added --stack option.. refactor

This commit is contained in:
Lloyd Brookes
2016-06-24 21:18:23 +01:00
parent fec62b7253
commit 6440486b0c
12 changed files with 105 additions and 436 deletions

View File

@ -0,0 +1,23 @@
'use strict'
const LocalWebServer = require('../../')
const cacheControl = require('koa-cache-control')
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 })
}
})
.addStatic()
.addIndex()
}
}
module.exports = CacheControl