docs
This commit is contained in:
3
example/README.md
Normal file
3
example/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Examples
|
||||
|
||||
Some examples of how to use the built-in middleware and configure custom servers.
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
3
example/custom/cache-control/.local-web-server.json
Normal file
3
example/custom/cache-control/.local-web-server.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"maxage": 2000
|
||||
}
|
18
example/custom/cache-control/server.js
Normal file
18
example/custom/cache-control/server.js
Normal 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()
|
10
example/custom/live-reload-optional/index.html
Normal file
10
example/custom/live-reload-optional/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>
|
19
example/custom/live-reload-optional/server.js
Normal file
19
example/custom/live-reload-optional/server.js
Normal 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()
|
10
example/custom/live-reload/index.html
Normal file
10
example/custom/live-reload/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>
|
9
example/custom/live-reload/server.js
Normal file
9
example/custom/live-reload/server.js
Normal 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()
|
Reference in New Issue
Block a user