diff --git a/lib/local-web-server.js b/lib/local-web-server.js index a565af7..d3bed26 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -1,6 +1,7 @@ 'use strict' const path = require('path') const url = require('url') +const arrayify = require('array-back') /** * @module local-web-server @@ -50,6 +51,16 @@ function localWebServer (options) { process.env.DEBUG = '*' } + const log = options.log + log.options = log.options || {} + + if (options.verbose && !log.format) { + log.format = 'none' + } + + options.rewrite = arrayify(options.rewrite) + options.forbid = arrayify(options.forbid) + const debug = require('debug')('local-web-server') const Koa = require('koa') const convert = require('koa-convert') @@ -59,17 +70,10 @@ function localWebServer (options) { const bodyParser = require('koa-bodyparser') const mw = require('./middleware') - const log = options.log - log.options = log.options || {} - const app = new Koa() const _use = app.use app.use = x => _use.call(app, convert(x)) - if (options.verbose && !log.format) { - log.format = 'none' - } - /* CORS: allow from any origin */ app.use(cors()) diff --git a/lib/middleware.js b/lib/middleware.js index 68336d5..e882b52 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -91,6 +91,7 @@ function mockResponses (options) { if (t.isFunction(mock.response)) { mockedResponse = new mock.response(ctx) } + debug('mock response: %j', mockedResponse) Object.assign(ctx.response, mockedResponse) } } else {