|
|
@ -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()) |
|
|
|
|
|
|
|