extend examples

This commit is contained in:
Lloyd Brookes
2016-06-18 10:29:34 +01:00
parent aee47bc599
commit 6298f693cd
8 changed files with 39 additions and 10 deletions

View File

@ -0,0 +1,3 @@
{
"maxage": 2000
}

View File

@ -1,13 +1,14 @@
'use strict'
const LocalWebServer = require('../')
const LocalWebServer = require('../../')
const cacheControl = require('koa-cache-control')
const optionDefinitions = { name: 'maxage', type: Number, defaultValue: 1000 }
const ws = new LocalWebServer()
ws.addLogging('dev')
.add({
optionDefinitions: optionDefinitions,
optionDefinitions: {
name: 'maxage', type: Number,
description: 'The maxage to set on each response.'
},
middleware: function (options) {
return cacheControl({ maxAge: options.maxage })
}

View File

@ -0,0 +1,19 @@
'use strict'
const Cli = require('../../')
const liveReload = require('koa-livereload')
const ws = new Cli()
ws.addLogging('dev')
.add({
optionDefinitions: {
name: 'live-reload', type: Boolean,
description: 'Add live reload.'
},
middleware: function (options) {
if (options['live-reload']) {
return liveReload()
}
}
})
.addStatic()
.start()

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

@ -1,5 +1,5 @@
'use strict'
const Cli = require('../')
const Cli = require('../../')
const liveReload = require('koa-livereload')
const ws = new Cli()

View File

@ -38,7 +38,7 @@ function usage (middlewareDefinitions) {
{
header: 'Synopsis',
content: [
'$ ws [<server options>]',
'$ ws [--verbose] [<server options>] [<middleware options>]',
'$ ws --config',
'$ ws --help'
]

View File

@ -146,7 +146,3 @@ function validateOptions (options) {
}
module.exports = LocalWebServer
process.on('unhandledRejection', (reason, p) => {
console.error('unhandledRejection', reason, p)
})