update stack examples and deps

This commit is contained in:
Lloyd Brookes
2016-06-25 15:24:30 +01:00
parent 6440486b0c
commit 99f5b19d27
11 changed files with 60 additions and 87 deletions

View File

@ -5,19 +5,23 @@ const DefaultStack = require('local-web-server-default-stack')
class CacheControl extends DefaultStack {
addAll () {
this.addLogging('dev')
.add({
optionDefinitions: {
name: 'maxage', type: Number,
description: 'The maxage to set on each response.'
},
middleware: function (options) {
return cacheControl({ maxAge: options.maxage })
}
})
return this.addLogging('dev')
.addCacheControl()
.addStatic()
.addIndex()
}
addCacheControl () {
this.add({
optionDefinitions: {
name: 'maxage', type: Number,
description: 'The maxage to set on each response.'
},
middleware: function (options) {
return cacheControl({ maxAge: options.maxage })
}
})
return this
}
}
module.exports = CacheControl

View File

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

View File

@ -0,0 +1,24 @@
'use strict'
const LocalWebServer = require('../../../')
const liveReload = require('koa-livereload')
const DefaultStack = require('local-web-server-default-stack')
class LiveReloadStack extends DefaultStack {
addAll () {
return this.addLogging('dev')
.add({
optionDefinitions: {
name: 'live-reload', type: Boolean,
description: 'Add live reload.'
},
middleware: function (options) {
if (options['live-reload']) {
return liveReload()
}
}
})
.addStatic()
}
}
module.exports = LiveReloadStack

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,14 @@
'use strict'
const LocalWebServer = require('../../../')
const liveReload = require('koa-livereload')
const DefaultStack = require('local-web-server-default-stack')
class LiveReloadStack extends DefaultStack {
addAll () {
return this.addLogging('dev')
.add({ middleware: liveReload })
.addStatic()
}
}
module.exports = LiveReloadStack