Browse Source

arrayify input

master
Lloyd Brookes 9 years ago
parent
commit
a3f5164fb3
  1. 18
      lib/local-web-server.js
  2. 1
      lib/middleware.js

18
lib/local-web-server.js

@ -1,6 +1,7 @@
'use strict' 'use strict'
const path = require('path') const path = require('path')
const url = require('url') const url = require('url')
const arrayify = require('array-back')
/** /**
* @module local-web-server * @module local-web-server
@ -50,6 +51,16 @@ function localWebServer (options) {
process.env.DEBUG = '*' 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 debug = require('debug')('local-web-server')
const Koa = require('koa') const Koa = require('koa')
const convert = require('koa-convert') const convert = require('koa-convert')
@ -59,17 +70,10 @@ function localWebServer (options) {
const bodyParser = require('koa-bodyparser') const bodyParser = require('koa-bodyparser')
const mw = require('./middleware') const mw = require('./middleware')
const log = options.log
log.options = log.options || {}
const app = new Koa() const app = new Koa()
const _use = app.use const _use = app.use
app.use = x => _use.call(app, convert(x)) app.use = x => _use.call(app, convert(x))
if (options.verbose && !log.format) {
log.format = 'none'
}
/* CORS: allow from any origin */ /* CORS: allow from any origin */
app.use(cors()) app.use(cors())

1
lib/middleware.js

@ -91,6 +91,7 @@ function mockResponses (options) {
if (t.isFunction(mock.response)) { if (t.isFunction(mock.response)) {
mockedResponse = new mock.response(ctx) mockedResponse = new mock.response(ctx)
} }
debug('mock response: %j', mockedResponse)
Object.assign(ctx.response, mockedResponse) Object.assign(ctx.response, mockedResponse)
} }
} else { } else {

Loading…
Cancel
Save