update stack examples and deps
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
{
|
||||
"maxage": 2000
|
||||
}
|
@ -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()
|
@ -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()
|
@ -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()
|
@ -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
|
||||
|
@ -5,6 +5,6 @@
|
||||
<title>live-reload demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Live reloaded attached</h1>
|
||||
<h1>Live reloaded potentially attached</h1>
|
||||
</body>
|
||||
</html>
|
24
example/stack/live-reload-optional/stack.js
Normal file
24
example/stack/live-reload-optional/stack.js
Normal 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
|
14
example/stack/live-reload/stack.js
Normal file
14
example/stack/live-reload/stack.js
Normal 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
|
@ -5,7 +5,6 @@ const path = require('path')
|
||||
const arrayify = require('array-back')
|
||||
const t = require('typical')
|
||||
const CommandLineTool = require('command-line-tool')
|
||||
const DefaultStack = require('local-web-server-default-stack')
|
||||
|
||||
/**
|
||||
* @module local-web-server
|
||||
@ -30,7 +29,7 @@ class LocalWebServer {
|
||||
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.addAll()
|
||||
const middlewareOptionDefinitions = this.stack.getOptionDefinitions()
|
||||
|
31
package.json
31
package.json
@ -34,38 +34,19 @@
|
||||
"dependencies": {
|
||||
"ansi-escape-sequences": "^2.2.2",
|
||||
"array-back": "^1.0.3",
|
||||
"command-line-tool": "~0.3.0",
|
||||
"config-master": "^2.0.2",
|
||||
"http-proxy": "^1.13.3",
|
||||
"kcors": "^1.2.1",
|
||||
"command-line-tool": "~0.3.1",
|
||||
"config-master": "^2.0.3",
|
||||
"koa": "^2.0.0",
|
||||
"koa-bodyparser": "^3.0.0",
|
||||
"koa-compose": "^3.1.0",
|
||||
"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",
|
||||
"local-web-server-default-stack": "github:local-web-server/default-stack",
|
||||
"reduce-flatten": "^1.0.1",
|
||||
"typical": "^2.4.2",
|
||||
"walk-back": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jsdoc-to-markdown": "^1.3.6",
|
||||
"koa-cache-control": "^1.0.0",
|
||||
"koa-livereload": "^0.1.23",
|
||||
"koa-livereload": "~0.2.0",
|
||||
"req-then": "~0.2.4",
|
||||
"tape": "^4.5.1"
|
||||
"tape": "^4.6.0"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user