docs.. log-format alias changed.. forbid option
This commit is contained in:
@ -27,7 +27,7 @@ module.exports = localWebServer
|
||||
* Returns a Koa application
|
||||
*
|
||||
* @param [options] {object} - options
|
||||
* @param [options.blacklist] {regexp[]} - a list of forbidden routes.
|
||||
* @param [options.forbid] {regexp[]} - a list of forbidden routes.
|
||||
* @alias module:local-web-server
|
||||
* @example
|
||||
* const localWebServer = require('local-web-server')
|
||||
@ -38,7 +38,7 @@ function localWebServer (options) {
|
||||
serveIndex: {},
|
||||
log: {},
|
||||
compress: false,
|
||||
blacklist: [],
|
||||
forbid: [],
|
||||
directories: [],
|
||||
proxyRoutes: []
|
||||
}, options)
|
||||
@ -82,9 +82,9 @@ function localWebServer (options) {
|
||||
app.use(cors())
|
||||
|
||||
/* path blacklist */
|
||||
if (options.blacklist.length) {
|
||||
app.use(function pathBlacklist (ctx, next) {
|
||||
if (options.blacklist.some(regexp => regexp.test(ctx.path))) {
|
||||
if (options.forbid.length) {
|
||||
app.use(function blacklist (ctx, next) {
|
||||
if (options.forbid.some(regexp => regexp.test(ctx.path))) {
|
||||
ctx.throw(403, http.STATUS_CODES[403])
|
||||
} else {
|
||||
return next()
|
||||
|
Reference in New Issue
Block a user