docs.. log-format alias changed.. forbid option

This commit is contained in:
Lloyd Brookes
2015-11-15 23:00:17 +00:00
parent d52dc38a91
commit b945f29feb
6 changed files with 41 additions and 79 deletions

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Web server port', group: 'server'
},
{
name: 'log-format', alias: 'f', type: String,
name: 'log-format', alias: 'l', type: String,
description: "If a format is supplied an access log is written to stdout. If not, a statistics view is displayed. Use a preset ('none', 'dev','combined', 'short', 'tiny' or 'logstalgia') or supply a custom format (e.g. ':method -> :url').", group: 'server'
},
{
@ -17,6 +17,10 @@ module.exports = {
description: 'Enable gzip compression, reduces bandwidth.', group: 'server'
},
{
name: 'forbid', alias: 'f', type: String, multiple: true, typeLabel: '[underline]{regexp} ...',
description: 'A list of forbidden routes', group: 'server'
},
{
name: 'no-cache', alias: 'n', type: Boolean,
description: 'Disable etag-based caching - forces loading from disk each request.', group: 'server'
},

View File

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