refactor
This commit is contained in:
@ -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(() => {
|
||||
|
Reference in New Issue
Block a user