extract koa-mock-response and lws stack

This commit is contained in:
Lloyd Brookes
2016-06-22 22:24:11 +01:00
parent 6100ad6f6e
commit fec62b7253
6 changed files with 38 additions and 122 deletions

View File

@ -18,15 +18,22 @@ const tool = new CommandLineTool()
* @alias module:local-web-server
* @extends module:middleware-stack
*/
class LocalWebServer extends DefaultStack {
class LocalWebServer {
constructor (stack) {
this.stack = stack || new DefaultStack()
this.stack.addAll()
}
_init (options) {
this.options = this.options || Object.assign(options || {}, collectUserOptions(this.getOptionDefinitions()))
this.options = this.options || Object.assign(options || {}, collectUserOptions(this.stack.getOptionDefinitions()))
}
addStack (stack) {
this.stack = stack
}
getApplication (options) {
this._init(options)
const Koa = require('koa')
const app = new Koa()
app.use(this.compose(this.options))
app.use(this.stack.compose(this.options))
return app
}