This commit is contained in:
Lloyd Brookes
2016-06-16 23:00:07 +01:00
parent 789b82160d
commit 9c3db53d27
9 changed files with 309 additions and 252 deletions

View File

@ -1,6 +1,5 @@
'use strict'
const path = require('path')
const http = require('http')
const url = require('url')
const arrayify = require('array-back')
const t = require('typical')
@ -11,7 +10,6 @@ const debug = require('debug')('local-web-server')
* @module middleware
*/
exports.proxyRequest = proxyRequest
exports.blacklist = blacklist
exports.mockResponses = mockResponses
exports.mime = mime
@ -49,16 +47,6 @@ function proxyRequest (route) {
}
}
function blacklist (forbid) {
return function blacklist (ctx, next) {
if (forbid.some(expression => pathToRegexp(expression).test(ctx.path))) {
ctx.throw(403, http.STATUS_CODES[403])
} else {
return next()
}
}
}
function mime (mimeTypes) {
return function mime (ctx, next) {
return next().then(() => {