This commit is contained in:
Lloyd Brookes
2016-06-20 20:32:32 +01:00
parent ef9bbf8066
commit 22612bbcf4
34 changed files with 59 additions and 88 deletions

3
example/README.md Normal file
View File

@ -0,0 +1,3 @@
# Examples
Some examples of how to use the built-in middleware and configure custom servers.

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

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

View File

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

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

@ -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()
.listen()

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

@ -0,0 +1,9 @@
'use strict'
const Cli = require('../../')
const liveReload = require('koa-livereload')
const ws = new Cli()
ws.addLogging('dev')
.add({ middleware: liveReload })
.addStatic()
.listen()