refactor
This commit is contained in:
@ -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
10
extend/index.html
Normal 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>
|
@ -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()
|
||||
|
Reference in New Issue
Block a user