Desplegando App
This commit is contained in:
215
node_modules/morgan/HISTORY.md
generated
vendored
Normal file
215
node_modules/morgan/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
1.10.0 / 2020-03-20
|
||||
===================
|
||||
|
||||
* Add `:total-time` token
|
||||
* Fix trailing space in colored status code for `dev` format
|
||||
* deps: basic-auth@~2.0.1
|
||||
- deps: safe-buffer@5.1.2
|
||||
* deps: depd@~2.0.0
|
||||
- Replace internal `eval` usage with `Function` constructor
|
||||
- Use instance methods on `process` to check for listeners
|
||||
* deps: on-headers@~1.0.2
|
||||
- Fix `res.writeHead` patch missing return value
|
||||
|
||||
1.9.1 / 2018-09-10
|
||||
==================
|
||||
|
||||
* Fix using special characters in format
|
||||
* deps: depd@~1.1.2
|
||||
- perf: remove argument reassignment
|
||||
|
||||
1.9.0 / 2017-09-26
|
||||
==================
|
||||
|
||||
* Use `res.headersSent` when available
|
||||
* deps: basic-auth@~2.0.0
|
||||
- Use `safe-buffer` for improved Buffer API
|
||||
* deps: debug@2.6.9
|
||||
* deps: depd@~1.1.1
|
||||
- Remove unnecessary `Buffer` loading
|
||||
|
||||
1.8.2 / 2017-05-23
|
||||
==================
|
||||
|
||||
* deps: debug@2.6.8
|
||||
- Fix `DEBUG_MAX_ARRAY_LENGTH`
|
||||
- deps: ms@2.0.0
|
||||
|
||||
1.8.1 / 2017-02-04
|
||||
==================
|
||||
|
||||
* deps: debug@2.6.1
|
||||
- Fix deprecation messages in WebStorm and other editors
|
||||
- Undeprecate `DEBUG_FD` set to `1` or `2`
|
||||
|
||||
1.8.0 / 2017-02-04
|
||||
==================
|
||||
|
||||
* Fix sending unnecessary `undefined` argument to token functions
|
||||
* deps: basic-auth@~1.1.0
|
||||
* deps: debug@2.6.0
|
||||
- Allow colors in workers
|
||||
- Deprecated `DEBUG_FD` environment variable
|
||||
- Fix error when running under React Native
|
||||
- Use same color for same namespace
|
||||
- deps: ms@0.7.2
|
||||
* perf: enable strict mode in compiled functions
|
||||
|
||||
1.7.0 / 2016-02-18
|
||||
==================
|
||||
|
||||
* Add `digits` argument to `response-time` token
|
||||
* deps: depd@~1.1.0
|
||||
- Enable strict mode in more places
|
||||
- Support web browser loading
|
||||
* deps: on-headers@~1.0.1
|
||||
- perf: enable strict mode
|
||||
|
||||
1.6.1 / 2015-07-03
|
||||
==================
|
||||
|
||||
* deps: basic-auth@~1.0.3
|
||||
|
||||
1.6.0 / 2015-06-12
|
||||
==================
|
||||
|
||||
* Add `morgan.compile(format)` export
|
||||
* Do not color 1xx status codes in `dev` format
|
||||
* Fix `response-time` token to not include response latency
|
||||
* Fix `status` token incorrectly displaying before response in `dev` format
|
||||
* Fix token return values to be `undefined` or a string
|
||||
* Improve representation of multiple headers in `req` and `res` tokens
|
||||
* Use `res.getHeader` in `res` token
|
||||
* deps: basic-auth@~1.0.2
|
||||
- perf: enable strict mode
|
||||
- perf: hoist regular expression
|
||||
- perf: parse with regular expressions
|
||||
- perf: remove argument reassignment
|
||||
* deps: on-finished@~2.3.0
|
||||
- Add defined behavior for HTTP `CONNECT` requests
|
||||
- Add defined behavior for HTTP `Upgrade` requests
|
||||
- deps: ee-first@1.1.1
|
||||
* pref: enable strict mode
|
||||
* pref: reduce function closure scopes
|
||||
* pref: remove dynamic compile on every request for `dev` format
|
||||
* pref: remove an argument reassignment
|
||||
* pref: skip function call without `skip` option
|
||||
|
||||
1.5.3 / 2015-05-10
|
||||
==================
|
||||
|
||||
* deps: basic-auth@~1.0.1
|
||||
* deps: debug@~2.2.0
|
||||
- deps: ms@0.7.1
|
||||
* deps: depd@~1.0.1
|
||||
* deps: on-finished@~2.2.1
|
||||
- Fix `isFinished(req)` when data buffered
|
||||
|
||||
1.5.2 / 2015-03-15
|
||||
==================
|
||||
|
||||
* deps: debug@~2.1.3
|
||||
- Fix high intensity foreground color for bold
|
||||
- deps: ms@0.7.0
|
||||
|
||||
1.5.1 / 2014-12-31
|
||||
==================
|
||||
|
||||
* deps: debug@~2.1.1
|
||||
* deps: on-finished@~2.2.0
|
||||
|
||||
1.5.0 / 2014-11-06
|
||||
==================
|
||||
|
||||
* Add multiple date formats
|
||||
- `clf` for the common log format
|
||||
- `iso` for the common ISO 8601 date time format
|
||||
- `web` for the common RFC 1123 date time format
|
||||
* Deprecate `buffer` option
|
||||
* Fix date format in `common` and `combined` formats
|
||||
* Fix token arguments to accept values with `"`
|
||||
|
||||
1.4.1 / 2014-10-22
|
||||
==================
|
||||
|
||||
* deps: on-finished@~2.1.1
|
||||
- Fix handling of pipelined requests
|
||||
|
||||
1.4.0 / 2014-10-16
|
||||
==================
|
||||
|
||||
* Add `debug` messages
|
||||
* deps: depd@~1.0.0
|
||||
|
||||
1.3.2 / 2014-09-27
|
||||
==================
|
||||
|
||||
* Fix `req.ip` integration when `immediate: false`
|
||||
|
||||
1.3.1 / 2014-09-14
|
||||
==================
|
||||
|
||||
* Remove un-used `bytes` dependency
|
||||
* deps: depd@0.4.5
|
||||
|
||||
1.3.0 / 2014-09-01
|
||||
==================
|
||||
|
||||
* Assert if `format` is not a function or string
|
||||
|
||||
1.2.3 / 2014-08-16
|
||||
==================
|
||||
|
||||
* deps: on-finished@2.1.0
|
||||
|
||||
1.2.2 / 2014-07-27
|
||||
==================
|
||||
|
||||
* deps: depd@0.4.4
|
||||
- Work-around v8 generating empty stack traces
|
||||
|
||||
1.2.1 / 2014-07-26
|
||||
==================
|
||||
|
||||
* deps: depd@0.4.3
|
||||
- Fix exception when global `Error.stackTraceLimit` is too low
|
||||
|
||||
1.2.0 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Add `:remote-user` token
|
||||
* Add `combined` log format
|
||||
* Add `common` log format
|
||||
* Add `morgan(format, options)` function signature
|
||||
* Deprecate `default` format -- use `combined` format instead
|
||||
* Deprecate not providing a format
|
||||
* Remove non-standard grey color from `dev` format
|
||||
|
||||
1.1.1 / 2014-05-20
|
||||
==================
|
||||
|
||||
* simplify method to get remote address
|
||||
|
||||
1.1.0 / 2014-05-18
|
||||
==================
|
||||
|
||||
* "dev" format will use same tokens as other formats
|
||||
* `:response-time` token is now empty when immediate used
|
||||
* `:response-time` token is now monotonic
|
||||
* `:response-time` token has precision to 1 μs
|
||||
* fix `:status` + immediate output in node.js 0.8
|
||||
* improve `buffer` option to prevent indefinite event loop holding
|
||||
* deps: bytes@1.0.0
|
||||
- add negative support
|
||||
|
||||
1.0.1 / 2014-05-04
|
||||
==================
|
||||
|
||||
* Make buffer unique per morgan instance
|
||||
* deps: bytes@0.3.0
|
||||
* added terabyte support
|
||||
|
||||
1.0.0 / 2014-02-08
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
23
node_modules/morgan/LICENSE
generated
vendored
Normal file
23
node_modules/morgan/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2014-2017 Douglas Christopher Wilson <doug@somethingdoug.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.
|
||||
417
node_modules/morgan/README.md
generated
vendored
Normal file
417
node_modules/morgan/README.md
generated
vendored
Normal file
@@ -0,0 +1,417 @@
|
||||
# morgan
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
HTTP request logger middleware for node.js
|
||||
|
||||
> Named after [Dexter](http://en.wikipedia.org/wiki/Dexter_Morgan), a show you should not watch until completion.
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```js
|
||||
var morgan = require('morgan')
|
||||
```
|
||||
|
||||
### morgan(format, options)
|
||||
|
||||
Create a new morgan logger middleware function using the given `format` and `options`.
|
||||
The `format` argument may be a string of a predefined name (see below for the names),
|
||||
a string of a format string, or a function that will produce a log entry.
|
||||
|
||||
The `format` function will be called with three arguments `tokens`, `req`, and `res`,
|
||||
where `tokens` is an object with all defined tokens, `req` is the HTTP request and `res`
|
||||
is the HTTP response. The function is expected to return a string that will be the log
|
||||
line, or `undefined` / `null` to skip logging.
|
||||
|
||||
#### Using a predefined format string
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
morgan('tiny')
|
||||
```
|
||||
|
||||
#### Using format string of predefined tokens
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
morgan(':method :url :status :res[content-length] - :response-time ms')
|
||||
```
|
||||
|
||||
#### Using a custom format function
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
``` js
|
||||
morgan(function (tokens, req, res) {
|
||||
return [
|
||||
tokens.method(req, res),
|
||||
tokens.url(req, res),
|
||||
tokens.status(req, res),
|
||||
tokens.res(req, res, 'content-length'), '-',
|
||||
tokens['response-time'](req, res), 'ms'
|
||||
].join(' ')
|
||||
})
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
Morgan accepts these properties in the options object.
|
||||
|
||||
##### immediate
|
||||
|
||||
Write log line on request instead of response. This means that a requests will
|
||||
be logged even if the server crashes, _but data from the response (like the
|
||||
response code, content length, etc.) cannot be logged_.
|
||||
|
||||
##### skip
|
||||
|
||||
Function to determine if logging is skipped, defaults to `false`. This function
|
||||
will be called as `skip(req, res)`.
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
// EXAMPLE: only log error responses
|
||||
morgan('combined', {
|
||||
skip: function (req, res) { return res.statusCode < 400 }
|
||||
})
|
||||
```
|
||||
|
||||
##### stream
|
||||
|
||||
Output stream for writing log lines, defaults to `process.stdout`.
|
||||
|
||||
#### Predefined Formats
|
||||
|
||||
There are various pre-defined formats provided:
|
||||
|
||||
##### combined
|
||||
|
||||
Standard Apache combined log output.
|
||||
|
||||
```
|
||||
:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"
|
||||
```
|
||||
|
||||
##### common
|
||||
|
||||
Standard Apache common log output.
|
||||
|
||||
```
|
||||
:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length]
|
||||
```
|
||||
|
||||
##### dev
|
||||
|
||||
Concise output colored by response status for development use. The `:status`
|
||||
token will be colored green for success codes, red for server error codes,
|
||||
yellow for client error codes, cyan for redirection codes, and uncolored
|
||||
for information codes.
|
||||
|
||||
```
|
||||
:method :url :status :response-time ms - :res[content-length]
|
||||
```
|
||||
|
||||
##### short
|
||||
|
||||
Shorter than default, also including response time.
|
||||
|
||||
```
|
||||
:remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms
|
||||
```
|
||||
|
||||
##### tiny
|
||||
|
||||
The minimal output.
|
||||
|
||||
```
|
||||
:method :url :status :res[content-length] - :response-time ms
|
||||
```
|
||||
|
||||
#### Tokens
|
||||
|
||||
##### Creating new tokens
|
||||
|
||||
To define a token, simply invoke `morgan.token()` with the name and a callback function.
|
||||
This callback function is expected to return a string value. The value returned is then
|
||||
available as ":type" in this case:
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
morgan.token('type', function (req, res) { return req.headers['content-type'] })
|
||||
```
|
||||
|
||||
Calling `morgan.token()` using the same name as an existing token will overwrite that
|
||||
token definition.
|
||||
|
||||
The token function is expected to be called with the arguments `req` and `res`, representing
|
||||
the HTTP request and HTTP response. Additionally, the token can accept further arguments of
|
||||
it's choosing to customize behavior.
|
||||
|
||||
##### :date[format]
|
||||
|
||||
The current date and time in UTC. The available formats are:
|
||||
|
||||
- `clf` for the common log format (`"10/Oct/2000:13:55:36 +0000"`)
|
||||
- `iso` for the common ISO 8601 date time format (`2000-10-10T13:55:36.000Z`)
|
||||
- `web` for the common RFC 1123 date time format (`Tue, 10 Oct 2000 13:55:36 GMT`)
|
||||
|
||||
If no format is given, then the default is `web`.
|
||||
|
||||
##### :http-version
|
||||
|
||||
The HTTP version of the request.
|
||||
|
||||
##### :method
|
||||
|
||||
The HTTP method of the request.
|
||||
|
||||
##### :referrer
|
||||
|
||||
The Referrer header of the request. This will use the standard mis-spelled Referer header if exists, otherwise Referrer.
|
||||
|
||||
##### :remote-addr
|
||||
|
||||
The remote address of the request. This will use `req.ip`, otherwise the standard `req.connection.remoteAddress` value (socket address).
|
||||
|
||||
##### :remote-user
|
||||
|
||||
The user authenticated as part of Basic auth for the request.
|
||||
|
||||
##### :req[header]
|
||||
|
||||
The given `header` of the request. If the header is not present, the
|
||||
value will be displayed as `"-"` in the log.
|
||||
|
||||
##### :res[header]
|
||||
|
||||
The given `header` of the response. If the header is not present, the
|
||||
value will be displayed as `"-"` in the log.
|
||||
|
||||
##### :response-time[digits]
|
||||
|
||||
The time between the request coming into `morgan` and when the response
|
||||
headers are written, in milliseconds.
|
||||
|
||||
The `digits` argument is a number that specifies the number of digits to
|
||||
include on the number, defaulting to `3`, which provides microsecond precision.
|
||||
|
||||
##### :status
|
||||
|
||||
The status code of the response.
|
||||
|
||||
If the request/response cycle completes before a response was sent to the
|
||||
client (for example, the TCP socket closed prematurely by a client aborting
|
||||
the request), then the status will be empty (displayed as `"-"` in the log).
|
||||
|
||||
##### :total-time[digits]
|
||||
|
||||
The time between the request coming into `morgan` and when the response
|
||||
has finished being written out to the connection, in milliseconds.
|
||||
|
||||
The `digits` argument is a number that specifies the number of digits to
|
||||
include on the number, defaulting to `3`, which provides microsecond precision.
|
||||
|
||||
##### :url
|
||||
|
||||
The URL of the request. This will use `req.originalUrl` if exists, otherwise `req.url`.
|
||||
|
||||
##### :user-agent
|
||||
|
||||
The contents of the User-Agent header of the request.
|
||||
|
||||
### morgan.compile(format)
|
||||
|
||||
Compile a format string into a `format` function for use by `morgan`. A format string
|
||||
is a string that represents a single log line and can utilize token syntax.
|
||||
Tokens are references by `:token-name`. If tokens accept arguments, they can
|
||||
be passed using `[]`, for example: `:token-name[pretty]` would pass the string
|
||||
`'pretty'` as an argument to the token `token-name`.
|
||||
|
||||
The function returned from `morgan.compile` takes three arguments `tokens`, `req`, and
|
||||
`res`, where `tokens` is object with all defined tokens, `req` is the HTTP request and
|
||||
`res` is the HTTP response. The function will return a string that will be the log line,
|
||||
or `undefined` / `null` to skip logging.
|
||||
|
||||
Normally formats are defined using `morgan.format(name, format)`, but for certain
|
||||
advanced uses, this compile function is directly available.
|
||||
|
||||
## Examples
|
||||
|
||||
### express/connect
|
||||
|
||||
Simple app that will log all request in the Apache combined format to STDOUT
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var morgan = require('morgan')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(morgan('combined'))
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('hello, world!')
|
||||
})
|
||||
```
|
||||
|
||||
### vanilla http server
|
||||
|
||||
Simple app that will log all request in the Apache combined format to STDOUT
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
var http = require('http')
|
||||
var morgan = require('morgan')
|
||||
|
||||
// create "middleware"
|
||||
var logger = morgan('combined')
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
var done = finalhandler(req, res)
|
||||
logger(req, res, function (err) {
|
||||
if (err) return done(err)
|
||||
|
||||
// respond to request
|
||||
res.setHeader('content-type', 'text/plain')
|
||||
res.end('hello, world!')
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
### write logs to a file
|
||||
|
||||
#### single file
|
||||
|
||||
Simple app that will log all requests in the Apache combined format to the file
|
||||
`access.log`.
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var fs = require('fs')
|
||||
var morgan = require('morgan')
|
||||
var path = require('path')
|
||||
|
||||
var app = express()
|
||||
|
||||
// create a write stream (in append mode)
|
||||
var accessLogStream = fs.createWriteStream(path.join(__dirname, 'access.log'), { flags: 'a' })
|
||||
|
||||
// setup the logger
|
||||
app.use(morgan('combined', { stream: accessLogStream }))
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('hello, world!')
|
||||
})
|
||||
```
|
||||
|
||||
#### log file rotation
|
||||
|
||||
Simple app that will log all requests in the Apache combined format to one log
|
||||
file per day in the `log/` directory using the
|
||||
[rotating-file-stream module](https://www.npmjs.com/package/rotating-file-stream).
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var morgan = require('morgan')
|
||||
var path = require('path')
|
||||
var rfs = require('rotating-file-stream') // version 2.x
|
||||
|
||||
var app = express()
|
||||
|
||||
// create a rotating write stream
|
||||
var accessLogStream = rfs.createStream('access.log', {
|
||||
interval: '1d', // rotate daily
|
||||
path: path.join(__dirname, 'log')
|
||||
})
|
||||
|
||||
// setup the logger
|
||||
app.use(morgan('combined', { stream: accessLogStream }))
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('hello, world!')
|
||||
})
|
||||
```
|
||||
|
||||
### split / dual logging
|
||||
|
||||
The `morgan` middleware can be used as many times as needed, enabling
|
||||
combinations like:
|
||||
|
||||
* Log entry on request and one on response
|
||||
* Log all requests to file, but errors to console
|
||||
* ... and more!
|
||||
|
||||
Sample app that will log all requests to a file using Apache format, but
|
||||
error responses are logged to the console:
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var fs = require('fs')
|
||||
var morgan = require('morgan')
|
||||
var path = require('path')
|
||||
|
||||
var app = express()
|
||||
|
||||
// log only 4xx and 5xx responses to console
|
||||
app.use(morgan('dev', {
|
||||
skip: function (req, res) { return res.statusCode < 400 }
|
||||
}))
|
||||
|
||||
// log all requests to access.log
|
||||
app.use(morgan('common', {
|
||||
stream: fs.createWriteStream(path.join(__dirname, 'access.log'), { flags: 'a' })
|
||||
}))
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('hello, world!')
|
||||
})
|
||||
```
|
||||
|
||||
### use custom token formats
|
||||
|
||||
Sample app that will use custom token formats. This adds an ID to all requests and displays it using the `:id` token.
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var morgan = require('morgan')
|
||||
var uuid = require('node-uuid')
|
||||
|
||||
morgan.token('id', function getId (req) {
|
||||
return req.id
|
||||
})
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(assignId)
|
||||
app.use(morgan(':id :method :url :response-time'))
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('hello, world!')
|
||||
})
|
||||
|
||||
function assignId (req, res, next) {
|
||||
req.id = uuid.v4()
|
||||
next()
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/morgan/master
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/morgan?branch=master
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/morgan
|
||||
[npm-url]: https://npmjs.org/package/morgan
|
||||
[npm-version-image]: https://badgen.net/npm/v/morgan
|
||||
[travis-image]: https://badgen.net/travis/expressjs/morgan/master
|
||||
[travis-url]: https://travis-ci.org/expressjs/morgan
|
||||
544
node_modules/morgan/index.js
generated
vendored
Normal file
544
node_modules/morgan/index.js
generated
vendored
Normal file
@@ -0,0 +1,544 @@
|
||||
/*!
|
||||
* morgan
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = morgan
|
||||
module.exports.compile = compile
|
||||
module.exports.format = format
|
||||
module.exports.token = token
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var auth = require('basic-auth')
|
||||
var debug = require('debug')('morgan')
|
||||
var deprecate = require('depd')('morgan')
|
||||
var onFinished = require('on-finished')
|
||||
var onHeaders = require('on-headers')
|
||||
|
||||
/**
|
||||
* Array of CLF month names.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var CLF_MONTH = [
|
||||
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
|
||||
]
|
||||
|
||||
/**
|
||||
* Default log buffer duration.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var DEFAULT_BUFFER_DURATION = 1000
|
||||
|
||||
/**
|
||||
* Create a logger middleware.
|
||||
*
|
||||
* @public
|
||||
* @param {String|Function} format
|
||||
* @param {Object} [options]
|
||||
* @return {Function} middleware
|
||||
*/
|
||||
|
||||
function morgan (format, options) {
|
||||
var fmt = format
|
||||
var opts = options || {}
|
||||
|
||||
if (format && typeof format === 'object') {
|
||||
opts = format
|
||||
fmt = opts.format || 'default'
|
||||
|
||||
// smart deprecation message
|
||||
deprecate('morgan(options): use morgan(' + (typeof fmt === 'string' ? JSON.stringify(fmt) : 'format') + ', options) instead')
|
||||
}
|
||||
|
||||
if (fmt === undefined) {
|
||||
deprecate('undefined format: specify a format')
|
||||
}
|
||||
|
||||
// output on request instead of response
|
||||
var immediate = opts.immediate
|
||||
|
||||
// check if log entry should be skipped
|
||||
var skip = opts.skip || false
|
||||
|
||||
// format function
|
||||
var formatLine = typeof fmt !== 'function'
|
||||
? getFormatFunction(fmt)
|
||||
: fmt
|
||||
|
||||
// stream
|
||||
var buffer = opts.buffer
|
||||
var stream = opts.stream || process.stdout
|
||||
|
||||
// buffering support
|
||||
if (buffer) {
|
||||
deprecate('buffer option')
|
||||
|
||||
// flush interval
|
||||
var interval = typeof buffer !== 'number'
|
||||
? DEFAULT_BUFFER_DURATION
|
||||
: buffer
|
||||
|
||||
// swap the stream
|
||||
stream = createBufferStream(stream, interval)
|
||||
}
|
||||
|
||||
return function logger (req, res, next) {
|
||||
// request data
|
||||
req._startAt = undefined
|
||||
req._startTime = undefined
|
||||
req._remoteAddress = getip(req)
|
||||
|
||||
// response data
|
||||
res._startAt = undefined
|
||||
res._startTime = undefined
|
||||
|
||||
// record request start
|
||||
recordStartTime.call(req)
|
||||
|
||||
function logRequest () {
|
||||
if (skip !== false && skip(req, res)) {
|
||||
debug('skip request')
|
||||
return
|
||||
}
|
||||
|
||||
var line = formatLine(morgan, req, res)
|
||||
|
||||
if (line == null) {
|
||||
debug('skip line')
|
||||
return
|
||||
}
|
||||
|
||||
debug('log request')
|
||||
stream.write(line + '\n')
|
||||
};
|
||||
|
||||
if (immediate) {
|
||||
// immediate log
|
||||
logRequest()
|
||||
} else {
|
||||
// record response start
|
||||
onHeaders(res, recordStartTime)
|
||||
|
||||
// log when response finished
|
||||
onFinished(res, logRequest)
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apache combined log format.
|
||||
*/
|
||||
|
||||
morgan.format('combined', ':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"')
|
||||
|
||||
/**
|
||||
* Apache common log format.
|
||||
*/
|
||||
|
||||
morgan.format('common', ':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length]')
|
||||
|
||||
/**
|
||||
* Default format.
|
||||
*/
|
||||
|
||||
morgan.format('default', ':remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"')
|
||||
deprecate.property(morgan, 'default', 'default format: use combined format')
|
||||
|
||||
/**
|
||||
* Short format.
|
||||
*/
|
||||
|
||||
morgan.format('short', ':remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms')
|
||||
|
||||
/**
|
||||
* Tiny format.
|
||||
*/
|
||||
|
||||
morgan.format('tiny', ':method :url :status :res[content-length] - :response-time ms')
|
||||
|
||||
/**
|
||||
* dev (colored)
|
||||
*/
|
||||
|
||||
morgan.format('dev', function developmentFormatLine (tokens, req, res) {
|
||||
// get the status code if response written
|
||||
var status = headersSent(res)
|
||||
? res.statusCode
|
||||
: undefined
|
||||
|
||||
// get status color
|
||||
var color = status >= 500 ? 31 // red
|
||||
: status >= 400 ? 33 // yellow
|
||||
: status >= 300 ? 36 // cyan
|
||||
: status >= 200 ? 32 // green
|
||||
: 0 // no color
|
||||
|
||||
// get colored function
|
||||
var fn = developmentFormatLine[color]
|
||||
|
||||
if (!fn) {
|
||||
// compile
|
||||
fn = developmentFormatLine[color] = compile('\x1b[0m:method :url \x1b[' +
|
||||
color + 'm:status\x1b[0m :response-time ms - :res[content-length]\x1b[0m')
|
||||
}
|
||||
|
||||
return fn(tokens, req, res)
|
||||
})
|
||||
|
||||
/**
|
||||
* request url
|
||||
*/
|
||||
|
||||
morgan.token('url', function getUrlToken (req) {
|
||||
return req.originalUrl || req.url
|
||||
})
|
||||
|
||||
/**
|
||||
* request method
|
||||
*/
|
||||
|
||||
morgan.token('method', function getMethodToken (req) {
|
||||
return req.method
|
||||
})
|
||||
|
||||
/**
|
||||
* response time in milliseconds
|
||||
*/
|
||||
|
||||
morgan.token('response-time', function getResponseTimeToken (req, res, digits) {
|
||||
if (!req._startAt || !res._startAt) {
|
||||
// missing request and/or response start time
|
||||
return
|
||||
}
|
||||
|
||||
// calculate diff
|
||||
var ms = (res._startAt[0] - req._startAt[0]) * 1e3 +
|
||||
(res._startAt[1] - req._startAt[1]) * 1e-6
|
||||
|
||||
// return truncated value
|
||||
return ms.toFixed(digits === undefined ? 3 : digits)
|
||||
})
|
||||
|
||||
/**
|
||||
* total time in milliseconds
|
||||
*/
|
||||
|
||||
morgan.token('total-time', function getTotalTimeToken (req, res, digits) {
|
||||
if (!req._startAt || !res._startAt) {
|
||||
// missing request and/or response start time
|
||||
return
|
||||
}
|
||||
|
||||
// time elapsed from request start
|
||||
var elapsed = process.hrtime(req._startAt)
|
||||
|
||||
// cover to milliseconds
|
||||
var ms = (elapsed[0] * 1e3) + (elapsed[1] * 1e-6)
|
||||
|
||||
// return truncated value
|
||||
return ms.toFixed(digits === undefined ? 3 : digits)
|
||||
})
|
||||
|
||||
/**
|
||||
* current date
|
||||
*/
|
||||
|
||||
morgan.token('date', function getDateToken (req, res, format) {
|
||||
var date = new Date()
|
||||
|
||||
switch (format || 'web') {
|
||||
case 'clf':
|
||||
return clfdate(date)
|
||||
case 'iso':
|
||||
return date.toISOString()
|
||||
case 'web':
|
||||
return date.toUTCString()
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* response status code
|
||||
*/
|
||||
|
||||
morgan.token('status', function getStatusToken (req, res) {
|
||||
return headersSent(res)
|
||||
? String(res.statusCode)
|
||||
: undefined
|
||||
})
|
||||
|
||||
/**
|
||||
* normalized referrer
|
||||
*/
|
||||
|
||||
morgan.token('referrer', function getReferrerToken (req) {
|
||||
return req.headers.referer || req.headers.referrer
|
||||
})
|
||||
|
||||
/**
|
||||
* remote address
|
||||
*/
|
||||
|
||||
morgan.token('remote-addr', getip)
|
||||
|
||||
/**
|
||||
* remote user
|
||||
*/
|
||||
|
||||
morgan.token('remote-user', function getRemoteUserToken (req) {
|
||||
// parse basic credentials
|
||||
var credentials = auth(req)
|
||||
|
||||
// return username
|
||||
return credentials
|
||||
? credentials.name
|
||||
: undefined
|
||||
})
|
||||
|
||||
/**
|
||||
* HTTP version
|
||||
*/
|
||||
|
||||
morgan.token('http-version', function getHttpVersionToken (req) {
|
||||
return req.httpVersionMajor + '.' + req.httpVersionMinor
|
||||
})
|
||||
|
||||
/**
|
||||
* UA string
|
||||
*/
|
||||
|
||||
morgan.token('user-agent', function getUserAgentToken (req) {
|
||||
return req.headers['user-agent']
|
||||
})
|
||||
|
||||
/**
|
||||
* request header
|
||||
*/
|
||||
|
||||
morgan.token('req', function getRequestToken (req, res, field) {
|
||||
// get header
|
||||
var header = req.headers[field.toLowerCase()]
|
||||
|
||||
return Array.isArray(header)
|
||||
? header.join(', ')
|
||||
: header
|
||||
})
|
||||
|
||||
/**
|
||||
* response header
|
||||
*/
|
||||
|
||||
morgan.token('res', function getResponseHeader (req, res, field) {
|
||||
if (!headersSent(res)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
// get header
|
||||
var header = res.getHeader(field)
|
||||
|
||||
return Array.isArray(header)
|
||||
? header.join(', ')
|
||||
: header
|
||||
})
|
||||
|
||||
/**
|
||||
* Format a Date in the common log format.
|
||||
*
|
||||
* @private
|
||||
* @param {Date} dateTime
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
function clfdate (dateTime) {
|
||||
var date = dateTime.getUTCDate()
|
||||
var hour = dateTime.getUTCHours()
|
||||
var mins = dateTime.getUTCMinutes()
|
||||
var secs = dateTime.getUTCSeconds()
|
||||
var year = dateTime.getUTCFullYear()
|
||||
|
||||
var month = CLF_MONTH[dateTime.getUTCMonth()]
|
||||
|
||||
return pad2(date) + '/' + month + '/' + year +
|
||||
':' + pad2(hour) + ':' + pad2(mins) + ':' + pad2(secs) +
|
||||
' +0000'
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile a format string into a function.
|
||||
*
|
||||
* @param {string} format
|
||||
* @return {function}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function compile (format) {
|
||||
if (typeof format !== 'string') {
|
||||
throw new TypeError('argument format must be a string')
|
||||
}
|
||||
|
||||
var fmt = String(JSON.stringify(format))
|
||||
var js = ' "use strict"\n return ' + fmt.replace(/:([-\w]{2,})(?:\[([^\]]+)\])?/g, function (_, name, arg) {
|
||||
var tokenArguments = 'req, res'
|
||||
var tokenFunction = 'tokens[' + String(JSON.stringify(name)) + ']'
|
||||
|
||||
if (arg !== undefined) {
|
||||
tokenArguments += ', ' + String(JSON.stringify(arg))
|
||||
}
|
||||
|
||||
return '" +\n (' + tokenFunction + '(' + tokenArguments + ') || "-") + "'
|
||||
})
|
||||
|
||||
// eslint-disable-next-line no-new-func
|
||||
return new Function('tokens, req, res', js)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a basic buffering stream.
|
||||
*
|
||||
* @param {object} stream
|
||||
* @param {number} interval
|
||||
* @public
|
||||
*/
|
||||
|
||||
function createBufferStream (stream, interval) {
|
||||
var buf = []
|
||||
var timer = null
|
||||
|
||||
// flush function
|
||||
function flush () {
|
||||
timer = null
|
||||
stream.write(buf.join(''))
|
||||
buf.length = 0
|
||||
}
|
||||
|
||||
// write function
|
||||
function write (str) {
|
||||
if (timer === null) {
|
||||
timer = setTimeout(flush, interval)
|
||||
}
|
||||
|
||||
buf.push(str)
|
||||
}
|
||||
|
||||
// return a minimal "stream"
|
||||
return { write: write }
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a format with the given name.
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {string|function} fmt
|
||||
* @public
|
||||
*/
|
||||
|
||||
function format (name, fmt) {
|
||||
morgan[name] = fmt
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup and compile a named format function.
|
||||
*
|
||||
* @param {string} name
|
||||
* @return {function}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function getFormatFunction (name) {
|
||||
// lookup format
|
||||
var fmt = morgan[name] || name || morgan.default
|
||||
|
||||
// return compiled format
|
||||
return typeof fmt !== 'function'
|
||||
? compile(fmt)
|
||||
: fmt
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request IP address.
|
||||
*
|
||||
* @private
|
||||
* @param {IncomingMessage} req
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
function getip (req) {
|
||||
return req.ip ||
|
||||
req._remoteAddress ||
|
||||
(req.connection && req.connection.remoteAddress) ||
|
||||
undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the response headers have been sent.
|
||||
*
|
||||
* @param {object} res
|
||||
* @returns {boolean}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function headersSent (res) {
|
||||
// istanbul ignore next: node.js 0.8 support
|
||||
return typeof res.headersSent !== 'boolean'
|
||||
? Boolean(res._header)
|
||||
: res.headersSent
|
||||
}
|
||||
|
||||
/**
|
||||
* Pad number to two digits.
|
||||
*
|
||||
* @private
|
||||
* @param {number} num
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
function pad2 (num) {
|
||||
var str = String(num)
|
||||
|
||||
// istanbul ignore next: num is current datetime
|
||||
return (str.length === 1 ? '0' : '') + str
|
||||
}
|
||||
|
||||
/**
|
||||
* Record the start time.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function recordStartTime () {
|
||||
this._startAt = process.hrtime()
|
||||
this._startTime = new Date()
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a token function with the given name,
|
||||
* and callback fn(req, res).
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {function} fn
|
||||
* @public
|
||||
*/
|
||||
|
||||
function token (name, fn) {
|
||||
morgan[name] = fn
|
||||
return this
|
||||
}
|
||||
103
node_modules/morgan/node_modules/depd/History.md
generated
vendored
Normal file
103
node_modules/morgan/node_modules/depd/History.md
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
2.0.0 / 2018-10-26
|
||||
==================
|
||||
|
||||
* Drop support for Node.js 0.6
|
||||
* Replace internal `eval` usage with `Function` constructor
|
||||
* Use instance methods on `process` to check for listeners
|
||||
|
||||
1.1.2 / 2018-01-11
|
||||
==================
|
||||
|
||||
* perf: remove argument reassignment
|
||||
* Support Node.js 0.6 to 9.x
|
||||
|
||||
1.1.1 / 2017-07-27
|
||||
==================
|
||||
|
||||
* Remove unnecessary `Buffer` loading
|
||||
* Support Node.js 0.6 to 8.x
|
||||
|
||||
1.1.0 / 2015-09-14
|
||||
==================
|
||||
|
||||
* Enable strict mode in more places
|
||||
* Support io.js 3.x
|
||||
* Support io.js 2.x
|
||||
* Support web browser loading
|
||||
- Requires bundler like Browserify or webpack
|
||||
|
||||
1.0.1 / 2015-04-07
|
||||
==================
|
||||
|
||||
* Fix `TypeError`s when under `'use strict'` code
|
||||
* Fix useless type name on auto-generated messages
|
||||
* Support io.js 1.x
|
||||
* Support Node.js 0.12
|
||||
|
||||
1.0.0 / 2014-09-17
|
||||
==================
|
||||
|
||||
* No changes
|
||||
|
||||
0.4.5 / 2014-09-09
|
||||
==================
|
||||
|
||||
* Improve call speed to functions using the function wrapper
|
||||
* Support Node.js 0.6
|
||||
|
||||
0.4.4 / 2014-07-27
|
||||
==================
|
||||
|
||||
* Work-around v8 generating empty stack traces
|
||||
|
||||
0.4.3 / 2014-07-26
|
||||
==================
|
||||
|
||||
* Fix exception when global `Error.stackTraceLimit` is too low
|
||||
|
||||
0.4.2 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Correct call site for wrapped functions and properties
|
||||
|
||||
0.4.1 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Improve automatic message generation for function properties
|
||||
|
||||
0.4.0 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Add `TRACE_DEPRECATION` environment variable
|
||||
* Remove non-standard grey color from color output
|
||||
* Support `--no-deprecation` argument
|
||||
* Support `--trace-deprecation` argument
|
||||
* Support `deprecate.property(fn, prop, message)`
|
||||
|
||||
0.3.0 / 2014-06-16
|
||||
==================
|
||||
|
||||
* Add `NO_DEPRECATION` environment variable
|
||||
|
||||
0.2.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Add `deprecate.property(obj, prop, message)`
|
||||
* Remove `supports-color` dependency for node.js 0.8
|
||||
|
||||
0.1.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Add `deprecate.function(fn, message)`
|
||||
* Add `process.on('deprecation', fn)` emitter
|
||||
* Automatically generate message when omitted from `deprecate()`
|
||||
|
||||
0.0.1 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Fix warning for dynamic calls at singe call site
|
||||
|
||||
0.0.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Initial implementation
|
||||
22
node_modules/morgan/node_modules/depd/LICENSE
generated
vendored
Normal file
22
node_modules/morgan/node_modules/depd/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2018 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.
|
||||
280
node_modules/morgan/node_modules/depd/Readme.md
generated
vendored
Normal file
280
node_modules/morgan/node_modules/depd/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,280 @@
|
||||
# depd
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Linux Build][travis-image]][travis-url]
|
||||
[![Windows Build][appveyor-image]][appveyor-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
|
||||
Deprecate all the things
|
||||
|
||||
> With great modules comes great responsibility; mark things deprecated!
|
||||
|
||||
## Install
|
||||
|
||||
This module is installed directly using `npm`:
|
||||
|
||||
```sh
|
||||
$ npm install depd
|
||||
```
|
||||
|
||||
This module can also be bundled with systems like
|
||||
[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/),
|
||||
though by default this module will alter it's API to no longer display or
|
||||
track deprecations.
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-module')
|
||||
```
|
||||
|
||||
This library allows you to display deprecation messages to your users.
|
||||
This library goes above and beyond with deprecation warnings by
|
||||
introspection of the call stack (but only the bits that it is interested
|
||||
in).
|
||||
|
||||
Instead of just warning on the first invocation of a deprecated
|
||||
function and never again, this module will warn on the first invocation
|
||||
of a deprecated function per unique call site, making it ideal to alert
|
||||
users of all deprecated uses across the code base, rather than just
|
||||
whatever happens to execute first.
|
||||
|
||||
The deprecation warnings from this module also include the file and line
|
||||
information for the call into the module that the deprecated function was
|
||||
in.
|
||||
|
||||
**NOTE** this library has a similar interface to the `debug` module, and
|
||||
this module uses the calling file to get the boundary for the call stacks,
|
||||
so you should always create a new `deprecate` object in each file and not
|
||||
within some central file.
|
||||
|
||||
### depd(namespace)
|
||||
|
||||
Create a new deprecate function that uses the given namespace name in the
|
||||
messages and will display the call site prior to the stack entering the
|
||||
file this function was called from. It is highly suggested you use the
|
||||
name of your module as the namespace.
|
||||
|
||||
### deprecate(message)
|
||||
|
||||
Call this function from deprecated code to display a deprecation message.
|
||||
This message will appear once per unique caller site. Caller site is the
|
||||
first call site in the stack in a different file from the caller of this
|
||||
function.
|
||||
|
||||
If the message is omitted, a message is generated for you based on the site
|
||||
of the `deprecate()` call and will display the name of the function called,
|
||||
similar to the name displayed in a stack trace.
|
||||
|
||||
### deprecate.function(fn, message)
|
||||
|
||||
Call this function to wrap a given function in a deprecation message on any
|
||||
call to the function. An optional message can be supplied to provide a custom
|
||||
message.
|
||||
|
||||
### deprecate.property(obj, prop, message)
|
||||
|
||||
Call this function to wrap a given property on object in a deprecation message
|
||||
on any accessing or setting of the property. An optional message can be supplied
|
||||
to provide a custom message.
|
||||
|
||||
The method must be called on the object where the property belongs (not
|
||||
inherited from the prototype).
|
||||
|
||||
If the property is a data descriptor, it will be converted to an accessor
|
||||
descriptor in order to display the deprecation message.
|
||||
|
||||
### process.on('deprecation', fn)
|
||||
|
||||
This module will allow easy capturing of deprecation errors by emitting the
|
||||
errors as the type "deprecation" on the global `process`. If there are no
|
||||
listeners for this type, the errors are written to STDERR as normal, but if
|
||||
there are any listeners, nothing will be written to STDERR and instead only
|
||||
emitted. From there, you can write the errors in a different format or to a
|
||||
logging source.
|
||||
|
||||
The error represents the deprecation and is emitted only once with the same
|
||||
rules as writing to STDERR. The error has the following properties:
|
||||
|
||||
- `message` - This is the message given by the library
|
||||
- `name` - This is always `'DeprecationError'`
|
||||
- `namespace` - This is the namespace the deprecation came from
|
||||
- `stack` - This is the stack of the call to the deprecated thing
|
||||
|
||||
Example `error.stack` output:
|
||||
|
||||
```
|
||||
DeprecationError: my-cool-module deprecated oldfunction
|
||||
at Object.<anonymous> ([eval]-wrapper:6:22)
|
||||
at Module._compile (module.js:456:26)
|
||||
at evalScript (node.js:532:25)
|
||||
at startup (node.js:80:7)
|
||||
at node.js:902:3
|
||||
```
|
||||
|
||||
### process.env.NO_DEPRECATION
|
||||
|
||||
As a user of modules that are deprecated, the environment variable `NO_DEPRECATION`
|
||||
is provided as a quick solution to silencing deprecation warnings from being
|
||||
output. The format of this is similar to that of `DEBUG`:
|
||||
|
||||
```sh
|
||||
$ NO_DEPRECATION=my-module,othermod node app.js
|
||||
```
|
||||
|
||||
This will suppress deprecations from being output for "my-module" and "othermod".
|
||||
The value is a list of comma-separated namespaces. To suppress every warning
|
||||
across all namespaces, use the value `*` for a namespace.
|
||||
|
||||
Providing the argument `--no-deprecation` to the `node` executable will suppress
|
||||
all deprecations (only available in Node.js 0.8 or higher).
|
||||
|
||||
**NOTE** This will not suppress the deperecations given to any "deprecation"
|
||||
event listeners, just the output to STDERR.
|
||||
|
||||
### process.env.TRACE_DEPRECATION
|
||||
|
||||
As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
|
||||
is provided as a solution to getting more detailed location information in deprecation
|
||||
warnings by including the entire stack trace. The format of this is the same as
|
||||
`NO_DEPRECATION`:
|
||||
|
||||
```sh
|
||||
$ TRACE_DEPRECATION=my-module,othermod node app.js
|
||||
```
|
||||
|
||||
This will include stack traces for deprecations being output for "my-module" and
|
||||
"othermod". The value is a list of comma-separated namespaces. To trace every
|
||||
warning across all namespaces, use the value `*` for a namespace.
|
||||
|
||||
Providing the argument `--trace-deprecation` to the `node` executable will trace
|
||||
all deprecations (only available in Node.js 0.8 or higher).
|
||||
|
||||
**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
|
||||
|
||||
## Display
|
||||
|
||||

|
||||
|
||||
When a user calls a function in your library that you mark deprecated, they
|
||||
will see the following written to STDERR (in the given colors, similar colors
|
||||
and layout to the `debug` module):
|
||||
|
||||
```
|
||||
bright cyan bright yellow
|
||||
| | reset cyan
|
||||
| | | |
|
||||
▼ ▼ ▼ ▼
|
||||
my-cool-module deprecated oldfunction [eval]-wrapper:6:22
|
||||
▲ ▲ ▲ ▲
|
||||
| | | |
|
||||
namespace | | location of mycoolmod.oldfunction() call
|
||||
| deprecation message
|
||||
the word "deprecated"
|
||||
```
|
||||
|
||||
If the user redirects their STDERR to a file or somewhere that does not support
|
||||
colors, they see (similar layout to the `debug` module):
|
||||
|
||||
```
|
||||
Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
|
||||
▲ ▲ ▲ ▲ ▲
|
||||
| | | | |
|
||||
timestamp of message namespace | | location of mycoolmod.oldfunction() call
|
||||
| deprecation message
|
||||
the word "deprecated"
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Deprecating all calls to a function
|
||||
|
||||
This will display a deprecated message about "oldfunction" being deprecated
|
||||
from "my-module" on STDERR.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
// message automatically derived from function name
|
||||
// Object.oldfunction
|
||||
exports.oldfunction = deprecate.function(function oldfunction () {
|
||||
// all calls to function are deprecated
|
||||
})
|
||||
|
||||
// specific message
|
||||
exports.oldfunction = deprecate.function(function () {
|
||||
// all calls to function are deprecated
|
||||
}, 'oldfunction')
|
||||
```
|
||||
|
||||
### Conditionally deprecating a function call
|
||||
|
||||
This will display a deprecated message about "weirdfunction" being deprecated
|
||||
from "my-module" on STDERR when called with less than 2 arguments.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.weirdfunction = function () {
|
||||
if (arguments.length < 2) {
|
||||
// calls with 0 or 1 args are deprecated
|
||||
deprecate('weirdfunction args < 2')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When calling `deprecate` as a function, the warning is counted per call site
|
||||
within your own module, so you can display different deprecations depending
|
||||
on different situations and the users will still get all the warnings:
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.weirdfunction = function () {
|
||||
if (arguments.length < 2) {
|
||||
// calls with 0 or 1 args are deprecated
|
||||
deprecate('weirdfunction args < 2')
|
||||
} else if (typeof arguments[0] !== 'string') {
|
||||
// calls with non-string first argument are deprecated
|
||||
deprecate('weirdfunction non-string first arg')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Deprecating property access
|
||||
|
||||
This will display a deprecated message about "oldprop" being deprecated
|
||||
from "my-module" on STDERR when accessed. A deprecation will be displayed
|
||||
when setting the value and when getting the value.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.oldprop = 'something'
|
||||
|
||||
// message automatically derives from property name
|
||||
deprecate.property(exports, 'oldprop')
|
||||
|
||||
// explicit message
|
||||
deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/nodejs-depd/master?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/dougwilson/nodejs-depd/master
|
||||
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
|
||||
[node-image]: https://badgen.net/npm/node/depd
|
||||
[node-url]: https://nodejs.org/en/download/
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/depd
|
||||
[npm-url]: https://npmjs.org/package/depd
|
||||
[npm-version-image]: https://badgen.net/npm/v/depd
|
||||
[travis-image]: https://badgen.net/travis/dougwilson/nodejs-depd/master?label=linux
|
||||
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
|
||||
538
node_modules/morgan/node_modules/depd/index.js
generated
vendored
Normal file
538
node_modules/morgan/node_modules/depd/index.js
generated
vendored
Normal file
@@ -0,0 +1,538 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014-2018 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var relative = require('path').relative
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = depd
|
||||
|
||||
/**
|
||||
* Get the path to base files on.
|
||||
*/
|
||||
|
||||
var basePath = process.cwd()
|
||||
|
||||
/**
|
||||
* Determine if namespace is contained in the string.
|
||||
*/
|
||||
|
||||
function containsNamespace (str, namespace) {
|
||||
var vals = str.split(/[ ,]+/)
|
||||
var ns = String(namespace).toLowerCase()
|
||||
|
||||
for (var i = 0; i < vals.length; i++) {
|
||||
var val = vals[i]
|
||||
|
||||
// namespace contained
|
||||
if (val && (val === '*' || val.toLowerCase() === ns)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data descriptor to accessor descriptor.
|
||||
*/
|
||||
|
||||
function convertDataDescriptorToAccessor (obj, prop, message) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||
var value = descriptor.value
|
||||
|
||||
descriptor.get = function getter () { return value }
|
||||
|
||||
if (descriptor.writable) {
|
||||
descriptor.set = function setter (val) { return (value = val) }
|
||||
}
|
||||
|
||||
delete descriptor.value
|
||||
delete descriptor.writable
|
||||
|
||||
Object.defineProperty(obj, prop, descriptor)
|
||||
|
||||
return descriptor
|
||||
}
|
||||
|
||||
/**
|
||||
* Create arguments string to keep arity.
|
||||
*/
|
||||
|
||||
function createArgumentsString (arity) {
|
||||
var str = ''
|
||||
|
||||
for (var i = 0; i < arity; i++) {
|
||||
str += ', arg' + i
|
||||
}
|
||||
|
||||
return str.substr(2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stack string from stack.
|
||||
*/
|
||||
|
||||
function createStackString (stack) {
|
||||
var str = this.name + ': ' + this.namespace
|
||||
|
||||
if (this.message) {
|
||||
str += ' deprecated ' + this.message
|
||||
}
|
||||
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
str += '\n at ' + stack[i].toString()
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
/**
|
||||
* Create deprecate for namespace in caller.
|
||||
*/
|
||||
|
||||
function depd (namespace) {
|
||||
if (!namespace) {
|
||||
throw new TypeError('argument namespace is required')
|
||||
}
|
||||
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
var file = site[0]
|
||||
|
||||
function deprecate (message) {
|
||||
// call to self as log
|
||||
log.call(deprecate, message)
|
||||
}
|
||||
|
||||
deprecate._file = file
|
||||
deprecate._ignored = isignored(namespace)
|
||||
deprecate._namespace = namespace
|
||||
deprecate._traced = istraced(namespace)
|
||||
deprecate._warned = Object.create(null)
|
||||
|
||||
deprecate.function = wrapfunction
|
||||
deprecate.property = wrapproperty
|
||||
|
||||
return deprecate
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if event emitter has listeners of a given type.
|
||||
*
|
||||
* The way to do this check is done three different ways in Node.js >= 0.8
|
||||
* so this consolidates them into a minimal set using instance methods.
|
||||
*
|
||||
* @param {EventEmitter} emitter
|
||||
* @param {string} type
|
||||
* @returns {boolean}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function eehaslisteners (emitter, type) {
|
||||
var count = typeof emitter.listenerCount !== 'function'
|
||||
? emitter.listeners(type).length
|
||||
: emitter.listenerCount(type)
|
||||
|
||||
return count > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if namespace is ignored.
|
||||
*/
|
||||
|
||||
function isignored (namespace) {
|
||||
if (process.noDeprecation) {
|
||||
// --no-deprecation support
|
||||
return true
|
||||
}
|
||||
|
||||
var str = process.env.NO_DEPRECATION || ''
|
||||
|
||||
// namespace ignored
|
||||
return containsNamespace(str, namespace)
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if namespace is traced.
|
||||
*/
|
||||
|
||||
function istraced (namespace) {
|
||||
if (process.traceDeprecation) {
|
||||
// --trace-deprecation support
|
||||
return true
|
||||
}
|
||||
|
||||
var str = process.env.TRACE_DEPRECATION || ''
|
||||
|
||||
// namespace traced
|
||||
return containsNamespace(str, namespace)
|
||||
}
|
||||
|
||||
/**
|
||||
* Display deprecation message.
|
||||
*/
|
||||
|
||||
function log (message, site) {
|
||||
var haslisteners = eehaslisteners(process, 'deprecation')
|
||||
|
||||
// abort early if no destination
|
||||
if (!haslisteners && this._ignored) {
|
||||
return
|
||||
}
|
||||
|
||||
var caller
|
||||
var callFile
|
||||
var callSite
|
||||
var depSite
|
||||
var i = 0
|
||||
var seen = false
|
||||
var stack = getStack()
|
||||
var file = this._file
|
||||
|
||||
if (site) {
|
||||
// provided site
|
||||
depSite = site
|
||||
callSite = callSiteLocation(stack[1])
|
||||
callSite.name = depSite.name
|
||||
file = callSite[0]
|
||||
} else {
|
||||
// get call site
|
||||
i = 2
|
||||
depSite = callSiteLocation(stack[i])
|
||||
callSite = depSite
|
||||
}
|
||||
|
||||
// get caller of deprecated thing in relation to file
|
||||
for (; i < stack.length; i++) {
|
||||
caller = callSiteLocation(stack[i])
|
||||
callFile = caller[0]
|
||||
|
||||
if (callFile === file) {
|
||||
seen = true
|
||||
} else if (callFile === this._file) {
|
||||
file = this._file
|
||||
} else if (seen) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var key = caller
|
||||
? depSite.join(':') + '__' + caller.join(':')
|
||||
: undefined
|
||||
|
||||
if (key !== undefined && key in this._warned) {
|
||||
// already warned
|
||||
return
|
||||
}
|
||||
|
||||
this._warned[key] = true
|
||||
|
||||
// generate automatic message from call site
|
||||
var msg = message
|
||||
if (!msg) {
|
||||
msg = callSite === depSite || !callSite.name
|
||||
? defaultMessage(depSite)
|
||||
: defaultMessage(callSite)
|
||||
}
|
||||
|
||||
// emit deprecation if listeners exist
|
||||
if (haslisteners) {
|
||||
var err = DeprecationError(this._namespace, msg, stack.slice(i))
|
||||
process.emit('deprecation', err)
|
||||
return
|
||||
}
|
||||
|
||||
// format and write message
|
||||
var format = process.stderr.isTTY
|
||||
? formatColor
|
||||
: formatPlain
|
||||
var output = format.call(this, msg, caller, stack.slice(i))
|
||||
process.stderr.write(output + '\n', 'utf8')
|
||||
}
|
||||
|
||||
/**
|
||||
* Get call site location as array.
|
||||
*/
|
||||
|
||||
function callSiteLocation (callSite) {
|
||||
var file = callSite.getFileName() || '<anonymous>'
|
||||
var line = callSite.getLineNumber()
|
||||
var colm = callSite.getColumnNumber()
|
||||
|
||||
if (callSite.isEval()) {
|
||||
file = callSite.getEvalOrigin() + ', ' + file
|
||||
}
|
||||
|
||||
var site = [file, line, colm]
|
||||
|
||||
site.callSite = callSite
|
||||
site.name = callSite.getFunctionName()
|
||||
|
||||
return site
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a default message from the site.
|
||||
*/
|
||||
|
||||
function defaultMessage (site) {
|
||||
var callSite = site.callSite
|
||||
var funcName = site.name
|
||||
|
||||
// make useful anonymous name
|
||||
if (!funcName) {
|
||||
funcName = '<anonymous@' + formatLocation(site) + '>'
|
||||
}
|
||||
|
||||
var context = callSite.getThis()
|
||||
var typeName = context && callSite.getTypeName()
|
||||
|
||||
// ignore useless type name
|
||||
if (typeName === 'Object') {
|
||||
typeName = undefined
|
||||
}
|
||||
|
||||
// make useful type name
|
||||
if (typeName === 'Function') {
|
||||
typeName = context.name || typeName
|
||||
}
|
||||
|
||||
return typeName && callSite.getMethodName()
|
||||
? typeName + '.' + funcName
|
||||
: funcName
|
||||
}
|
||||
|
||||
/**
|
||||
* Format deprecation message without color.
|
||||
*/
|
||||
|
||||
function formatPlain (msg, caller, stack) {
|
||||
var timestamp = new Date().toUTCString()
|
||||
|
||||
var formatted = timestamp +
|
||||
' ' + this._namespace +
|
||||
' deprecated ' + msg
|
||||
|
||||
// add stack trace
|
||||
if (this._traced) {
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
formatted += '\n at ' + stack[i].toString()
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
if (caller) {
|
||||
formatted += ' at ' + formatLocation(caller)
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
/**
|
||||
* Format deprecation message with color.
|
||||
*/
|
||||
|
||||
function formatColor (msg, caller, stack) {
|
||||
var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' + // bold cyan
|
||||
' \x1b[33;1mdeprecated\x1b[22;39m' + // bold yellow
|
||||
' \x1b[0m' + msg + '\x1b[39m' // reset
|
||||
|
||||
// add stack trace
|
||||
if (this._traced) {
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m' // cyan
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
if (caller) {
|
||||
formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
/**
|
||||
* Format call site location.
|
||||
*/
|
||||
|
||||
function formatLocation (callSite) {
|
||||
return relative(basePath, callSite[0]) +
|
||||
':' + callSite[1] +
|
||||
':' + callSite[2]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stack as array of call sites.
|
||||
*/
|
||||
|
||||
function getStack () {
|
||||
var limit = Error.stackTraceLimit
|
||||
var obj = {}
|
||||
var prep = Error.prepareStackTrace
|
||||
|
||||
Error.prepareStackTrace = prepareObjectStackTrace
|
||||
Error.stackTraceLimit = Math.max(10, limit)
|
||||
|
||||
// capture the stack
|
||||
Error.captureStackTrace(obj)
|
||||
|
||||
// slice this function off the top
|
||||
var stack = obj.stack.slice(1)
|
||||
|
||||
Error.prepareStackTrace = prep
|
||||
Error.stackTraceLimit = limit
|
||||
|
||||
return stack
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture call site stack from v8.
|
||||
*/
|
||||
|
||||
function prepareObjectStackTrace (obj, stack) {
|
||||
return stack
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a wrapped function in a deprecation message.
|
||||
*/
|
||||
|
||||
function wrapfunction (fn, message) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument fn must be a function')
|
||||
}
|
||||
|
||||
var args = createArgumentsString(fn.length)
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
site.name = fn.name
|
||||
|
||||
// eslint-disable-next-line no-new-func
|
||||
var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',
|
||||
'"use strict"\n' +
|
||||
'return function (' + args + ') {' +
|
||||
'log.call(deprecate, message, site)\n' +
|
||||
'return fn.apply(this, arguments)\n' +
|
||||
'}')(fn, log, this, message, site)
|
||||
|
||||
return deprecatedfn
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap property in a deprecation message.
|
||||
*/
|
||||
|
||||
function wrapproperty (obj, prop, message) {
|
||||
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
throw new TypeError('argument obj must be object')
|
||||
}
|
||||
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||
|
||||
if (!descriptor) {
|
||||
throw new TypeError('must call property on owner object')
|
||||
}
|
||||
|
||||
if (!descriptor.configurable) {
|
||||
throw new TypeError('property must be configurable')
|
||||
}
|
||||
|
||||
var deprecate = this
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
// set site name
|
||||
site.name = prop
|
||||
|
||||
// convert data descriptor
|
||||
if ('value' in descriptor) {
|
||||
descriptor = convertDataDescriptorToAccessor(obj, prop, message)
|
||||
}
|
||||
|
||||
var get = descriptor.get
|
||||
var set = descriptor.set
|
||||
|
||||
// wrap getter
|
||||
if (typeof get === 'function') {
|
||||
descriptor.get = function getter () {
|
||||
log.call(deprecate, message, site)
|
||||
return get.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
// wrap setter
|
||||
if (typeof set === 'function') {
|
||||
descriptor.set = function setter () {
|
||||
log.call(deprecate, message, site)
|
||||
return set.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, prop, descriptor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DeprecationError for deprecation
|
||||
*/
|
||||
|
||||
function DeprecationError (namespace, message, stack) {
|
||||
var error = new Error()
|
||||
var stackString
|
||||
|
||||
Object.defineProperty(error, 'constructor', {
|
||||
value: DeprecationError
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'message', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: message,
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'name', {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: 'DeprecationError',
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'namespace', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: namespace,
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'stack', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
if (stackString !== undefined) {
|
||||
return stackString
|
||||
}
|
||||
|
||||
// prepare stack trace
|
||||
return (stackString = createStackString.call(this, stack))
|
||||
},
|
||||
set: function setter (val) {
|
||||
stackString = val
|
||||
}
|
||||
})
|
||||
|
||||
return error
|
||||
}
|
||||
77
node_modules/morgan/node_modules/depd/lib/browser/index.js
generated
vendored
Normal file
77
node_modules/morgan/node_modules/depd/lib/browser/index.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = depd
|
||||
|
||||
/**
|
||||
* Create deprecate for namespace in caller.
|
||||
*/
|
||||
|
||||
function depd (namespace) {
|
||||
if (!namespace) {
|
||||
throw new TypeError('argument namespace is required')
|
||||
}
|
||||
|
||||
function deprecate (message) {
|
||||
// no-op in browser
|
||||
}
|
||||
|
||||
deprecate._file = undefined
|
||||
deprecate._ignored = true
|
||||
deprecate._namespace = namespace
|
||||
deprecate._traced = false
|
||||
deprecate._warned = Object.create(null)
|
||||
|
||||
deprecate.function = wrapfunction
|
||||
deprecate.property = wrapproperty
|
||||
|
||||
return deprecate
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a wrapped function in a deprecation message.
|
||||
*
|
||||
* This is a no-op version of the wrapper, which does nothing but call
|
||||
* validation.
|
||||
*/
|
||||
|
||||
function wrapfunction (fn, message) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument fn must be a function')
|
||||
}
|
||||
|
||||
return fn
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap property in a deprecation message.
|
||||
*
|
||||
* This is a no-op version of the wrapper, which does nothing but call
|
||||
* validation.
|
||||
*/
|
||||
|
||||
function wrapproperty (obj, prop, message) {
|
||||
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
throw new TypeError('argument obj must be object')
|
||||
}
|
||||
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||
|
||||
if (!descriptor) {
|
||||
throw new TypeError('must call property on owner object')
|
||||
}
|
||||
|
||||
if (!descriptor.configurable) {
|
||||
throw new TypeError('property must be configurable')
|
||||
}
|
||||
}
|
||||
80
node_modules/morgan/node_modules/depd/package.json
generated
vendored
Normal file
80
node_modules/morgan/node_modules/depd/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"_from": "depd@~2.0.0",
|
||||
"_id": "depd@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
|
||||
"_location": "/morgan/depd",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "depd@~2.0.0",
|
||||
"name": "depd",
|
||||
"escapedName": "depd",
|
||||
"rawSpec": "~2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/morgan"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
"_shasum": "b696163cc757560d09cf22cc8fad1571b79e76df",
|
||||
"_spec": "depd@~2.0.0",
|
||||
"_where": "/home/pablinux/Projects/Node/app_sigma/node_modules/morgan",
|
||||
"author": {
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"browser": "lib/browser/index.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dougwilson/nodejs-depd/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Deprecate all the things",
|
||||
"devDependencies": {
|
||||
"beautify-benchmark": "0.2.4",
|
||||
"benchmark": "2.1.4",
|
||||
"eslint": "5.7.0",
|
||||
"eslint-config-standard": "12.0.0",
|
||||
"eslint-plugin-import": "2.14.0",
|
||||
"eslint-plugin-markdown": "1.0.0-beta.7",
|
||||
"eslint-plugin-node": "7.0.1",
|
||||
"eslint-plugin-promise": "4.0.1",
|
||||
"eslint-plugin-standard": "4.0.0",
|
||||
"istanbul": "0.4.5",
|
||||
"mocha": "5.2.0",
|
||||
"safe-buffer": "5.1.2",
|
||||
"uid-safe": "2.1.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"History.md",
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"Readme.md"
|
||||
],
|
||||
"homepage": "https://github.com/dougwilson/nodejs-depd#readme",
|
||||
"keywords": [
|
||||
"deprecate",
|
||||
"deprecated"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "depd",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dougwilson/nodejs-depd.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/index.js",
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"test": "mocha --reporter spec --bail test/",
|
||||
"test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
|
||||
"test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
||||
92
node_modules/morgan/package.json
generated
vendored
Normal file
92
node_modules/morgan/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"_from": "morgan",
|
||||
"_id": "morgan@1.10.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==",
|
||||
"_location": "/morgan",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "morgan",
|
||||
"name": "morgan",
|
||||
"escapedName": "morgan",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz",
|
||||
"_shasum": "091778abc1fc47cd3509824653dae1faab6b17d7",
|
||||
"_spec": "morgan",
|
||||
"_where": "/home/pablinux/Projects/Node/app_sigma",
|
||||
"bugs": {
|
||||
"url": "https://github.com/expressjs/morgan/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"basic-auth": "~2.0.1",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~2.0.0",
|
||||
"on-finished": "~2.3.0",
|
||||
"on-headers": "~1.0.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "HTTP request logger middleware for node.js",
|
||||
"devDependencies": {
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-standard": "14.1.0",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"eslint-plugin-markdown": "1.0.2",
|
||||
"eslint-plugin-node": "9.2.0",
|
||||
"eslint-plugin-promise": "4.2.1",
|
||||
"eslint-plugin-standard": "4.0.1",
|
||||
"mocha": "7.1.1",
|
||||
"nyc": "15.0.0",
|
||||
"split": "1.0.1",
|
||||
"supertest": "4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/expressjs/morgan#readme",
|
||||
"keywords": [
|
||||
"express",
|
||||
"http",
|
||||
"logger",
|
||||
"middleware"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "morgan",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/expressjs/morgan.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"test": "mocha --check-leaks --reporter spec --bail",
|
||||
"test-ci": "nyc --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
},
|
||||
"version": "1.10.0"
|
||||
}
|
||||
Reference in New Issue
Block a user