This commit is contained in:
Lloyd Brookes
2015-11-19 10:01:04 +00:00
parent aab1f04a2f
commit bbd0d9fbe6
4 changed files with 93 additions and 11 deletions

View File

@ -14,7 +14,7 @@ module.exports = {
},
{
name: 'compress', alias: 'c', type: Boolean,
description: 'Enable gzip compression, reduces bandwidth.', group: 'server'
description: 'Serve gzip-compressed resources, where applicable', group: 'server'
},
{
name: 'forbid', alias: 'b', type: String, multiple: true, typeLabel: '[underline]{path} ...',

View File

@ -17,13 +17,21 @@ module.exports = localWebServer
* Returns a Koa application
*
* @param [options] {object} - options
* @param [options.static] {object} - koajs/static config
* @param [options.static] {object} - koa-static config
* @param [options.static.root] {string} - root directory
* @param [options.static.options] {string} - options
* @param [options.static.options] {string} - [options](https://github.com/koajs/static#options)
* @param [options.serveIndex] {object} - koa-serve-index config
* @param [options.serveIndex.path] {string} - root directory
* @param [options.serveIndex.options] {string} - options
* @param [options.forbid] {string[]} - a list of forbidden routes.
* @param [options.serveIndex.options] {string} - [options](https://github.com/expressjs/serve-index#options)
* @param [options.forbid] {string[]} - A list of forbidden routes, each route being an [express route-path](http://expressjs.com/guide/routing.html#route-paths).
* @param [options.spa] {string} - specify an SPA file to catch requests for everything but static assets.
* @param [options.log] {object} - [morgan](https://github.com/expressjs/morgan) config
* @param [options.log.format] {string} - [log format](https://github.com/expressjs/morgan#predefined-formats)
* @param [options.log.options] {object} - [options](https://github.com/expressjs/morgan#options)
* @param [options.compress] {boolean} - Serve gzip-compressed resources, where applicable
* @param [options.mime] {object} - A list of mime-type overrides, passed directly to [mime.define()](https://github.com/broofa/node-mime#mimedefine)
* @param [options.rewrite] {module:local-web-server~rewriteRule[]} - One or more rewrite rules
* @param [options.verbose] {boolean} - Print detailed output, useful for debugging
*
* @alias module:local-web-server
* @example
@ -213,3 +221,22 @@ function blacklist (forbid) {
process.on('unhandledRejection', (reason, p) => {
throw reason
})
/**
* The `from` and `to` routes are specified using [express route-paths](http://expressjs.com/guide/routing.html#route-paths)
*
* @example
* ```json
* {
* "rewrite": [
* { "from": "/css/*", "to": "/build/styles/$1" },
* { "from": "/npm/*", "to": "http://registry.npmjs.org/$1" },
* { "from": "/:user/repos/:name", "to": "https://api.github.com/repos/:user/:name" }
* ]
* }
* ```
*
* @typedef rewriteRule
* @property from {string} - request route
* @property to {string} - target route
*/