Changements dans les modules (nouvelle version Express, mysql, ..)
This commit is contained in:
82
node_modules/router/HISTORY.md
generated
vendored
Normal file
82
node_modules/router/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
1.1.5 / 2017-01-28
|
||||
==================
|
||||
|
||||
* deps: array-flatten@2.1.1
|
||||
* deps: setprototypeof@1.0.2
|
||||
- Fix using fallback even when native method exists
|
||||
|
||||
1.1.4 / 2016-01-21
|
||||
==================
|
||||
|
||||
* deps: array-flatten@2.0.0
|
||||
* deps: methods@~1.1.2
|
||||
- perf: enable strict mode
|
||||
* deps: parseurl@~1.3.1
|
||||
- perf: enable strict mode
|
||||
|
||||
1.1.3 / 2015-08-02
|
||||
==================
|
||||
|
||||
* Fix infinite loop condition using `mergeParams: true`
|
||||
* Fix inner numeric indices incorrectly altering parent `req.params`
|
||||
* deps: array-flatten@1.1.1
|
||||
- perf: enable strict mode
|
||||
* deps: path-to-regexp@0.1.7
|
||||
- Fix regression with escaped round brackets and matching groups
|
||||
|
||||
1.1.2 / 2015-07-06
|
||||
==================
|
||||
|
||||
* Fix hiding platform issues with `decodeURIComponent`
|
||||
- Only `URIError`s are a 400
|
||||
* Fix using `*` before params in routes
|
||||
* Fix using capture groups before params in routes
|
||||
* deps: path-to-regexp@0.1.6
|
||||
* perf: enable strict mode
|
||||
* perf: remove argument reassignments in routing
|
||||
* perf: skip attempting to decode zero length string
|
||||
* perf: use plain for loops
|
||||
|
||||
1.1.1 / 2015-05-25
|
||||
==================
|
||||
|
||||
* Fix issue where `next('route')` in `router.param` would incorrectly skip values
|
||||
* deps: array-flatten@1.1.0
|
||||
* deps: debug@~2.2.0
|
||||
- deps: ms@0.7.1
|
||||
|
||||
1.1.0 / 2015-04-22
|
||||
==================
|
||||
|
||||
* Use `setprototypeof` instead of `__proto__`
|
||||
* deps: debug@~2.1.3
|
||||
- Fix high intensity foreground color for bold
|
||||
- deps: ms@0.7.0
|
||||
|
||||
1.0.0 / 2015-01-13
|
||||
==================
|
||||
|
||||
* Fix crash from error within `OPTIONS` response handler
|
||||
* deps: array-flatten@1.0.2
|
||||
- Remove redundant code path
|
||||
|
||||
1.0.0-beta.3 / 2015-01-11
|
||||
=========================
|
||||
|
||||
* Fix duplicate methods appearing in OPTIONS responses
|
||||
* Fix OPTIONS responses to include the HEAD method properly
|
||||
* Remove support for leading colon in `router.param(name, fn)`
|
||||
* Use `array-flatten` for flattening arrays
|
||||
* deps: debug@~2.1.1
|
||||
* deps: methods@~1.1.1
|
||||
|
||||
1.0.0-beta.2 / 2014-11-19
|
||||
=========================
|
||||
|
||||
* Match routes iteratively to prevent stack overflows
|
||||
|
||||
1.0.0-beta.1 / 2014-11-16
|
||||
=========================
|
||||
|
||||
* Initial release ported from Express 4.x
|
||||
- Altered to work without Express
|
||||
23
node_modules/router/LICENSE
generated
vendored
Normal file
23
node_modules/router/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Roman Shtylman
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
311
node_modules/router/README.md
generated
vendored
Normal file
311
node_modules/router/README.md
generated
vendored
Normal file
@@ -0,0 +1,311 @@
|
||||
# router
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Simple middleware-style router
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install router
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
var http = require('http')
|
||||
var Router = require('router')
|
||||
|
||||
var router = Router()
|
||||
router.get('/', function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end('Hello World!')
|
||||
})
|
||||
|
||||
var server = http.createServer(function(req, res) {
|
||||
router(req, res, finalhandler(req, res))
|
||||
})
|
||||
|
||||
server.listen(3000)
|
||||
```
|
||||
|
||||
This module is currently an extracted version from the Express project,
|
||||
but with the main change being it can be used with a plain `http.createServer`
|
||||
object or other web frameworks by removing Express-specific API calls.
|
||||
|
||||
## Router(options)
|
||||
|
||||
Options
|
||||
|
||||
- `strict` - When `false` trailing slashes are optional (default: `false`)
|
||||
- `caseSensitive` - When `true` the routing will be case sensitive. (default: `false`)
|
||||
- `mergeParams` - When `true` any `req.params` passed to the router will be
|
||||
merged into the router's `req.params`. (default: `false`) ([example](#example-using-mergeparams))
|
||||
|
||||
Returns a function with the signature `router(req, res, callback)` where
|
||||
`callback([err])` must be provided to handle errors and fall-through from
|
||||
not handling requests.
|
||||
|
||||
### router.use([path], ...middleware)
|
||||
|
||||
Use the given middleware function for all http methods on the given `path`,
|
||||
defaulting to the root path.
|
||||
|
||||
`router` does not automatically see `use` as a handler. As such, it will not
|
||||
consider it one for handling `OPTIONS` requests.
|
||||
|
||||
* Note: If a `path` is specified, that `path` is stripped from the start of
|
||||
`req.url`.
|
||||
|
||||
```js
|
||||
router.use(function (req, res, next) {
|
||||
// do your things
|
||||
|
||||
// continue to the next middleware
|
||||
// the request will stall if this is not called
|
||||
next()
|
||||
|
||||
// note: you should NOT call `next` if you have begun writing to the response
|
||||
})
|
||||
```
|
||||
|
||||
### router\[method](path, ...[middleware], handler)
|
||||
|
||||
The [http methods](https://github.com/jshttp/methods/blob/master/index.js) provide
|
||||
the routing functionality in `router`.
|
||||
|
||||
These are functions which you can directly call on the router to register a new
|
||||
`handler` for the `method` at a specified `path`.
|
||||
|
||||
```js
|
||||
// handle a `GET` request
|
||||
router.get('/', function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end('Hello World!')
|
||||
})
|
||||
```
|
||||
|
||||
Additional middleware may be given before the handler. These middleware behave
|
||||
exactly as normal with one exception: they may invoke `next('route')`.
|
||||
Calling `next('route')` bypasses the remaining middleware and handler for this
|
||||
route, passing the request on to the next route.
|
||||
|
||||
### router.param(name, param_middleware)
|
||||
|
||||
Maps the specified path parameter `name` to a specialized param-capturing middleware.
|
||||
|
||||
This function positions the middleware in the same stack as `.use`.
|
||||
|
||||
Parameter mapping is used to provide pre-conditions to routes
|
||||
which use normalized placeholders. For example a _:user_id_ parameter
|
||||
could automatically load a user's information from the database without
|
||||
any additional code:
|
||||
|
||||
```js
|
||||
router.param('user_id', function (req, res, next, id) {
|
||||
User.find(id, function (err, user) {
|
||||
if (err) {
|
||||
return next(err)
|
||||
} else if (!user) {
|
||||
return next(new Error('failed to load user'))
|
||||
}
|
||||
req.user = user
|
||||
|
||||
// continue processing the request
|
||||
next()
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
### router.route(path)
|
||||
|
||||
Creates an instance of a single `Route` for the given `path`.
|
||||
(See `Router.Route` below)
|
||||
|
||||
Routes can be used to handle http `methods` with their own, optional middleware.
|
||||
|
||||
Using `router.route(path)` is a recommended approach to avoiding duplicate
|
||||
route naming and thus typo errors.
|
||||
|
||||
```js
|
||||
var api = router.route('/api/')
|
||||
```
|
||||
|
||||
## Router.Route(path)
|
||||
|
||||
Represents a single route as an instance that can be used can be used to handle
|
||||
http `methods` with it's own, optional middleware.
|
||||
|
||||
### route\[method](handler)
|
||||
|
||||
These are functions which you can directly call on a route to register a new
|
||||
`handler` for the `method` on the route.
|
||||
|
||||
```js
|
||||
// handle a `GET` request
|
||||
var status = router.route('/status')
|
||||
|
||||
status.get(function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end('All Systems Green!')
|
||||
})
|
||||
```
|
||||
|
||||
### route.all(handler)
|
||||
|
||||
Adds a handler for all HTTP methods to this route.
|
||||
|
||||
The handler can behave like middleware and call `next` to continue processing
|
||||
rather than responding.
|
||||
|
||||
```js
|
||||
router.route('/')
|
||||
.all(function (req, res, next) {
|
||||
next()
|
||||
})
|
||||
.all(check_something)
|
||||
.get(function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end('Hello World!')
|
||||
})
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
// import our modules
|
||||
var http = require('http')
|
||||
var Router = require('router')
|
||||
var finalhandler = require('finalhandler')
|
||||
var compression = require('compression')
|
||||
var bodyParser = require('body-parser')
|
||||
|
||||
// store our message to display
|
||||
var message = "Hello World!"
|
||||
|
||||
// initialize the router & server and add a final callback.
|
||||
var router = Router()
|
||||
var server = http.createServer(function onRequest(req, res) {
|
||||
router(req, res, finalhandler(req, res))
|
||||
})
|
||||
|
||||
// use some middleware and compress all outgoing responses
|
||||
router.use(compression())
|
||||
|
||||
// handle `GET` requests to `/message`
|
||||
router.get('/message', function (req, res) {
|
||||
res.statusCode = 200
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end(message + '\n')
|
||||
})
|
||||
|
||||
// create and mount a new router for our API
|
||||
var api = Router()
|
||||
router.use('/api/', api)
|
||||
|
||||
// add a body parsing middleware to our API
|
||||
api.use(bodyParser.json())
|
||||
|
||||
// handle `PATCH` requests to `/api/set-message`
|
||||
api.patch('/set-message', function (req, res) {
|
||||
if (req.body.value) {
|
||||
message = req.body.value
|
||||
|
||||
res.statusCode = 200
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end(message + '\n')
|
||||
} else {
|
||||
res.statusCode = 400
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end('Invalid API Syntax\n')
|
||||
}
|
||||
})
|
||||
|
||||
// make our http server listen to connections
|
||||
server.listen(8080)
|
||||
```
|
||||
|
||||
You can get the message by running this command in your terminal,
|
||||
or navigating to `127.0.0.1:8080` in a web browser.
|
||||
```bash
|
||||
curl http://127.0.0.1:8080
|
||||
```
|
||||
|
||||
You can set the message by sending it a `PATCH` request via this command:
|
||||
```bash
|
||||
curl http://127.0.0.1:8080/api/set-message -X PATCH -H "Content-Type: application/json" -d '{"value":"Cats!"}'
|
||||
```
|
||||
|
||||
### Example using mergeParams
|
||||
|
||||
```js
|
||||
var http = require('http')
|
||||
var Router = require('router')
|
||||
var finalhandler = require('finalhandler')
|
||||
|
||||
// this example is about the mergeParams option
|
||||
var opts = { mergeParams: true }
|
||||
|
||||
// make a router with out special options
|
||||
var router = Router(opts)
|
||||
var server = http.createServer(function onRequest(req, res) {
|
||||
|
||||
// set something to be passed into the router
|
||||
req.params = { type: 'kitten' }
|
||||
|
||||
router(req, res, finalhandler(req, res))
|
||||
})
|
||||
|
||||
router.get('/', function (req, res) {
|
||||
res.statusCode = 200
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
|
||||
// with respond with the the params that were passed in
|
||||
res.end(req.params.type + '\n')
|
||||
})
|
||||
|
||||
// make another router with our options
|
||||
var handler = Router(opts)
|
||||
|
||||
// mount our new router to a route that accepts a param
|
||||
router.use('/:path', handler)
|
||||
|
||||
handler.get('/', function (req, res) {
|
||||
res.statusCode = 200
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
|
||||
// will respond with the param of the router's parent route
|
||||
res.end(path + '\n')
|
||||
})
|
||||
|
||||
// make our http server listen to connections
|
||||
server.listen(8080)
|
||||
```
|
||||
|
||||
Now you can get the type, or what path you are requesting:
|
||||
```bash
|
||||
curl http://127.0.0.1:8080
|
||||
> kitten
|
||||
curl http://127.0.0.1:8080/such_path
|
||||
> such_path
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/router.svg
|
||||
[npm-url]: https://npmjs.org/package/router
|
||||
[node-version-image]: https://img.shields.io/node/v/router.svg
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/pillarjs/router/master.svg
|
||||
[travis-url]: https://travis-ci.org/pillarjs/router
|
||||
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/router/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/pillarjs/router?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/router.svg
|
||||
[downloads-url]: https://npmjs.org/package/router
|
||||
735
node_modules/router/index.js
generated
vendored
Normal file
735
node_modules/router/index.js
generated
vendored
Normal file
@@ -0,0 +1,735 @@
|
||||
/*!
|
||||
* router
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var debug = require('debug')('router')
|
||||
var flatten = require('array-flatten')
|
||||
var Layer = require('./lib/layer')
|
||||
var methods = require('methods')
|
||||
var mixin = require('utils-merge')
|
||||
var parseUrl = require('parseurl')
|
||||
var Route = require('./lib/route')
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var slice = Array.prototype.slice
|
||||
|
||||
/* istanbul ignore next */
|
||||
var defer = typeof setImmediate === 'function'
|
||||
? setImmediate
|
||||
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) }
|
||||
|
||||
/**
|
||||
* Expose `Router`.
|
||||
*/
|
||||
|
||||
module.exports = Router
|
||||
|
||||
/**
|
||||
* Expose `Route`.
|
||||
*/
|
||||
|
||||
module.exports.Route = Route
|
||||
|
||||
/**
|
||||
* Initialize a new `Router` with the given `options`.
|
||||
*
|
||||
* @param {object} options
|
||||
* @return {Router} which is an callable function
|
||||
* @public
|
||||
*/
|
||||
|
||||
function Router(options) {
|
||||
if (!(this instanceof Router)) {
|
||||
return new Router(options)
|
||||
}
|
||||
|
||||
var opts = options || {}
|
||||
|
||||
function router(req, res, next) {
|
||||
router.handle(req, res, next)
|
||||
}
|
||||
|
||||
// inherit from the correct prototype
|
||||
setPrototypeOf(router, this)
|
||||
|
||||
router.caseSensitive = opts.caseSensitive
|
||||
router.mergeParams = opts.mergeParams
|
||||
router.params = {}
|
||||
router.strict = opts.strict
|
||||
router.stack = []
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
/**
|
||||
* Router prototype inherits from a Function.
|
||||
*/
|
||||
|
||||
/* istanbul ignore next */
|
||||
Router.prototype = function () {}
|
||||
|
||||
/**
|
||||
* Map the given param placeholder `name`(s) to the given callback.
|
||||
*
|
||||
* Parameter mapping is used to provide pre-conditions to routes
|
||||
* which use normalized placeholders. For example a _:user_id_ parameter
|
||||
* could automatically load a user's information from the database without
|
||||
* any additional code.
|
||||
*
|
||||
* The callback uses the same signature as middleware, the only difference
|
||||
* being that the value of the placeholder is passed, in this case the _id_
|
||||
* of the user. Once the `next()` function is invoked, just like middleware
|
||||
* it will continue on to execute the route, or subsequent parameter functions.
|
||||
*
|
||||
* Just like in middleware, you must either respond to the request or call next
|
||||
* to avoid stalling the request.
|
||||
*
|
||||
* router.param('user_id', function(req, res, next, id){
|
||||
* User.find(id, function(err, user){
|
||||
* if (err) {
|
||||
* return next(err)
|
||||
* } else if (!user) {
|
||||
* return next(new Error('failed to load user'))
|
||||
* }
|
||||
* req.user = user
|
||||
* next()
|
||||
* })
|
||||
* })
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {function} fn
|
||||
* @public
|
||||
*/
|
||||
|
||||
Router.prototype.param = function param(name, fn) {
|
||||
if (!name) {
|
||||
throw new TypeError('argument name is required')
|
||||
}
|
||||
|
||||
if (typeof name !== 'string') {
|
||||
throw new TypeError('argument name must be a string')
|
||||
}
|
||||
|
||||
if (!fn) {
|
||||
throw new TypeError('argument fn is required')
|
||||
}
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument fn must be a function')
|
||||
}
|
||||
|
||||
var params = this.params[name]
|
||||
|
||||
if (!params) {
|
||||
params = this.params[name] = []
|
||||
}
|
||||
|
||||
params.push(fn)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a req, res into the router.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
Router.prototype.handle = function handle(req, res, callback) {
|
||||
if (!callback) {
|
||||
throw new TypeError('argument callback is required')
|
||||
}
|
||||
|
||||
debug('dispatching %s %s', req.method, req.url)
|
||||
|
||||
var idx = 0
|
||||
var methods
|
||||
var protohost = getProtohost(req.url) || ''
|
||||
var removed = ''
|
||||
var self = this
|
||||
var slashAdded = false
|
||||
var paramcalled = {}
|
||||
|
||||
// middleware and routes
|
||||
var stack = this.stack
|
||||
|
||||
// manage inter-router variables
|
||||
var parentParams = req.params
|
||||
var parentUrl = req.baseUrl || ''
|
||||
var done = restore(callback, req, 'baseUrl', 'next', 'params')
|
||||
|
||||
// setup next layer
|
||||
req.next = next
|
||||
|
||||
// for options requests, respond with a default if nothing else responds
|
||||
if (req.method === 'OPTIONS') {
|
||||
methods = []
|
||||
done = wrap(done, generateOptionsResponder(res, methods))
|
||||
}
|
||||
|
||||
// setup basic req values
|
||||
req.baseUrl = parentUrl
|
||||
req.originalUrl = req.originalUrl || req.url
|
||||
|
||||
next()
|
||||
|
||||
function next(err) {
|
||||
var layerError = err === 'route'
|
||||
? null
|
||||
: err
|
||||
|
||||
// remove added slash
|
||||
if (slashAdded) {
|
||||
req.url = req.url.substr(1)
|
||||
slashAdded = false
|
||||
}
|
||||
|
||||
// restore altered req.url
|
||||
if (removed.length !== 0) {
|
||||
req.baseUrl = parentUrl
|
||||
req.url = protohost + removed + req.url.substr(protohost.length)
|
||||
removed = ''
|
||||
}
|
||||
|
||||
// no more matching layers
|
||||
if (idx >= stack.length) {
|
||||
defer(done, layerError)
|
||||
return
|
||||
}
|
||||
|
||||
// get pathname of request
|
||||
var path = getPathname(req)
|
||||
|
||||
if (path == null) {
|
||||
return done(layerError)
|
||||
}
|
||||
|
||||
// find next matching layer
|
||||
var layer
|
||||
var match
|
||||
var route
|
||||
|
||||
while (match !== true && idx < stack.length) {
|
||||
layer = stack[idx++]
|
||||
match = matchLayer(layer, path)
|
||||
route = layer.route
|
||||
|
||||
if (typeof match !== 'boolean') {
|
||||
// hold on to layerError
|
||||
layerError = layerError || match
|
||||
}
|
||||
|
||||
if (match !== true) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (!route) {
|
||||
// process non-route handlers normally
|
||||
continue
|
||||
}
|
||||
|
||||
if (layerError) {
|
||||
// routes do not match with a pending error
|
||||
match = false
|
||||
continue
|
||||
}
|
||||
|
||||
var method = req.method;
|
||||
var has_method = route._handles_method(method)
|
||||
|
||||
// build up automatic options response
|
||||
if (!has_method && method === 'OPTIONS' && methods) {
|
||||
methods.push.apply(methods, route._methods())
|
||||
}
|
||||
|
||||
// don't even bother matching route
|
||||
if (!has_method && method !== 'HEAD') {
|
||||
match = false
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// no match
|
||||
if (match !== true) {
|
||||
return done(layerError)
|
||||
}
|
||||
|
||||
// store route for dispatch on change
|
||||
if (route) {
|
||||
req.route = route
|
||||
}
|
||||
|
||||
// Capture one-time layer values
|
||||
req.params = self.mergeParams
|
||||
? mergeParams(layer.params, parentParams)
|
||||
: layer.params
|
||||
var layerPath = layer.path
|
||||
|
||||
// this should be done for the layer
|
||||
self.process_params(layer, paramcalled, req, res, function (err) {
|
||||
if (err) {
|
||||
return next(layerError || err)
|
||||
}
|
||||
|
||||
if (route) {
|
||||
return layer.handle_request(req, res, next)
|
||||
}
|
||||
|
||||
trim_prefix(layer, layerError, layerPath, path)
|
||||
})
|
||||
}
|
||||
|
||||
function trim_prefix(layer, layerError, layerPath, path) {
|
||||
var c = path[layerPath.length]
|
||||
|
||||
if (c && c !== '/') {
|
||||
next(layerError)
|
||||
return
|
||||
}
|
||||
|
||||
// Trim off the part of the url that matches the route
|
||||
// middleware (.use stuff) needs to have the path stripped
|
||||
if (layerPath.length !== 0) {
|
||||
debug('trim prefix (%s) from url %s', layerPath, req.url)
|
||||
removed = layerPath
|
||||
req.url = protohost + req.url.substr(protohost.length + removed.length)
|
||||
|
||||
// Ensure leading slash
|
||||
if (!protohost && req.url[0] !== '/') {
|
||||
req.url = '/' + req.url
|
||||
slashAdded = true
|
||||
}
|
||||
|
||||
// Setup base URL (no trailing slash)
|
||||
req.baseUrl = parentUrl + (removed[removed.length - 1] === '/'
|
||||
? removed.substring(0, removed.length - 1)
|
||||
: removed)
|
||||
}
|
||||
|
||||
debug('%s %s : %s', layer.name, layerPath, req.originalUrl)
|
||||
|
||||
if (layerError) {
|
||||
layer.handle_error(layerError, req, res, next)
|
||||
} else {
|
||||
layer.handle_request(req, res, next)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process any parameters for the layer.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
Router.prototype.process_params = function process_params(layer, called, req, res, done) {
|
||||
var params = this.params
|
||||
|
||||
// captured parameters from the layer, keys and values
|
||||
var keys = layer.keys
|
||||
|
||||
// fast track
|
||||
if (!keys || keys.length === 0) {
|
||||
return done()
|
||||
}
|
||||
|
||||
var i = 0
|
||||
var name
|
||||
var paramIndex = 0
|
||||
var key
|
||||
var paramVal
|
||||
var paramCallbacks
|
||||
var paramCalled
|
||||
|
||||
// process params in order
|
||||
// param callbacks can be async
|
||||
function param(err) {
|
||||
if (err) {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
if (i >= keys.length ) {
|
||||
return done()
|
||||
}
|
||||
|
||||
paramIndex = 0
|
||||
key = keys[i++]
|
||||
|
||||
if (!key) {
|
||||
return done()
|
||||
}
|
||||
|
||||
name = key.name
|
||||
paramVal = req.params[name]
|
||||
paramCallbacks = params[name]
|
||||
paramCalled = called[name]
|
||||
|
||||
if (paramVal === undefined || !paramCallbacks) {
|
||||
return param()
|
||||
}
|
||||
|
||||
// param previously called with same value or error occurred
|
||||
if (paramCalled && (paramCalled.match === paramVal
|
||||
|| (paramCalled.error && paramCalled.error !== 'route'))) {
|
||||
// restore value
|
||||
req.params[name] = paramCalled.value
|
||||
|
||||
// next param
|
||||
return param(paramCalled.error)
|
||||
}
|
||||
|
||||
called[name] = paramCalled = {
|
||||
error: null,
|
||||
match: paramVal,
|
||||
value: paramVal
|
||||
}
|
||||
|
||||
paramCallback()
|
||||
}
|
||||
|
||||
// single param callbacks
|
||||
function paramCallback(err) {
|
||||
var fn = paramCallbacks[paramIndex++]
|
||||
|
||||
// store updated value
|
||||
paramCalled.value = req.params[key.name]
|
||||
|
||||
if (err) {
|
||||
// store error
|
||||
paramCalled.error = err
|
||||
param(err)
|
||||
return
|
||||
}
|
||||
|
||||
if (!fn) return param()
|
||||
|
||||
try {
|
||||
fn(req, res, paramCallback, paramVal, key.name)
|
||||
} catch (e) {
|
||||
paramCallback(e)
|
||||
}
|
||||
}
|
||||
|
||||
param()
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the given middleware function, with optional path, defaulting to "/".
|
||||
*
|
||||
* Use (like `.all`) will run for any http METHOD, but it will not add
|
||||
* handlers for those methods so OPTIONS requests will not consider `.use`
|
||||
* functions even if they could respond.
|
||||
*
|
||||
* The other difference is that _route_ path is stripped and not visible
|
||||
* to the handler function. The main effect of this feature is that mounted
|
||||
* handlers can operate without any code changes regardless of the "prefix"
|
||||
* pathname.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
Router.prototype.use = function use(handler) {
|
||||
var offset = 0
|
||||
var path = '/'
|
||||
|
||||
// default path to '/'
|
||||
// disambiguate router.use([handler])
|
||||
if (typeof handler !== 'function') {
|
||||
var arg = handler
|
||||
|
||||
while (Array.isArray(arg) && arg.length !== 0) {
|
||||
arg = arg[0]
|
||||
}
|
||||
|
||||
// first arg is the path
|
||||
if (typeof arg !== 'function') {
|
||||
offset = 1
|
||||
path = handler
|
||||
}
|
||||
}
|
||||
|
||||
var callbacks = flatten(slice.call(arguments, offset))
|
||||
|
||||
if (callbacks.length === 0) {
|
||||
throw new TypeError('argument handler is required')
|
||||
}
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
var fn = callbacks[i]
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument handler must be a function')
|
||||
}
|
||||
|
||||
// add the middleware
|
||||
debug('use %s %s', path, fn.name || '<anonymous>')
|
||||
|
||||
var layer = new Layer(path, {
|
||||
sensitive: this.caseSensitive,
|
||||
strict: false,
|
||||
end: false
|
||||
}, fn)
|
||||
|
||||
layer.route = undefined
|
||||
|
||||
this.stack.push(layer)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Route for the given path.
|
||||
*
|
||||
* Each route contains a separate middleware stack and VERB handlers.
|
||||
*
|
||||
* See the Route api documentation for details on adding handlers
|
||||
* and middleware to routes.
|
||||
*
|
||||
* @param {string} path
|
||||
* @return {Route}
|
||||
* @public
|
||||
*/
|
||||
|
||||
Router.prototype.route = function route(path) {
|
||||
var route = new Route(path)
|
||||
|
||||
var layer = new Layer(path, {
|
||||
sensitive: this.caseSensitive,
|
||||
strict: this.strict,
|
||||
end: true
|
||||
}, handle)
|
||||
|
||||
function handle(req, res, next) {
|
||||
route.dispatch(req, res, next)
|
||||
}
|
||||
|
||||
layer.route = route
|
||||
|
||||
this.stack.push(layer)
|
||||
return route
|
||||
}
|
||||
|
||||
// create Router#VERB functions
|
||||
methods.concat('all').forEach(function(method){
|
||||
Router.prototype[method] = function (path) {
|
||||
var route = this.route(path)
|
||||
route[method].apply(route, slice.call(arguments, 1))
|
||||
return this
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Generate a callback that will make an OPTIONS response.
|
||||
*
|
||||
* @param {OutgoingMessage} res
|
||||
* @param {array} methods
|
||||
* @private
|
||||
*/
|
||||
|
||||
function generateOptionsResponder(res, methods) {
|
||||
return function onDone(fn, err) {
|
||||
if (err || methods.length === 0) {
|
||||
return fn(err)
|
||||
}
|
||||
|
||||
trySendOptionsResponse(res, methods, fn)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pathname of request.
|
||||
*
|
||||
* @param {IncomingMessage} req
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getPathname(req) {
|
||||
try {
|
||||
return parseUrl(req).pathname;
|
||||
} catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get get protocol + host for a URL.
|
||||
*
|
||||
* @param {string} url
|
||||
* @private
|
||||
*/
|
||||
|
||||
function getProtohost(url) {
|
||||
if (url.length === 0 || url[0] === '/') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var searchIndex = url.indexOf('?')
|
||||
var pathLength = searchIndex !== -1
|
||||
? searchIndex
|
||||
: url.length
|
||||
var fqdnIndex = url.substr(0, pathLength).indexOf('://')
|
||||
|
||||
return fqdnIndex !== -1
|
||||
? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
|
||||
: undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Match path to a layer.
|
||||
*
|
||||
* @param {Layer} layer
|
||||
* @param {string} path
|
||||
* @private
|
||||
*/
|
||||
|
||||
function matchLayer(layer, path) {
|
||||
try {
|
||||
return layer.match(path);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge params with parent params
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function mergeParams(params, parent) {
|
||||
if (typeof parent !== 'object' || !parent) {
|
||||
return params
|
||||
}
|
||||
|
||||
// make copy of parent for base
|
||||
var obj = mixin({}, parent)
|
||||
|
||||
// simple non-numeric merging
|
||||
if (!(0 in params) || !(0 in parent)) {
|
||||
return mixin(obj, params)
|
||||
}
|
||||
|
||||
var i = 0
|
||||
var o = 0
|
||||
|
||||
// determine numeric gap in params
|
||||
while (i in params) {
|
||||
i++
|
||||
}
|
||||
|
||||
// determine numeric gap in parent
|
||||
while (o in parent) {
|
||||
o++
|
||||
}
|
||||
|
||||
// offset numeric indices in params before merge
|
||||
for (i--; i >= 0; i--) {
|
||||
params[i + o] = params[i]
|
||||
|
||||
// create holes for the merge when necessary
|
||||
if (i < o) {
|
||||
delete params[i]
|
||||
}
|
||||
}
|
||||
|
||||
return mixin(obj, params)
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore obj props after function
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function restore(fn, obj) {
|
||||
var props = new Array(arguments.length - 2)
|
||||
var vals = new Array(arguments.length - 2)
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
props[i] = arguments[i + 2]
|
||||
vals[i] = obj[props[i]]
|
||||
}
|
||||
|
||||
return function(err){
|
||||
// restore vals
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
obj[props[i]] = vals[i]
|
||||
}
|
||||
|
||||
return fn.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an OPTIONS response.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function sendOptionsResponse(res, methods) {
|
||||
var options = Object.create(null)
|
||||
|
||||
// build unique method map
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
options[methods[i]] = true
|
||||
}
|
||||
|
||||
// construct the allow list
|
||||
var allow = Object.keys(options).sort().join(', ')
|
||||
|
||||
// send response
|
||||
res.setHeader('Allow', allow)
|
||||
res.setHeader('Content-Length', Buffer.byteLength(allow))
|
||||
res.setHeader('Content-Type', 'text/plain')
|
||||
res.setHeader('X-Content-Type-Options', 'nosniff')
|
||||
res.end(allow)
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to send an OPTIONS response.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function trySendOptionsResponse(res, methods, next) {
|
||||
try {
|
||||
sendOptionsResponse(res, methods)
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a function
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function wrap(old, fn) {
|
||||
return function proxy() {
|
||||
var args = new Array(arguments.length + 1)
|
||||
|
||||
args[0] = old
|
||||
for (var i = 0, len = arguments.length; i < len; i++) {
|
||||
args[i + 1] = arguments[i]
|
||||
}
|
||||
|
||||
fn.apply(this, args)
|
||||
}
|
||||
}
|
||||
175
node_modules/router/lib/layer.js
generated
vendored
Normal file
175
node_modules/router/lib/layer.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
/*!
|
||||
* router
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var pathRegexp = require('path-to-regexp')
|
||||
var debug = require('debug')('router:layer')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
/**
|
||||
* Expose `Layer`.
|
||||
*/
|
||||
|
||||
module.exports = Layer
|
||||
|
||||
function Layer(path, options, fn) {
|
||||
if (!(this instanceof Layer)) {
|
||||
return new Layer(path, options, fn)
|
||||
}
|
||||
|
||||
debug('new %s', path)
|
||||
var opts = options || {}
|
||||
|
||||
this.handle = fn
|
||||
this.name = fn.name || '<anonymous>'
|
||||
this.params = undefined
|
||||
this.path = undefined
|
||||
this.regexp = pathRegexp(path, this.keys = [], opts)
|
||||
|
||||
if (path === '/' && opts.end === false) {
|
||||
this.regexp.fast_slash = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the error for the layer.
|
||||
*
|
||||
* @param {Error} error
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {function} next
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handle_error = function handle_error(error, req, res, next) {
|
||||
var fn = this.handle
|
||||
|
||||
if (fn.length !== 4) {
|
||||
// not a standard error handler
|
||||
return next(error)
|
||||
}
|
||||
|
||||
try {
|
||||
fn(error, req, res, next)
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the request for the layer.
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {function} next
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handle_request = function handle(req, res, next) {
|
||||
var fn = this.handle
|
||||
|
||||
if (fn.length > 3) {
|
||||
// not a standard request handler
|
||||
return next()
|
||||
}
|
||||
|
||||
try {
|
||||
fn(req, res, next)
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this route matches `path`, if so
|
||||
* populate `.params`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.match = function match(path) {
|
||||
if (path == null) {
|
||||
// no path, nothing matches
|
||||
this.params = undefined
|
||||
this.path = undefined
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.regexp.fast_slash) {
|
||||
// fast path non-ending match for / (everything matches)
|
||||
this.params = {}
|
||||
this.path = ''
|
||||
return true
|
||||
}
|
||||
|
||||
var m = this.regexp.exec(path)
|
||||
|
||||
if (!m) {
|
||||
this.params = undefined
|
||||
this.path = undefined
|
||||
return false
|
||||
}
|
||||
|
||||
// store values
|
||||
this.params = {}
|
||||
this.path = m[0]
|
||||
|
||||
// iterate matches
|
||||
var keys = this.keys
|
||||
var params = this.params
|
||||
|
||||
for (var i = 1; i < m.length; i++) {
|
||||
var key = keys[i - 1]
|
||||
var prop = key.name
|
||||
var val = decode_param(m[i])
|
||||
|
||||
if (val !== undefined || !(hasOwnProperty.call(params, prop))) {
|
||||
params[prop] = val
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode param value.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function decode_param(val){
|
||||
if (typeof val !== 'string' || val.length === 0) {
|
||||
return val
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURIComponent(val)
|
||||
} catch (err) {
|
||||
if (err instanceof URIError) {
|
||||
err.message = 'Failed to decode param \'' + val + '\''
|
||||
err.status = 400
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
}
|
||||
221
node_modules/router/lib/route.js
generated
vendored
Normal file
221
node_modules/router/lib/route.js
generated
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
/*!
|
||||
* router
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var debug = require('debug')('router:route')
|
||||
var flatten = require('array-flatten')
|
||||
var Layer = require('./layer')
|
||||
var methods = require('methods')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var slice = Array.prototype.slice
|
||||
|
||||
/**
|
||||
* Expose `Route`.
|
||||
*/
|
||||
|
||||
module.exports = Route
|
||||
|
||||
/**
|
||||
* Initialize `Route` with the given `path`,
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function Route(path) {
|
||||
debug('new %s', path)
|
||||
this.path = path
|
||||
this.stack = []
|
||||
|
||||
// route handlers for various http methods
|
||||
this.methods = {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype._handles_method = function _handles_method(method) {
|
||||
if (this.methods._all) {
|
||||
return true
|
||||
}
|
||||
|
||||
// normalize name
|
||||
var name = method.toLowerCase()
|
||||
|
||||
if (name === 'head' && !this.methods['head']) {
|
||||
name = 'get'
|
||||
}
|
||||
|
||||
return Boolean(this.methods[name])
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {array} supported HTTP methods
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype._methods = function _methods() {
|
||||
var methods = Object.keys(this.methods)
|
||||
|
||||
// append automatic head
|
||||
if (this.methods.get && !this.methods.head) {
|
||||
methods.push('head')
|
||||
}
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
// make upper case
|
||||
methods[i] = methods[i].toUpperCase()
|
||||
}
|
||||
|
||||
return methods
|
||||
}
|
||||
|
||||
/**
|
||||
* dispatch req, res into this route
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype.dispatch = function dispatch(req, res, done) {
|
||||
var idx = 0
|
||||
var stack = this.stack
|
||||
if (stack.length === 0) {
|
||||
return done()
|
||||
}
|
||||
|
||||
var method = req.method.toLowerCase()
|
||||
if (method === 'head' && !this.methods['head']) {
|
||||
method = 'get'
|
||||
}
|
||||
|
||||
req.route = this
|
||||
|
||||
next()
|
||||
|
||||
function next(err) {
|
||||
if (err && err === 'route') {
|
||||
return done()
|
||||
}
|
||||
|
||||
// no more matching layers
|
||||
if (idx >= stack.length) {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
var layer
|
||||
var match
|
||||
|
||||
// find next matching layer
|
||||
while (match !== true && idx < stack.length) {
|
||||
layer = stack[idx++]
|
||||
match = !layer.method || layer.method === method
|
||||
}
|
||||
|
||||
// no match
|
||||
if (match !== true) {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
if (err) {
|
||||
layer.handle_error(err, req, res, next)
|
||||
} else {
|
||||
layer.handle_request(req, res, next)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a handler for all HTTP verbs to this route.
|
||||
*
|
||||
* Behaves just like middleware and can respond or call `next`
|
||||
* to continue processing.
|
||||
*
|
||||
* You can use multiple `.all` call to add multiple handlers.
|
||||
*
|
||||
* function check_something(req, res, next){
|
||||
* next()
|
||||
* }
|
||||
*
|
||||
* function validate_user(req, res, next){
|
||||
* next()
|
||||
* }
|
||||
*
|
||||
* route
|
||||
* .all(validate_user)
|
||||
* .all(check_something)
|
||||
* .get(function(req, res, next){
|
||||
* res.send('hello world')
|
||||
* })
|
||||
*
|
||||
* @param {array|function} handler
|
||||
* @return {Route} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Route.prototype.all = function all(handler) {
|
||||
var callbacks = flatten(slice.call(arguments))
|
||||
|
||||
if (callbacks.length === 0) {
|
||||
throw new TypeError('argument handler is required')
|
||||
}
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
var fn = callbacks[i]
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument handler must be a function')
|
||||
}
|
||||
|
||||
var layer = Layer('/', {}, fn)
|
||||
layer.method = undefined
|
||||
|
||||
this.methods._all = true
|
||||
this.stack.push(layer)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
methods.forEach(function (method) {
|
||||
Route.prototype[method] = function (handler) {
|
||||
var callbacks = flatten(slice.call(arguments))
|
||||
|
||||
if (callbacks.length === 0) {
|
||||
throw new TypeError('argument handler is required')
|
||||
}
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
var fn = callbacks[i]
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument handler must be a function')
|
||||
}
|
||||
|
||||
debug('%s %s', method, this.path)
|
||||
|
||||
var layer = Layer('/', {}, fn)
|
||||
layer.method = method
|
||||
|
||||
this.methods[method] = true
|
||||
this.stack.push(layer)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
})
|
||||
21
node_modules/router/node_modules/array-flatten/LICENSE
generated
vendored
Normal file
21
node_modules/router/node_modules/array-flatten/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
50
node_modules/router/node_modules/array-flatten/README.md
generated
vendored
Normal file
50
node_modules/router/node_modules/array-flatten/README.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# Array Flatten
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![NPM downloads][downloads-image]][downloads-url]
|
||||
[![Build status][travis-image]][travis-url]
|
||||
[![Test coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
> Flatten nested arrays.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install array-flatten --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var flatten = require('array-flatten')
|
||||
|
||||
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
|
||||
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
flatten.depth([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
|
||||
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
|
||||
|
||||
(function () {
|
||||
flatten.from(arguments) //=> [1, 2, 3]
|
||||
})(1, [2, 3])
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
* **flatten(array)** Flatten a nested array structure
|
||||
* **flatten.from(arrayish)** Flatten an array-like structure (E.g. arguments)
|
||||
* **flatten.depth(array, depth)** Flatten a nested array structure with a specific depth
|
||||
* **flatten.fromDepth(arrayish, depth)** Flatten an array-like structure with a specific depth
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/array-flatten
|
||||
[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/array-flatten
|
||||
[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
|
||||
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
|
||||
16
node_modules/router/node_modules/array-flatten/array-flatten.d.ts
generated
vendored
Normal file
16
node_modules/router/node_modules/array-flatten/array-flatten.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
declare function flatten <T> (array: flatten.NestedArray<T>): T[];
|
||||
|
||||
declare namespace flatten {
|
||||
export interface NestedArray <T> extends Array<T | NestedArray<T>> {}
|
||||
|
||||
export interface NestedList <T> {
|
||||
[index: number]: T | NestedList<T>;
|
||||
length: number;
|
||||
}
|
||||
|
||||
export function from <T> (array: NestedList<T>): T[];
|
||||
export function depth <T> (array: NestedArray<T>, depth: number): NestedArray<T>;
|
||||
export function depthFrom <T> (array: NestedList<T>, depth: number): NestedArray<T>;
|
||||
}
|
||||
|
||||
export = flatten;
|
||||
108
node_modules/router/node_modules/array-flatten/array-flatten.js
generated
vendored
Normal file
108
node_modules/router/node_modules/array-flatten/array-flatten.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Expose `arrayFlatten`.
|
||||
*/
|
||||
module.exports = flatten
|
||||
module.exports.from = flattenFrom
|
||||
module.exports.depth = flattenDepth
|
||||
module.exports.fromDepth = flattenFromDepth
|
||||
|
||||
/**
|
||||
* Flatten an array.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @return {Array}
|
||||
*/
|
||||
function flatten (array) {
|
||||
if (!Array.isArray(array)) {
|
||||
throw new TypeError('Expected value to be an array')
|
||||
}
|
||||
|
||||
return flattenFrom(array)
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array-like structure.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @return {Array}
|
||||
*/
|
||||
function flattenFrom (array) {
|
||||
return flattenDown(array, [])
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array-like structure with depth.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {number} depth
|
||||
* @return {Array}
|
||||
*/
|
||||
function flattenDepth (array, depth) {
|
||||
if (!Array.isArray(array)) {
|
||||
throw new TypeError('Expected value to be an array')
|
||||
}
|
||||
|
||||
return flattenFromDepth(array, depth)
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array-like structure with depth.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {number} depth
|
||||
* @return {Array}
|
||||
*/
|
||||
function flattenFromDepth (array, depth) {
|
||||
if (typeof depth !== 'number') {
|
||||
throw new TypeError('Expected the depth to be a number')
|
||||
}
|
||||
|
||||
return flattenDownDepth(array, [], depth)
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array indefinitely.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {Array} result
|
||||
* @return {Array}
|
||||
*/
|
||||
function flattenDown (array, result) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var value = array[i]
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
flattenDown(value, result)
|
||||
} else {
|
||||
result.push(value)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array with depth.
|
||||
*
|
||||
* @param {Array} array
|
||||
* @param {Array} result
|
||||
* @param {number} depth
|
||||
* @return {Array}
|
||||
*/
|
||||
function flattenDownDepth (array, result, depth) {
|
||||
depth--
|
||||
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var value = array[i]
|
||||
|
||||
if (depth > -1 && Array.isArray(value)) {
|
||||
flattenDownDepth(value, result, depth)
|
||||
} else {
|
||||
result.push(value)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
47
node_modules/router/node_modules/array-flatten/package.json
generated
vendored
Normal file
47
node_modules/router/node_modules/array-flatten/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "array-flatten",
|
||||
"version": "2.1.1",
|
||||
"description": "Flatten nested arrays",
|
||||
"main": "array-flatten.js",
|
||||
"typings": "array-flatten.d.ts",
|
||||
"files": [
|
||||
"array-flatten.js",
|
||||
"array-flatten.d.ts",
|
||||
"LICENSE"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test-spec": "mocha -R spec --bail",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- -R spec --bail",
|
||||
"test": "npm run lint && npm run test-cov",
|
||||
"benchmark": "node benchmark"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/blakeembrey/array-flatten.git"
|
||||
},
|
||||
"keywords": [
|
||||
"array",
|
||||
"flatten",
|
||||
"arguments",
|
||||
"depth",
|
||||
"fast",
|
||||
"for"
|
||||
],
|
||||
"author": {
|
||||
"name": "Blake Embrey",
|
||||
"email": "hello@blakeembrey.com",
|
||||
"url": "http://blakeembrey.me"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/blakeembrey/array-flatten/issues"
|
||||
},
|
||||
"homepage": "https://github.com/blakeembrey/array-flatten",
|
||||
"devDependencies": {
|
||||
"benchmarked": "^0.2.5",
|
||||
"istanbul": "^0.4.0",
|
||||
"mocha": "^3.1.2",
|
||||
"standard": "^8.5.0"
|
||||
}
|
||||
}
|
||||
3
node_modules/router/node_modules/debug/.jshintrc
generated
vendored
Normal file
3
node_modules/router/node_modules/debug/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"laxbreak": true
|
||||
}
|
||||
6
node_modules/router/node_modules/debug/.npmignore
generated
vendored
Normal file
6
node_modules/router/node_modules/debug/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
support
|
||||
test
|
||||
examples
|
||||
example
|
||||
*.sock
|
||||
dist
|
||||
195
node_modules/router/node_modules/debug/History.md
generated
vendored
Normal file
195
node_modules/router/node_modules/debug/History.md
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
|
||||
2.2.0 / 2015-05-09
|
||||
==================
|
||||
|
||||
* package: update "ms" to v0.7.1 (#202, @dougwilson)
|
||||
* README: add logging to file example (#193, @DanielOchoa)
|
||||
* README: fixed a typo (#191, @amir-s)
|
||||
* browser: expose `storage` (#190, @stephenmathieson)
|
||||
* Makefile: add a `distclean` target (#189, @stephenmathieson)
|
||||
|
||||
2.1.3 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Updated stdout/stderr example (#186)
|
||||
* Updated example/stdout.js to match debug current behaviour
|
||||
* Renamed example/stderr.js to stdout.js
|
||||
* Update Readme.md (#184)
|
||||
* replace high intensity foreground color for bold (#182, #183)
|
||||
|
||||
2.1.2 / 2015-03-01
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* update "ms" to v0.7.0
|
||||
* package: update "browserify" to v9.0.3
|
||||
* component: fix "ms.js" repo location
|
||||
* changed bower package name
|
||||
* updated documentation about using debug in a browser
|
||||
* fix: security error on safari (#167, #168, @yields)
|
||||
|
||||
2.1.1 / 2014-12-29
|
||||
==================
|
||||
|
||||
* browser: use `typeof` to check for `console` existence
|
||||
* browser: check for `console.log` truthiness (fix IE 8/9)
|
||||
* browser: add support for Chrome apps
|
||||
* Readme: added Windows usage remarks
|
||||
* Add `bower.json` to properly support bower install
|
||||
|
||||
2.1.0 / 2014-10-15
|
||||
==================
|
||||
|
||||
* node: implement `DEBUG_FD` env variable support
|
||||
* package: update "browserify" to v6.1.0
|
||||
* package: add "license" field to package.json (#135, @panuhorsmalahti)
|
||||
|
||||
2.0.0 / 2014-09-01
|
||||
==================
|
||||
|
||||
* package: update "browserify" to v5.11.0
|
||||
* node: use stderr rather than stdout for logging (#29, @stephenmathieson)
|
||||
|
||||
1.0.4 / 2014-07-15
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* example: remove `console.info()` log usage
|
||||
* example: add "Content-Type" UTF-8 header to browser example
|
||||
* browser: place %c marker after the space character
|
||||
* browser: reset the "content" color via `color: inherit`
|
||||
* browser: add colors support for Firefox >= v31
|
||||
* debug: prefer an instance `log()` function over the global one (#119)
|
||||
* Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
|
||||
|
||||
1.0.3 / 2014-07-09
|
||||
==================
|
||||
|
||||
* Add support for multiple wildcards in namespaces (#122, @seegno)
|
||||
* browser: fix lint
|
||||
|
||||
1.0.2 / 2014-06-10
|
||||
==================
|
||||
|
||||
* browser: update color palette (#113, @gscottolson)
|
||||
* common: make console logging function configurable (#108, @timoxley)
|
||||
* node: fix %o colors on old node <= 0.8.x
|
||||
* Makefile: find node path using shell/which (#109, @timoxley)
|
||||
|
||||
1.0.1 / 2014-06-06
|
||||
==================
|
||||
|
||||
* browser: use `removeItem()` to clear localStorage
|
||||
* browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
|
||||
* package: add "contributors" section
|
||||
* node: fix comment typo
|
||||
* README: list authors
|
||||
|
||||
1.0.0 / 2014-06-04
|
||||
==================
|
||||
|
||||
* make ms diff be global, not be scope
|
||||
* debug: ignore empty strings in enable()
|
||||
* node: make DEBUG_COLORS able to disable coloring
|
||||
* *: export the `colors` array
|
||||
* npmignore: don't publish the `dist` dir
|
||||
* Makefile: refactor to use browserify
|
||||
* package: add "browserify" as a dev dependency
|
||||
* Readme: add Web Inspector Colors section
|
||||
* node: reset terminal color for the debug content
|
||||
* node: map "%o" to `util.inspect()`
|
||||
* browser: map "%j" to `JSON.stringify()`
|
||||
* debug: add custom "formatters"
|
||||
* debug: use "ms" module for humanizing the diff
|
||||
* Readme: add "bash" syntax highlighting
|
||||
* browser: add Firebug color support
|
||||
* browser: add colors for WebKit browsers
|
||||
* node: apply log to `console`
|
||||
* rewrite: abstract common logic for Node & browsers
|
||||
* add .jshintrc file
|
||||
|
||||
0.8.1 / 2014-04-14
|
||||
==================
|
||||
|
||||
* package: re-add the "component" section
|
||||
|
||||
0.8.0 / 2014-03-30
|
||||
==================
|
||||
|
||||
* add `enable()` method for nodejs. Closes #27
|
||||
* change from stderr to stdout
|
||||
* remove unnecessary index.js file
|
||||
|
||||
0.7.4 / 2013-11-13
|
||||
==================
|
||||
|
||||
* remove "browserify" key from package.json (fixes something in browserify)
|
||||
|
||||
0.7.3 / 2013-10-30
|
||||
==================
|
||||
|
||||
* fix: catch localStorage security error when cookies are blocked (Chrome)
|
||||
* add debug(err) support. Closes #46
|
||||
* add .browser prop to package.json. Closes #42
|
||||
|
||||
0.7.2 / 2013-02-06
|
||||
==================
|
||||
|
||||
* fix package.json
|
||||
* fix: Mobile Safari (private mode) is broken with debug
|
||||
* fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
|
||||
|
||||
0.7.1 / 2013-02-05
|
||||
==================
|
||||
|
||||
* add repository URL to package.json
|
||||
* add DEBUG_COLORED to force colored output
|
||||
* add browserify support
|
||||
* fix component. Closes #24
|
||||
|
||||
0.7.0 / 2012-05-04
|
||||
==================
|
||||
|
||||
* Added .component to package.json
|
||||
* Added debug.component.js build
|
||||
|
||||
0.6.0 / 2012-03-16
|
||||
==================
|
||||
|
||||
* Added support for "-" prefix in DEBUG [Vinay Pulim]
|
||||
* Added `.enabled` flag to the node version [TooTallNate]
|
||||
|
||||
0.5.0 / 2012-02-02
|
||||
==================
|
||||
|
||||
* Added: humanize diffs. Closes #8
|
||||
* Added `debug.disable()` to the CS variant
|
||||
* Removed padding. Closes #10
|
||||
* Fixed: persist client-side variant again. Closes #9
|
||||
|
||||
0.4.0 / 2012-02-01
|
||||
==================
|
||||
|
||||
* Added browser variant support for older browsers [TooTallNate]
|
||||
* Added `debug.enable('project:*')` to browser variant [TooTallNate]
|
||||
* Added padding to diff (moved it to the right)
|
||||
|
||||
0.3.0 / 2012-01-26
|
||||
==================
|
||||
|
||||
* Added millisecond diff when isatty, otherwise UTC string
|
||||
|
||||
0.2.0 / 2012-01-22
|
||||
==================
|
||||
|
||||
* Added wildcard support
|
||||
|
||||
0.1.0 / 2011-12-02
|
||||
==================
|
||||
|
||||
* Added: remove colors unless stderr isatty [TooTallNate]
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
36
node_modules/router/node_modules/debug/Makefile
generated
vendored
Normal file
36
node_modules/router/node_modules/debug/Makefile
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
|
||||
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
|
||||
|
||||
# BIN directory
|
||||
BIN := $(THIS_DIR)/node_modules/.bin
|
||||
|
||||
# applications
|
||||
NODE ?= $(shell which node)
|
||||
NPM ?= $(NODE) $(shell which npm)
|
||||
BROWSERIFY ?= $(NODE) $(BIN)/browserify
|
||||
|
||||
all: dist/debug.js
|
||||
|
||||
install: node_modules
|
||||
|
||||
clean:
|
||||
@rm -rf dist
|
||||
|
||||
dist:
|
||||
@mkdir -p $@
|
||||
|
||||
dist/debug.js: node_modules browser.js debug.js dist
|
||||
@$(BROWSERIFY) \
|
||||
--standalone debug \
|
||||
. > $@
|
||||
|
||||
distclean: clean
|
||||
@rm -rf node_modules
|
||||
|
||||
node_modules: package.json
|
||||
@NODE_ENV= $(NPM) install
|
||||
@touch node_modules
|
||||
|
||||
.PHONY: all install clean distclean
|
||||
188
node_modules/router/node_modules/debug/Readme.md
generated
vendored
Normal file
188
node_modules/router/node_modules/debug/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
# debug
|
||||
|
||||
tiny node.js debugging utility modelled after node core's debugging technique.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
|
||||
|
||||
Example _app.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %s', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example _worker.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('worker');
|
||||
|
||||
setInterval(function(){
|
||||
debug('doing some work');
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
#### Windows note
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||

|
||||
|
||||
When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||

|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:".
|
||||
|
||||
## Browser support
|
||||
|
||||
Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include:
|
||||
|
||||
```js
|
||||
window.myDebug = require("debug");
|
||||
```
|
||||
|
||||
("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console:
|
||||
|
||||
```js
|
||||
myDebug.enable("worker:*")
|
||||
```
|
||||
|
||||
Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
#### Web Inspector Colors
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
Colored output looks something like:
|
||||
|
||||

|
||||
|
||||
### stderr vs stdout
|
||||
|
||||
You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally:
|
||||
|
||||
Example _stdout.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
### Save debug output to a file
|
||||
|
||||
You can save all debug statements to a file by piping them.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
$ DEBUG_FD=3 node your-app.js 3> whatever.log
|
||||
```
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
28
node_modules/router/node_modules/debug/bower.json
generated
vendored
Normal file
28
node_modules/router/node_modules/debug/bower.json
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "visionmedia-debug",
|
||||
"main": "dist/debug.js",
|
||||
"version": "2.2.0",
|
||||
"homepage": "https://github.com/visionmedia/debug",
|
||||
"authors": [
|
||||
"TJ Holowaychuk <tj@vision-media.ca>"
|
||||
],
|
||||
"description": "visionmedia-debug",
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"es6",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"visionmedia",
|
||||
"debug"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
168
node_modules/router/node_modules/debug/browser.js
generated
vendored
Normal file
168
node_modules/router/node_modules/debug/browser.js
generated
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = require('./debug');
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = 'undefined' != typeof chrome
|
||||
&& 'undefined' != typeof chrome.storage
|
||||
? chrome.storage.local
|
||||
: localstorage();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'lightseagreen',
|
||||
'forestgreen',
|
||||
'goldenrod',
|
||||
'dodgerblue',
|
||||
'darkorchid',
|
||||
'crimson'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
// is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
return ('WebkitAppearance' in document.documentElement.style) ||
|
||||
// is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(window.console && (console.firebug || (console.exception && console.table))) ||
|
||||
// is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
exports.formatters.j = function(v) {
|
||||
return JSON.stringify(v);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs() {
|
||||
var args = arguments;
|
||||
var useColors = this.useColors;
|
||||
|
||||
args[0] = (useColors ? '%c' : '')
|
||||
+ this.namespace
|
||||
+ (useColors ? ' %c' : ' ')
|
||||
+ args[0]
|
||||
+ (useColors ? '%c ' : ' ')
|
||||
+ '+' + exports.humanize(this.diff);
|
||||
|
||||
if (!useColors) return args;
|
||||
|
||||
var c = 'color: ' + this.color;
|
||||
args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
|
||||
|
||||
// the final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
var index = 0;
|
||||
var lastC = 0;
|
||||
args[0].replace(/%[a-z%]/g, function(match) {
|
||||
if ('%%' === match) return;
|
||||
index++;
|
||||
if ('%c' === match) {
|
||||
// we only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.log()` when available.
|
||||
* No-op when `console.log` is not a "function".
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function log() {
|
||||
// this hackery is required for IE8/9, where
|
||||
// the `console.log` function doesn't have 'apply'
|
||||
return 'object' === typeof console
|
||||
&& console.log
|
||||
&& Function.prototype.apply.call(console.log, console, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (null == namespaces) {
|
||||
exports.storage.removeItem('debug');
|
||||
} else {
|
||||
exports.storage.debug = namespaces;
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
var r;
|
||||
try {
|
||||
r = exports.storage.debug;
|
||||
} catch(e) {}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `localStorage.debug` initially.
|
||||
*/
|
||||
|
||||
exports.enable(load());
|
||||
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function localstorage(){
|
||||
try {
|
||||
return window.localStorage;
|
||||
} catch (e) {}
|
||||
}
|
||||
19
node_modules/router/node_modules/debug/component.json
generated
vendored
Normal file
19
node_modules/router/node_modules/debug/component.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"repo": "visionmedia/debug",
|
||||
"description": "small debugging utility",
|
||||
"version": "2.2.0",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"main": "browser.js",
|
||||
"scripts": [
|
||||
"browser.js",
|
||||
"debug.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"rauchg/ms.js": "0.7.1"
|
||||
}
|
||||
}
|
||||
197
node_modules/router/node_modules/debug/debug.js
generated
vendored
Normal file
197
node_modules/router/node_modules/debug/debug.js
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = debug;
|
||||
exports.coerce = coerce;
|
||||
exports.disable = disable;
|
||||
exports.enable = enable;
|
||||
exports.enabled = enabled;
|
||||
exports.humanize = require('ms');
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
exports.names = [];
|
||||
exports.skips = [];
|
||||
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lowercased letter, i.e. "n".
|
||||
*/
|
||||
|
||||
exports.formatters = {};
|
||||
|
||||
/**
|
||||
* Previously assigned color.
|
||||
*/
|
||||
|
||||
var prevColor = 0;
|
||||
|
||||
/**
|
||||
* Previous log timestamp.
|
||||
*/
|
||||
|
||||
var prevTime;
|
||||
|
||||
/**
|
||||
* Select a color.
|
||||
*
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function selectColor() {
|
||||
return exports.colors[prevColor++ % exports.colors.length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function debug(namespace) {
|
||||
|
||||
// define the `disabled` version
|
||||
function disabled() {
|
||||
}
|
||||
disabled.enabled = false;
|
||||
|
||||
// define the `enabled` version
|
||||
function enabled() {
|
||||
|
||||
var self = enabled;
|
||||
|
||||
// set `diff` timestamp
|
||||
var curr = +new Date();
|
||||
var ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
|
||||
// add the `color` if not set
|
||||
if (null == self.useColors) self.useColors = exports.useColors();
|
||||
if (null == self.color && self.useColors) self.color = selectColor();
|
||||
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
args[0] = exports.coerce(args[0]);
|
||||
|
||||
if ('string' !== typeof args[0]) {
|
||||
// anything else let's inspect with %o
|
||||
args = ['%o'].concat(args);
|
||||
}
|
||||
|
||||
// apply any `formatters` transformations
|
||||
var index = 0;
|
||||
args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
|
||||
// if we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') return match;
|
||||
index++;
|
||||
var formatter = exports.formatters[format];
|
||||
if ('function' === typeof formatter) {
|
||||
var val = args[index];
|
||||
match = formatter.call(self, val);
|
||||
|
||||
// now we need to remove `args[index]` since it's inlined in the `format`
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
if ('function' === typeof exports.formatArgs) {
|
||||
args = exports.formatArgs.apply(self, args);
|
||||
}
|
||||
var logFn = enabled.log || exports.log || console.log.bind(console);
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
enabled.enabled = true;
|
||||
|
||||
var fn = exports.enabled(namespace) ? enabled : disabled;
|
||||
|
||||
fn.namespace = namespace;
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function enable(namespaces) {
|
||||
exports.save(namespaces);
|
||||
|
||||
var split = (namespaces || '').split(/[\s,]+/);
|
||||
var len = split.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (!split[i]) continue; // ignore empty strings
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
if (namespaces[0] === '-') {
|
||||
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
exports.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function disable() {
|
||||
exports.enable('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function enabled(name) {
|
||||
var i, len;
|
||||
for (i = 0, len = exports.skips.length; i < len; i++) {
|
||||
if (exports.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (i = 0, len = exports.names.length; i < len; i++) {
|
||||
if (exports.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) return val.stack || val.message;
|
||||
return val;
|
||||
}
|
||||
209
node_modules/router/node_modules/debug/node.js
generated
vendored
Normal file
209
node_modules/router/node_modules/debug/node.js
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var tty = require('tty');
|
||||
var util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = require('./debug');
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
/**
|
||||
* The file descriptor to write the `debug()` calls to.
|
||||
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
||||
*
|
||||
* $ DEBUG_FD=3 node script.js 3>debug.log
|
||||
*/
|
||||
|
||||
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
||||
var stream = 1 === fd ? process.stdout :
|
||||
2 === fd ? process.stderr :
|
||||
createWritableStdioStream(fd);
|
||||
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
|
||||
if (0 === debugColors.length) {
|
||||
return tty.isatty(fd);
|
||||
} else {
|
||||
return '0' !== debugColors
|
||||
&& 'no' !== debugColors
|
||||
&& 'false' !== debugColors
|
||||
&& 'disabled' !== debugColors;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, since Node doesn't do that out of the box.
|
||||
*/
|
||||
|
||||
var inspect = (4 === util.inspect.length ?
|
||||
// node <= 0.8.x
|
||||
function (v, colors) {
|
||||
return util.inspect(v, void 0, void 0, colors);
|
||||
} :
|
||||
// node > 0.8.x
|
||||
function (v, colors) {
|
||||
return util.inspect(v, { colors: colors });
|
||||
}
|
||||
);
|
||||
|
||||
exports.formatters.o = function(v) {
|
||||
return inspect(v, this.useColors)
|
||||
.replace(/\s*\n\s*/g, ' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs() {
|
||||
var args = arguments;
|
||||
var useColors = this.useColors;
|
||||
var name = this.namespace;
|
||||
|
||||
if (useColors) {
|
||||
var c = this.color;
|
||||
|
||||
args[0] = ' \u001b[3' + c + ';1m' + name + ' '
|
||||
+ '\u001b[0m'
|
||||
+ args[0] + '\u001b[3' + c + 'm'
|
||||
+ ' +' + exports.humanize(this.diff) + '\u001b[0m';
|
||||
} else {
|
||||
args[0] = new Date().toUTCString()
|
||||
+ ' ' + name + ' ' + args[0];
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.error()` with the specified arguments.
|
||||
*/
|
||||
|
||||
function log() {
|
||||
return stream.write(util.format.apply(this, arguments) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function save(namespaces) {
|
||||
if (null == namespaces) {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
} else {
|
||||
process.env.DEBUG = namespaces;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from `node/src/node.js`.
|
||||
*
|
||||
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
||||
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
||||
*/
|
||||
|
||||
function createWritableStdioStream (fd) {
|
||||
var stream;
|
||||
var tty_wrap = process.binding('tty_wrap');
|
||||
|
||||
// Note stream._type is used for test-module-load-list.js
|
||||
|
||||
switch (tty_wrap.guessHandleType(fd)) {
|
||||
case 'TTY':
|
||||
stream = new tty.WriteStream(fd);
|
||||
stream._type = 'tty';
|
||||
|
||||
// Hack to have stream not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
if (stream._handle && stream._handle.unref) {
|
||||
stream._handle.unref();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'FILE':
|
||||
var fs = require('fs');
|
||||
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
||||
stream._type = 'fs';
|
||||
break;
|
||||
|
||||
case 'PIPE':
|
||||
case 'TCP':
|
||||
var net = require('net');
|
||||
stream = new net.Socket({
|
||||
fd: fd,
|
||||
readable: false,
|
||||
writable: true
|
||||
});
|
||||
|
||||
// FIXME Should probably have an option in net.Socket to create a
|
||||
// stream from an existing fd which is writable only. But for now
|
||||
// we'll just add this hack and set the `readable` member to false.
|
||||
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
||||
stream.readable = false;
|
||||
stream.read = null;
|
||||
stream._type = 'pipe';
|
||||
|
||||
// FIXME Hack to have stream not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
if (stream._handle && stream._handle.unref) {
|
||||
stream._handle.unref();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Probably an error on in uv_guess_handle()
|
||||
throw new Error('Implement me. Unknown stream file type!');
|
||||
}
|
||||
|
||||
// For supporting legacy API we put the FD here.
|
||||
stream.fd = fd;
|
||||
|
||||
stream._isStdio = true;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `process.env.DEBUG` initially.
|
||||
*/
|
||||
|
||||
exports.enable(load());
|
||||
34
node_modules/router/node_modules/debug/package.json
generated
vendored
Normal file
34
node_modules/router/node_modules/debug/package.json
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"version": "2.2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/debug.git"
|
||||
},
|
||||
"description": "small debugging utility",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"contributors": [
|
||||
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "0.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "9.0.3",
|
||||
"mocha": "*"
|
||||
},
|
||||
"main": "./node.js",
|
||||
"browser": "./browser.js",
|
||||
"component": {
|
||||
"scripts": {
|
||||
"debug/index.js": "browser.js",
|
||||
"debug/debug.js": "debug.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
5
node_modules/router/node_modules/ms/.npmignore
generated
vendored
Normal file
5
node_modules/router/node_modules/ms/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
test
|
||||
History.md
|
||||
Makefile
|
||||
component.json
|
||||
66
node_modules/router/node_modules/ms/History.md
generated
vendored
Normal file
66
node_modules/router/node_modules/ms/History.md
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
0.7.1 / 2015-04-20
|
||||
==================
|
||||
|
||||
* prevent extraordinary long inputs (@evilpacket)
|
||||
* Fixed broken readme link
|
||||
|
||||
0.7.0 / 2014-11-24
|
||||
==================
|
||||
|
||||
* add time abbreviations, updated tests and readme for the new units
|
||||
* fix example in the readme.
|
||||
* add LICENSE file
|
||||
|
||||
0.6.2 / 2013-12-05
|
||||
==================
|
||||
|
||||
* Adding repository section to package.json to suppress warning from NPM.
|
||||
|
||||
0.6.1 / 2013-05-10
|
||||
==================
|
||||
|
||||
* fix singularization [visionmedia]
|
||||
|
||||
0.6.0 / 2013-03-15
|
||||
==================
|
||||
|
||||
* fix minutes
|
||||
|
||||
0.5.1 / 2013-02-24
|
||||
==================
|
||||
|
||||
* add component namespace
|
||||
|
||||
0.5.0 / 2012-11-09
|
||||
==================
|
||||
|
||||
* add short formatting as default and .long option
|
||||
* add .license property to component.json
|
||||
* add version to component.json
|
||||
|
||||
0.4.0 / 2012-10-22
|
||||
==================
|
||||
|
||||
* add rounding to fix crazy decimals
|
||||
|
||||
0.3.0 / 2012-09-07
|
||||
==================
|
||||
|
||||
* fix `ms(<String>)` [visionmedia]
|
||||
|
||||
0.2.0 / 2012-09-03
|
||||
==================
|
||||
|
||||
* add component.json [visionmedia]
|
||||
* add days support [visionmedia]
|
||||
* add hours support [visionmedia]
|
||||
* add minutes support [visionmedia]
|
||||
* add seconds support [visionmedia]
|
||||
* add ms string support [visionmedia]
|
||||
* refactor tests to facilitate ms(number) [visionmedia]
|
||||
|
||||
0.1.0 / 2012-03-07
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
20
node_modules/router/node_modules/ms/LICENSE
generated
vendored
Normal file
20
node_modules/router/node_modules/ms/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Guillermo Rauch <rauchg@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
35
node_modules/router/node_modules/ms/README.md
generated
vendored
Normal file
35
node_modules/router/node_modules/ms/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# ms.js: miliseconds conversion utility
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('100') // 100
|
||||
```
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download).
|
||||
- If a number is supplied to `ms`, a string with a unit is returned.
|
||||
- If a string that contains the number is supplied, it returns it as
|
||||
a number (e.g: it returns `100` for `'100'`).
|
||||
- If you pass a string with a number and a valid unit, the number of
|
||||
equivalent ms is returned.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
125
node_modules/router/node_modules/ms/index.js
generated
vendored
Normal file
125
node_modules/router/node_modules/ms/index.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} options
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options){
|
||||
options = options || {};
|
||||
if ('string' == typeof val) return parse(val);
|
||||
return options.long
|
||||
? long(val)
|
||||
: short(val);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = '' + str;
|
||||
if (str.length > 10000) return;
|
||||
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
|
||||
if (!match) return;
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function short(ms) {
|
||||
if (ms >= d) return Math.round(ms / d) + 'd';
|
||||
if (ms >= h) return Math.round(ms / h) + 'h';
|
||||
if (ms >= m) return Math.round(ms / m) + 'm';
|
||||
if (ms >= s) return Math.round(ms / s) + 's';
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function long(ms) {
|
||||
return plural(ms, d, 'day')
|
||||
|| plural(ms, h, 'hour')
|
||||
|| plural(ms, m, 'minute')
|
||||
|| plural(ms, s, 'second')
|
||||
|| ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, n, name) {
|
||||
if (ms < n) return;
|
||||
if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
|
||||
return Math.ceil(ms / n) + ' ' + name + 's';
|
||||
}
|
||||
20
node_modules/router/node_modules/ms/package.json
generated
vendored
Normal file
20
node_modules/router/node_modules/ms/package.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "ms",
|
||||
"version": "0.7.1",
|
||||
"description": "Tiny ms conversion utility",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/guille/ms.js.git"
|
||||
},
|
||||
"main": "./index",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"expect.js": "*",
|
||||
"serve": "*"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"ms/index.js": "index.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
36
node_modules/router/node_modules/path-to-regexp/History.md
generated
vendored
Normal file
36
node_modules/router/node_modules/path-to-regexp/History.md
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
0.1.7 / 2015-07-28
|
||||
==================
|
||||
|
||||
* Fixed regression with escaped round brackets and matching groups.
|
||||
|
||||
0.1.6 / 2015-06-19
|
||||
==================
|
||||
|
||||
* Replace `index` feature by outputting all parameters, unnamed and named.
|
||||
|
||||
0.1.5 / 2015-05-08
|
||||
==================
|
||||
|
||||
* Add an index property for position in match result.
|
||||
|
||||
0.1.4 / 2015-03-05
|
||||
==================
|
||||
|
||||
* Add license information
|
||||
|
||||
0.1.3 / 2014-07-06
|
||||
==================
|
||||
|
||||
* Better array support
|
||||
* Improved support for trailing slash in non-ending mode
|
||||
|
||||
0.1.0 / 2014-03-06
|
||||
==================
|
||||
|
||||
* add options.end
|
||||
|
||||
0.0.2 / 2013-02-10
|
||||
==================
|
||||
|
||||
* Update to match current express
|
||||
* add .license property to component.json
|
||||
21
node_modules/router/node_modules/path-to-regexp/LICENSE
generated
vendored
Normal file
21
node_modules/router/node_modules/path-to-regexp/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
35
node_modules/router/node_modules/path-to-regexp/Readme.md
generated
vendored
Normal file
35
node_modules/router/node_modules/path-to-regexp/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# Path-to-RegExp
|
||||
|
||||
Turn an Express-style path string such as `/user/:name` into a regular expression.
|
||||
|
||||
**Note:** This is a legacy branch. You should upgrade to `1.x`.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var pathToRegexp = require('path-to-regexp');
|
||||
```
|
||||
|
||||
### pathToRegexp(path, keys, options)
|
||||
|
||||
- **path** A string in the express format, an array of such strings, or a regular expression
|
||||
- **keys** An array to be populated with the keys present in the url. Once the function completes, this will be an array of strings.
|
||||
- **options**
|
||||
- **options.sensitive** Defaults to false, set this to true to make routes case sensitive
|
||||
- **options.strict** Defaults to false, set this to true to make the trailing slash matter.
|
||||
- **options.end** Defaults to true, set this to false to only match the prefix of the URL.
|
||||
|
||||
```javascript
|
||||
var keys = [];
|
||||
var exp = pathToRegexp('/foo/:bar', keys);
|
||||
//keys = ['bar']
|
||||
//exp = /^\/foo\/(?:([^\/]+?))\/?$/i
|
||||
```
|
||||
|
||||
## Live Demo
|
||||
|
||||
You can see a live demo of this library in use at [express-route-tester](http://forbeslindesay.github.com/express-route-tester/).
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
129
node_modules/router/node_modules/path-to-regexp/index.js
generated
vendored
Normal file
129
node_modules/router/node_modules/path-to-regexp/index.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* Expose `pathtoRegexp`.
|
||||
*/
|
||||
|
||||
module.exports = pathtoRegexp;
|
||||
|
||||
/**
|
||||
* Match matching groups in a regular expression.
|
||||
*/
|
||||
var MATCHING_GROUP_REGEXP = /\((?!\?)/g;
|
||||
|
||||
/**
|
||||
* Normalize the given path string,
|
||||
* returning a regular expression.
|
||||
*
|
||||
* An empty array should be passed,
|
||||
* which will contain the placeholder
|
||||
* key names. For example "/user/:id" will
|
||||
* then contain ["id"].
|
||||
*
|
||||
* @param {String|RegExp|Array} path
|
||||
* @param {Array} keys
|
||||
* @param {Object} options
|
||||
* @return {RegExp}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function pathtoRegexp(path, keys, options) {
|
||||
options = options || {};
|
||||
keys = keys || [];
|
||||
var strict = options.strict;
|
||||
var end = options.end !== false;
|
||||
var flags = options.sensitive ? '' : 'i';
|
||||
var extraOffset = 0;
|
||||
var keysOffset = keys.length;
|
||||
var i = 0;
|
||||
var name = 0;
|
||||
var m;
|
||||
|
||||
if (path instanceof RegExp) {
|
||||
while (m = MATCHING_GROUP_REGEXP.exec(path.source)) {
|
||||
keys.push({
|
||||
name: name++,
|
||||
optional: false,
|
||||
offset: m.index
|
||||
});
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
if (Array.isArray(path)) {
|
||||
// Map array parts into regexps and return their source. We also pass
|
||||
// the same keys and options instance into every generation to get
|
||||
// consistent matching groups before we join the sources together.
|
||||
path = path.map(function (value) {
|
||||
return pathtoRegexp(value, keys, options).source;
|
||||
});
|
||||
|
||||
return new RegExp('(?:' + path.join('|') + ')', flags);
|
||||
}
|
||||
|
||||
path = ('^' + path + (strict ? '' : path[path.length - 1] === '/' ? '?' : '/?'))
|
||||
.replace(/\/\(/g, '/(?:')
|
||||
.replace(/([\/\.])/g, '\\$1')
|
||||
.replace(/(\\\/)?(\\\.)?:(\w+)(\(.*?\))?(\*)?(\?)?/g, function (match, slash, format, key, capture, star, optional, offset) {
|
||||
slash = slash || '';
|
||||
format = format || '';
|
||||
capture = capture || '([^\\/' + format + ']+?)';
|
||||
optional = optional || '';
|
||||
|
||||
keys.push({
|
||||
name: key,
|
||||
optional: !!optional,
|
||||
offset: offset + extraOffset
|
||||
});
|
||||
|
||||
var result = ''
|
||||
+ (optional ? '' : slash)
|
||||
+ '(?:'
|
||||
+ format + (optional ? slash : '') + capture
|
||||
+ (star ? '((?:[\\/' + format + '].+?)?)' : '')
|
||||
+ ')'
|
||||
+ optional;
|
||||
|
||||
extraOffset += result.length - match.length;
|
||||
|
||||
return result;
|
||||
})
|
||||
.replace(/\*/g, function (star, index) {
|
||||
var len = keys.length
|
||||
|
||||
while (len-- > keysOffset && keys[len].offset > index) {
|
||||
keys[len].offset += 3; // Replacement length minus asterisk length.
|
||||
}
|
||||
|
||||
return '(.*)';
|
||||
});
|
||||
|
||||
// This is a workaround for handling unnamed matching groups.
|
||||
while (m = MATCHING_GROUP_REGEXP.exec(path)) {
|
||||
var escapeCount = 0;
|
||||
var index = m.index;
|
||||
|
||||
while (path.charAt(--index) === '\\') {
|
||||
escapeCount++;
|
||||
}
|
||||
|
||||
// It's possible to escape the bracket.
|
||||
if (escapeCount % 2 === 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
|
||||
keys.splice(keysOffset + i, 0, {
|
||||
name: name++, // Unnamed matching groups must be consistently linear.
|
||||
optional: false,
|
||||
offset: m.index
|
||||
});
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
// If the path is non-ending, match until the end or a slash.
|
||||
path += (end ? '$' : (path[path.length - 1] === '/' ? '' : '(?=\\/|$)'));
|
||||
|
||||
return new RegExp(path, flags);
|
||||
};
|
||||
30
node_modules/router/node_modules/path-to-regexp/package.json
generated
vendored
Normal file
30
node_modules/router/node_modules/path-to-regexp/package.json
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "path-to-regexp",
|
||||
"description": "Express style path to RegExp utility",
|
||||
"version": "0.1.7",
|
||||
"files": [
|
||||
"index.js",
|
||||
"LICENSE"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "istanbul cover _mocha -- -R spec"
|
||||
},
|
||||
"keywords": [
|
||||
"express",
|
||||
"regexp"
|
||||
],
|
||||
"component": {
|
||||
"scripts": {
|
||||
"path-to-regexp": "index.js"
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/component/path-to-regexp.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^1.17.1",
|
||||
"istanbul": "^0.2.6"
|
||||
}
|
||||
}
|
||||
13
node_modules/router/node_modules/setprototypeof/LICENSE
generated
vendored
Normal file
13
node_modules/router/node_modules/setprototypeof/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright (c) 2015, Wes Todd
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
21
node_modules/router/node_modules/setprototypeof/README.md
generated
vendored
Normal file
21
node_modules/router/node_modules/setprototypeof/README.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Polyfill for `Object.setPrototypeOf`
|
||||
|
||||
A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
|
||||
|
||||
## Usage:
|
||||
|
||||
```
|
||||
$ npm install --save setprototypeof
|
||||
```
|
||||
|
||||
```javascript
|
||||
var setPrototypeOf = require('setprototypeof');
|
||||
|
||||
var obj = {};
|
||||
setPrototypeOf(obj, {
|
||||
foo: function() {
|
||||
return 'bar';
|
||||
}
|
||||
});
|
||||
obj.foo(); // bar
|
||||
```
|
||||
13
node_modules/router/node_modules/setprototypeof/index.js
generated
vendored
Normal file
13
node_modules/router/node_modules/setprototypeof/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = Object.setPrototypeOf || ({__proto__:[]} instanceof Array ? setProtoOf : mixinProperties);
|
||||
|
||||
function setProtoOf(obj, proto) {
|
||||
obj.__proto__ = proto;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function mixinProperties(obj, proto) {
|
||||
for (var prop in proto) {
|
||||
obj[prop] = proto[prop];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
24
node_modules/router/node_modules/setprototypeof/package.json
generated
vendored
Normal file
24
node_modules/router/node_modules/setprototypeof/package.json
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "setprototypeof",
|
||||
"version": "1.0.2",
|
||||
"description": "A small polyfill for Object.setprototypeof",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/wesleytodd/setprototypeof.git"
|
||||
},
|
||||
"keywords": [
|
||||
"polyfill",
|
||||
"object",
|
||||
"setprototypeof"
|
||||
],
|
||||
"author": "Wes Todd",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/wesleytodd/setprototypeof/issues"
|
||||
},
|
||||
"homepage": "https://github.com/wesleytodd/setprototypeof"
|
||||
}
|
||||
39
node_modules/router/package.json
generated
vendored
Normal file
39
node_modules/router/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "router",
|
||||
"description": "Simple middleware-style router",
|
||||
"version": "1.1.5",
|
||||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"license": "MIT",
|
||||
"repository": "pillarjs/router",
|
||||
"dependencies": {
|
||||
"array-flatten": "2.1.1",
|
||||
"debug": "~2.2.0",
|
||||
"methods": "~1.1.2",
|
||||
"parseurl": "~1.3.1",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"setprototypeof": "1.0.2",
|
||||
"utils-merge": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"after": "0.8.2",
|
||||
"finalhandler": "0.5.1",
|
||||
"istanbul": "0.4.5",
|
||||
"mocha": "2.5.3",
|
||||
"supertest": "1.1.0"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --bail --check-leaks test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user