This commit is contained in:
Lloyd Brookes
2016-06-16 23:00:07 +01:00
parent 789b82160d
commit 9c3db53d27
9 changed files with 309 additions and 252 deletions

View File

@ -1,16 +1,17 @@
'use strict'
const LocalWebServer = require('../')
const cacheControl = require('koa-cache-control')
const cliData = require('../lib/cli-data')
cliData.optionDefinitions.push({ name: 'maxage', group: 'misc' })
const optionDefinitions = { name: 'maxage', type: Number, defaultValue: 1000 }
const ws = new LocalWebServer()
ws.middleware
.addLogging('dev')
.add(cacheControl({
maxAge: 15
}))
ws.addLogging('dev')
.add({
optionDefinitions: optionDefinitions,
middleware: function (options) {
return cacheControl({ maxAge: options.middleware.maxage })
}
})
.addStatic()
.addIndex()
ws.listen()
.start()

10
extend/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>live-reload demo</title>
</head>
<body>
<h1>Live reloaded attached</h1>
</body>
</html>

View File

@ -3,8 +3,7 @@ const Cli = require('../')
const liveReload = require('koa-livereload')
const ws = new Cli()
ws.middleware
.addLogging('dev')
.add(liveReload())
ws.addLogging('dev')
.add({ middleware: liveReload })
.addStatic()
ws.listen(8000)
.start()