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

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

View File

@ -1,18 +0,0 @@
'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

@ -1,19 +0,0 @@
'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

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

View File

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

View File

@ -5,6 +5,6 @@
<title>live-reload demo</title> <title>live-reload demo</title>
</head> </head>
<body> <body>
<h1>Live reloaded attached</h1> <h1>Live reloaded potentially attached</h1>
</body> </body>
</html> </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,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

View File

@ -5,7 +5,6 @@ const path = require('path')
const arrayify = require('array-back') const arrayify = require('array-back')
const t = require('typical') const t = require('typical')
const CommandLineTool = require('command-line-tool') const CommandLineTool = require('command-line-tool')
const DefaultStack = require('local-web-server-default-stack')
/** /**
* @module local-web-server * @module local-web-server
@ -30,7 +29,7 @@ class LocalWebServer {
if (/^-/.test(stackPath)) stackPath = null if (/^-/.test(stackPath)) stackPath = null
} }
const stackModule = loadStack(stackPath) || DefaultStack const stackModule = loadStack(stackPath) || require('local-web-server-default-stack')
this.stack = new stackModule() this.stack = new stackModule()
this.stack.addAll() this.stack.addAll()
const middlewareOptionDefinitions = this.stack.getOptionDefinitions() const middlewareOptionDefinitions = this.stack.getOptionDefinitions()

View File

@ -34,38 +34,19 @@
"dependencies": { "dependencies": {
"ansi-escape-sequences": "^2.2.2", "ansi-escape-sequences": "^2.2.2",
"array-back": "^1.0.3", "array-back": "^1.0.3",
"command-line-tool": "~0.3.0", "command-line-tool": "~0.3.1",
"config-master": "^2.0.2", "config-master": "^2.0.3",
"http-proxy": "^1.13.3",
"kcors": "^1.2.1",
"koa": "^2.0.0", "koa": "^2.0.0",
"koa-bodyparser": "^3.0.0", "local-web-server-default-stack": "github:local-web-server/default-stack",
"koa-compose": "^3.1.0", "reduce-flatten": "^1.0.1",
"koa-compress": "^1.0.9",
"koa-conditional-get": "^1.0.3",
"koa-convert": "^1.2.0",
"koa-etag": "^2.1.1",
"koa-json": "^1.1.3",
"koa-mock-response": "0.0.2",
"koa-morgan": "^1.0.1",
"koa-rewrite": "^2.1.0",
"koa-route": "^3.0.0",
"koa-send": "^3.2.0",
"koa-serve-index": "^1.1.1",
"koa-static": "^2.0.0",
"local-web-server-stack": "github:75lb/local-web-server-stack",
"path-to-regexp": "^1.5.0",
"reduce-flatten": "^1.0.0",
"stream-log-stats": "^1.1.3",
"test-value": "^2.0.0",
"typical": "^2.4.2", "typical": "^2.4.2",
"walk-back": "^2.0.1" "walk-back": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {
"jsdoc-to-markdown": "^1.3.6", "jsdoc-to-markdown": "^1.3.6",
"koa-cache-control": "^1.0.0", "koa-cache-control": "^1.0.0",
"koa-livereload": "^0.1.23", "koa-livereload": "~0.2.0",
"req-then": "~0.2.4", "req-then": "~0.2.4",
"tape": "^4.5.1" "tape": "^4.6.0"
} }
} }