mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 18:32:50 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
295
node_modules/send/HISTORY.md
generated
vendored
Normal file
295
node_modules/send/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
0.13.0 / 2015-06-16
|
||||
===================
|
||||
|
||||
* Allow Node.js HTTP server to set `Date` response header
|
||||
* Fix incorrectly removing `Content-Location` on 304 response
|
||||
* Improve the default redirect response headers
|
||||
* Send appropriate headers on default error response
|
||||
* Use `http-errors` for standard emitted errors
|
||||
* Use `statuses` instead of `http` module for status messages
|
||||
* deps: escape-html@1.0.2
|
||||
* deps: etag@~1.7.0
|
||||
- Improve stat performance by removing hashing
|
||||
* deps: fresh@0.3.0
|
||||
- Add weak `ETag` matching support
|
||||
* 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
|
||||
* perf: enable strict mode
|
||||
* perf: remove unnecessary array allocations
|
||||
|
||||
0.12.3 / 2015-05-13
|
||||
===================
|
||||
|
||||
* deps: debug@~2.2.0
|
||||
- deps: ms@0.7.1
|
||||
* deps: depd@~1.0.1
|
||||
* deps: etag@~1.6.0
|
||||
- Improve support for JXcore
|
||||
- Support "fake" stats objects in environments without `fs`
|
||||
* deps: ms@0.7.1
|
||||
- Prevent extraordinarily long inputs
|
||||
* deps: on-finished@~2.2.1
|
||||
|
||||
0.12.2 / 2015-03-13
|
||||
===================
|
||||
|
||||
* Throw errors early for invalid `extensions` or `index` options
|
||||
* deps: debug@~2.1.3
|
||||
- Fix high intensity foreground color for bold
|
||||
- deps: ms@0.7.0
|
||||
|
||||
0.12.1 / 2015-02-17
|
||||
===================
|
||||
|
||||
* Fix regression sending zero-length files
|
||||
|
||||
0.12.0 / 2015-02-16
|
||||
===================
|
||||
|
||||
* Always read the stat size from the file
|
||||
* Fix mutating passed-in `options`
|
||||
* deps: mime@1.3.4
|
||||
|
||||
0.11.1 / 2015-01-20
|
||||
===================
|
||||
|
||||
* Fix `root` path disclosure
|
||||
|
||||
0.11.0 / 2015-01-05
|
||||
===================
|
||||
|
||||
* deps: debug@~2.1.1
|
||||
* deps: etag@~1.5.1
|
||||
- deps: crc@3.2.1
|
||||
* deps: ms@0.7.0
|
||||
- Add `milliseconds`
|
||||
- Add `msecs`
|
||||
- Add `secs`
|
||||
- Add `mins`
|
||||
- Add `hrs`
|
||||
- Add `yrs`
|
||||
* deps: on-finished@~2.2.0
|
||||
|
||||
0.10.1 / 2014-10-22
|
||||
===================
|
||||
|
||||
* deps: on-finished@~2.1.1
|
||||
- Fix handling of pipelined requests
|
||||
|
||||
0.10.0 / 2014-10-15
|
||||
===================
|
||||
|
||||
* deps: debug@~2.1.0
|
||||
- Implement `DEBUG_FD` env variable support
|
||||
* deps: depd@~1.0.0
|
||||
* deps: etag@~1.5.0
|
||||
- Improve string performance
|
||||
- Slightly improve speed for weak ETags over 1KB
|
||||
|
||||
0.9.3 / 2014-09-24
|
||||
==================
|
||||
|
||||
* deps: etag@~1.4.0
|
||||
- Support "fake" stats objects
|
||||
|
||||
0.9.2 / 2014-09-15
|
||||
==================
|
||||
|
||||
* deps: depd@0.4.5
|
||||
* deps: etag@~1.3.1
|
||||
* deps: range-parser@~1.0.2
|
||||
|
||||
0.9.1 / 2014-09-07
|
||||
==================
|
||||
|
||||
* deps: fresh@0.2.4
|
||||
|
||||
0.9.0 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Add `lastModified` option
|
||||
* Use `etag` to generate `ETag` header
|
||||
* deps: debug@~2.0.0
|
||||
|
||||
0.8.5 / 2014-09-04
|
||||
==================
|
||||
|
||||
* Fix malicious path detection for empty string path
|
||||
|
||||
0.8.4 / 2014-09-04
|
||||
==================
|
||||
|
||||
* Fix a path traversal issue when using `root`
|
||||
|
||||
0.8.3 / 2014-08-16
|
||||
==================
|
||||
|
||||
* deps: destroy@1.0.3
|
||||
- renamed from dethroy
|
||||
* deps: on-finished@2.1.0
|
||||
|
||||
0.8.2 / 2014-08-14
|
||||
==================
|
||||
|
||||
* Work around `fd` leak in Node.js 0.10 for `fs.ReadStream`
|
||||
* deps: dethroy@1.0.2
|
||||
|
||||
0.8.1 / 2014-08-05
|
||||
==================
|
||||
|
||||
* Fix `extensions` behavior when file already has extension
|
||||
|
||||
0.8.0 / 2014-08-05
|
||||
==================
|
||||
|
||||
* Add `extensions` option
|
||||
|
||||
0.7.4 / 2014-08-04
|
||||
==================
|
||||
|
||||
* Fix serving index files without root dir
|
||||
|
||||
0.7.3 / 2014-07-29
|
||||
==================
|
||||
|
||||
* Fix incorrect 403 on Windows and Node.js 0.11
|
||||
|
||||
0.7.2 / 2014-07-27
|
||||
==================
|
||||
|
||||
* deps: depd@0.4.4
|
||||
- Work-around v8 generating empty stack traces
|
||||
|
||||
0.7.1 / 2014-07-26
|
||||
==================
|
||||
|
||||
* deps: depd@0.4.3
|
||||
- Fix exception when global `Error.stackTraceLimit` is too low
|
||||
|
||||
0.7.0 / 2014-07-20
|
||||
==================
|
||||
|
||||
* Deprecate `hidden` option; use `dotfiles` option
|
||||
* Add `dotfiles` option
|
||||
* deps: debug@1.0.4
|
||||
* deps: depd@0.4.2
|
||||
- Add `TRACE_DEPRECATION` environment variable
|
||||
- Remove non-standard grey color from color output
|
||||
- Support `--no-deprecation` argument
|
||||
- Support `--trace-deprecation` argument
|
||||
|
||||
0.6.0 / 2014-07-11
|
||||
==================
|
||||
|
||||
* Deprecate `from` option; use `root` option
|
||||
* Deprecate `send.etag()` -- use `etag` in `options`
|
||||
* Deprecate `send.hidden()` -- use `hidden` in `options`
|
||||
* Deprecate `send.index()` -- use `index` in `options`
|
||||
* Deprecate `send.maxage()` -- use `maxAge` in `options`
|
||||
* Deprecate `send.root()` -- use `root` in `options`
|
||||
* Cap `maxAge` value to 1 year
|
||||
* deps: debug@1.0.3
|
||||
- Add support for multiple wildcards in namespaces
|
||||
|
||||
0.5.0 / 2014-06-28
|
||||
==================
|
||||
|
||||
* Accept string for `maxAge` (converted by `ms`)
|
||||
* Add `headers` event
|
||||
* Include link in default redirect response
|
||||
* Use `EventEmitter.listenerCount` to count listeners
|
||||
|
||||
0.4.3 / 2014-06-11
|
||||
==================
|
||||
|
||||
* Do not throw un-catchable error on file open race condition
|
||||
* Use `escape-html` for HTML escaping
|
||||
* deps: debug@1.0.2
|
||||
- fix some debugging output colors on node.js 0.8
|
||||
* deps: finished@1.2.2
|
||||
* deps: fresh@0.2.2
|
||||
|
||||
0.4.2 / 2014-06-09
|
||||
==================
|
||||
|
||||
* fix "event emitter leak" warnings
|
||||
* deps: debug@1.0.1
|
||||
* deps: finished@1.2.1
|
||||
|
||||
0.4.1 / 2014-06-02
|
||||
==================
|
||||
|
||||
* Send `max-age` in `Cache-Control` in correct format
|
||||
|
||||
0.4.0 / 2014-05-27
|
||||
==================
|
||||
|
||||
* Calculate ETag with md5 for reduced collisions
|
||||
* Fix wrong behavior when index file matches directory
|
||||
* Ignore stream errors after request ends
|
||||
- Goodbye `EBADF, read`
|
||||
* Skip directories in index file search
|
||||
* deps: debug@0.8.1
|
||||
|
||||
0.3.0 / 2014-04-24
|
||||
==================
|
||||
|
||||
* Fix sending files with dots without root set
|
||||
* Coerce option types
|
||||
* Accept API options in options object
|
||||
* Set etags to "weak"
|
||||
* Include file path in etag
|
||||
* Make "Can't set headers after they are sent." catchable
|
||||
* Send full entity-body for multi range requests
|
||||
* Default directory access to 403 when index disabled
|
||||
* Support multiple index paths
|
||||
* Support "If-Range" header
|
||||
* Control whether to generate etags
|
||||
* deps: mime@1.2.11
|
||||
|
||||
0.2.0 / 2014-01-29
|
||||
==================
|
||||
|
||||
* update range-parser and fresh
|
||||
|
||||
0.1.4 / 2013-08-11
|
||||
==================
|
||||
|
||||
* update fresh
|
||||
|
||||
0.1.3 / 2013-07-08
|
||||
==================
|
||||
|
||||
* Revert "Fix fd leak"
|
||||
|
||||
0.1.2 / 2013-07-03
|
||||
==================
|
||||
|
||||
* Fix fd leak
|
||||
|
||||
0.1.0 / 2012-08-25
|
||||
==================
|
||||
|
||||
* add options parameter to send() that is passed to fs.createReadStream() [kanongil]
|
||||
|
||||
0.0.4 / 2012-08-16
|
||||
==================
|
||||
|
||||
* allow custom "Accept-Ranges" definition
|
||||
|
||||
0.0.3 / 2012-07-16
|
||||
==================
|
||||
|
||||
* fix normalization of the root directory. Closes #3
|
||||
|
||||
0.0.2 / 2012-07-09
|
||||
==================
|
||||
|
||||
* add passing of req explicitly for now (YUCK)
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
23
node_modules/send/LICENSE
generated
vendored
Normal file
23
node_modules/send/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 TJ Holowaychuk
|
||||
Copyright (c) 2014-2015 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.
|
||||
195
node_modules/send/README.md
generated
vendored
Normal file
195
node_modules/send/README.md
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
# send
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Linux Build][travis-image]][travis-url]
|
||||
[![Windows Build][appveyor-image]][appveyor-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
[![Gratipay][gratipay-image]][gratipay-url]
|
||||
|
||||
Send is a library for streaming files from the file system as a http response
|
||||
supporting partial responses (Ranges), conditional-GET negotiation, high test
|
||||
coverage, and granular events which may be leveraged to take appropriate actions
|
||||
in your application or framework.
|
||||
|
||||
Looking to serve up entire folders mapped to URLs? Try [serve-static](https://www.npmjs.org/package/serve-static).
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install send
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var send = require('send')
|
||||
```
|
||||
|
||||
### send(req, path, [options])
|
||||
|
||||
Create a new `SendStream` for the given path to send to a `res`. The `req` is
|
||||
the Node.js HTTP request and the `path` is a urlencoded path to send (urlencoded,
|
||||
not the actual file-system path).
|
||||
|
||||
#### Options
|
||||
|
||||
##### dotfiles
|
||||
|
||||
Set how "dotfiles" are treated when encountered. A dotfile is a file
|
||||
or directory that begins with a dot ("."). Note this check is done on
|
||||
the path itself without checking if the path actually exists on the
|
||||
disk. If `root` is specified, only the dotfiles above the root are
|
||||
checked (i.e. the root itself can be within a dotfile when when set
|
||||
to "deny").
|
||||
|
||||
- `'allow'` No special treatment for dotfiles.
|
||||
- `'deny'` Send a 403 for any request for a dotfile.
|
||||
- `'ignore'` Pretend like the dotfile does not exist and 404.
|
||||
|
||||
The default value is _similar_ to `'ignore'`, with the exception that
|
||||
this default will not ignore the files within a directory that begins
|
||||
with a dot, for backward-compatibility.
|
||||
|
||||
##### etag
|
||||
|
||||
Enable or disable etag generation, defaults to true.
|
||||
|
||||
##### extensions
|
||||
|
||||
If a given file doesn't exist, try appending one of the given extensions,
|
||||
in the given order. By default, this is disabled (set to `false`). An
|
||||
example value that will serve extension-less HTML files: `['html', 'htm']`.
|
||||
This is skipped if the requested file already has an extension.
|
||||
|
||||
##### index
|
||||
|
||||
By default send supports "index.html" files, to disable this
|
||||
set `false` or to supply a new index pass a string or an array
|
||||
in preferred order.
|
||||
|
||||
##### lastModified
|
||||
|
||||
Enable or disable `Last-Modified` header, defaults to true. Uses the file
|
||||
system's last modified value.
|
||||
|
||||
##### maxAge
|
||||
|
||||
Provide a max-age in milliseconds for http caching, defaults to 0.
|
||||
This can also be a string accepted by the
|
||||
[ms](https://www.npmjs.org/package/ms#readme) module.
|
||||
|
||||
##### root
|
||||
|
||||
Serve files relative to `path`.
|
||||
|
||||
### Events
|
||||
|
||||
The `SendStream` is an event emitter and will emit the following events:
|
||||
|
||||
- `error` an error occurred `(err)`
|
||||
- `directory` a directory was requested
|
||||
- `file` a file was requested `(path, stat)`
|
||||
- `headers` the headers are about to be set on a file `(res, path, stat)`
|
||||
- `stream` file streaming has started `(stream)`
|
||||
- `end` streaming has completed
|
||||
|
||||
### .pipe
|
||||
|
||||
The `pipe` method is used to pipe the response into the Node.js HTTP response
|
||||
object, typically `send(req, path, options).pipe(res)`.
|
||||
|
||||
## Error-handling
|
||||
|
||||
By default when no `error` listeners are present an automatic response will be
|
||||
made, otherwise you have full control over the response, aka you may show a 5xx
|
||||
page etc.
|
||||
|
||||
## Caching
|
||||
|
||||
It does _not_ perform internal caching, you should use a reverse proxy cache
|
||||
such as Varnish for this, or those fancy things called CDNs. If your
|
||||
application is small enough that it would benefit from single-node memory
|
||||
caching, it's small enough that it does not need caching at all ;).
|
||||
|
||||
## Debugging
|
||||
|
||||
To enable `debug()` instrumentation output export __DEBUG__:
|
||||
|
||||
```
|
||||
$ DEBUG=send node app
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
||||
```
|
||||
$ npm install
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Small example
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var send = require('send');
|
||||
|
||||
var app = http.createServer(function(req, res){
|
||||
send(req, req.url).pipe(res);
|
||||
}).listen(3000);
|
||||
```
|
||||
|
||||
Serving from a root directory with custom error-handling:
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var send = require('send');
|
||||
var url = require('url');
|
||||
|
||||
var app = http.createServer(function(req, res){
|
||||
// your custom error-handling logic:
|
||||
function error(err) {
|
||||
res.statusCode = err.status || 500;
|
||||
res.end(err.message);
|
||||
}
|
||||
|
||||
// your custom headers
|
||||
function headers(res, path, stat) {
|
||||
// serve all files for download
|
||||
res.setHeader('Content-Disposition', 'attachment');
|
||||
}
|
||||
|
||||
// your custom directory handling logic:
|
||||
function redirect() {
|
||||
res.statusCode = 301;
|
||||
res.setHeader('Location', req.url + '/');
|
||||
res.end('Redirecting to ' + req.url + '/');
|
||||
}
|
||||
|
||||
// transfer arbitrary files from within
|
||||
// /www/example.com/public/*
|
||||
send(req, url.parse(req.url).pathname, {root: '/www/example.com/public'})
|
||||
.on('error', error)
|
||||
.on('directory', redirect)
|
||||
.on('headers', headers)
|
||||
.pipe(res);
|
||||
}).listen(3000);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/send.svg
|
||||
[npm-url]: https://npmjs.org/package/send
|
||||
[travis-image]: https://img.shields.io/travis/pillarjs/send/master.svg?label=linux
|
||||
[travis-url]: https://travis-ci.org/pillarjs/send
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/send/master.svg?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/send
|
||||
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/send/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/pillarjs/send?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/send.svg
|
||||
[downloads-url]: https://npmjs.org/package/send
|
||||
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
|
||||
[gratipay-url]: https://www.gratipay.com/dougwilson/
|
||||
820
node_modules/send/index.js
generated
vendored
Normal file
820
node_modules/send/index.js
generated
vendored
Normal file
@@ -0,0 +1,820 @@
|
||||
/*!
|
||||
* send
|
||||
* Copyright(c) 2012 TJ Holowaychuk
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var createError = require('http-errors')
|
||||
var debug = require('debug')('send')
|
||||
var deprecate = require('depd')('send')
|
||||
var destroy = require('destroy')
|
||||
var escapeHtml = require('escape-html')
|
||||
, parseRange = require('range-parser')
|
||||
, Stream = require('stream')
|
||||
, mime = require('mime')
|
||||
, fresh = require('fresh')
|
||||
, path = require('path')
|
||||
, fs = require('fs')
|
||||
, normalize = path.normalize
|
||||
, join = path.join
|
||||
var etag = require('etag')
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var ms = require('ms');
|
||||
var onFinished = require('on-finished')
|
||||
var statuses = require('statuses')
|
||||
|
||||
/**
|
||||
* Variables.
|
||||
*/
|
||||
var extname = path.extname
|
||||
var maxMaxAge = 60 * 60 * 24 * 365 * 1000; // 1 year
|
||||
var resolve = path.resolve
|
||||
var sep = path.sep
|
||||
var toString = Object.prototype.toString
|
||||
var upPathRegexp = /(?:^|[\\\/])\.\.(?:[\\\/]|$)/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = send
|
||||
module.exports.mime = mime
|
||||
|
||||
/**
|
||||
* Shim EventEmitter.listenerCount for node.js < 0.10
|
||||
*/
|
||||
|
||||
/* istanbul ignore next */
|
||||
var listenerCount = EventEmitter.listenerCount
|
||||
|| function(emitter, type){ return emitter.listeners(type).length; };
|
||||
|
||||
/**
|
||||
* Return a `SendStream` for `req` and `path`.
|
||||
*
|
||||
* @param {object} req
|
||||
* @param {string} path
|
||||
* @param {object} [options]
|
||||
* @return {SendStream}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function send(req, path, options) {
|
||||
return new SendStream(req, path, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a `SendStream` with the given `path`.
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {String} path
|
||||
* @param {object} [options]
|
||||
* @private
|
||||
*/
|
||||
|
||||
function SendStream(req, path, options) {
|
||||
var opts = options || {}
|
||||
|
||||
this.options = opts
|
||||
this.path = path
|
||||
this.req = req
|
||||
|
||||
this._etag = opts.etag !== undefined
|
||||
? Boolean(opts.etag)
|
||||
: true
|
||||
|
||||
this._dotfiles = opts.dotfiles !== undefined
|
||||
? opts.dotfiles
|
||||
: 'ignore'
|
||||
|
||||
if (this._dotfiles !== 'ignore' && this._dotfiles !== 'allow' && this._dotfiles !== 'deny') {
|
||||
throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"')
|
||||
}
|
||||
|
||||
this._hidden = Boolean(opts.hidden)
|
||||
|
||||
if (opts.hidden !== undefined) {
|
||||
deprecate('hidden: use dotfiles: \'' + (this._hidden ? 'allow' : 'ignore') + '\' instead')
|
||||
}
|
||||
|
||||
// legacy support
|
||||
if (opts.dotfiles === undefined) {
|
||||
this._dotfiles = undefined
|
||||
}
|
||||
|
||||
this._extensions = opts.extensions !== undefined
|
||||
? normalizeList(opts.extensions, 'extensions option')
|
||||
: []
|
||||
|
||||
this._index = opts.index !== undefined
|
||||
? normalizeList(opts.index, 'index option')
|
||||
: ['index.html']
|
||||
|
||||
this._lastModified = opts.lastModified !== undefined
|
||||
? Boolean(opts.lastModified)
|
||||
: true
|
||||
|
||||
this._maxage = opts.maxAge || opts.maxage
|
||||
this._maxage = typeof this._maxage === 'string'
|
||||
? ms(this._maxage)
|
||||
: Number(this._maxage)
|
||||
this._maxage = !isNaN(this._maxage)
|
||||
? Math.min(Math.max(0, this._maxage), maxMaxAge)
|
||||
: 0
|
||||
|
||||
this._root = opts.root
|
||||
? resolve(opts.root)
|
||||
: null
|
||||
|
||||
if (!this._root && opts.from) {
|
||||
this.from(opts.from)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherits from `Stream.prototype`.
|
||||
*/
|
||||
|
||||
SendStream.prototype.__proto__ = Stream.prototype;
|
||||
|
||||
/**
|
||||
* Enable or disable etag generation.
|
||||
*
|
||||
* @param {Boolean} val
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.etag = deprecate.function(function etag(val) {
|
||||
val = Boolean(val);
|
||||
debug('etag %s', val);
|
||||
this._etag = val;
|
||||
return this;
|
||||
}, 'send.etag: pass etag as option');
|
||||
|
||||
/**
|
||||
* Enable or disable "hidden" (dot) files.
|
||||
*
|
||||
* @param {Boolean} path
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.hidden = deprecate.function(function hidden(val) {
|
||||
val = Boolean(val);
|
||||
debug('hidden %s', val);
|
||||
this._hidden = val;
|
||||
this._dotfiles = undefined
|
||||
return this;
|
||||
}, 'send.hidden: use dotfiles option');
|
||||
|
||||
/**
|
||||
* Set index `paths`, set to a falsy
|
||||
* value to disable index support.
|
||||
*
|
||||
* @param {String|Boolean|Array} paths
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.index = deprecate.function(function index(paths) {
|
||||
var index = !paths ? [] : normalizeList(paths, 'paths argument');
|
||||
debug('index %o', paths);
|
||||
this._index = index;
|
||||
return this;
|
||||
}, 'send.index: pass index as option');
|
||||
|
||||
/**
|
||||
* Set root `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.root = function(path){
|
||||
path = String(path);
|
||||
this._root = resolve(path)
|
||||
return this;
|
||||
};
|
||||
|
||||
SendStream.prototype.from = deprecate.function(SendStream.prototype.root,
|
||||
'send.from: pass root as option');
|
||||
|
||||
SendStream.prototype.root = deprecate.function(SendStream.prototype.root,
|
||||
'send.root: pass root as option');
|
||||
|
||||
/**
|
||||
* Set max-age to `maxAge`.
|
||||
*
|
||||
* @param {Number} maxAge
|
||||
* @return {SendStream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.maxage = deprecate.function(function maxage(maxAge) {
|
||||
maxAge = typeof maxAge === 'string'
|
||||
? ms(maxAge)
|
||||
: Number(maxAge);
|
||||
if (isNaN(maxAge)) maxAge = 0;
|
||||
if (Infinity == maxAge) maxAge = 60 * 60 * 24 * 365 * 1000;
|
||||
debug('max-age %d', maxAge);
|
||||
this._maxage = maxAge;
|
||||
return this;
|
||||
}, 'send.maxage: pass maxAge as option');
|
||||
|
||||
/**
|
||||
* Emit error with `status`.
|
||||
*
|
||||
* @param {number} status
|
||||
* @param {Error} [error]
|
||||
* @private
|
||||
*/
|
||||
|
||||
SendStream.prototype.error = function error(status, error) {
|
||||
// emit if listeners instead of responding
|
||||
if (listenerCount(this, 'error') !== 0) {
|
||||
return this.emit('error', createError(error, status, {
|
||||
expose: false
|
||||
}))
|
||||
}
|
||||
|
||||
var res = this.res
|
||||
var msg = statuses[status]
|
||||
|
||||
// wipe all existing headers
|
||||
res._headers = null
|
||||
|
||||
// send basic response
|
||||
res.statusCode = status
|
||||
res.setHeader('Content-Type', 'text/plain; charset=UTF-8')
|
||||
res.setHeader('Content-Length', Buffer.byteLength(msg))
|
||||
res.setHeader('X-Content-Type-Options', 'nosniff')
|
||||
res.end(msg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the pathname ends with "/".
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.hasTrailingSlash = function(){
|
||||
return '/' == this.path[this.path.length - 1];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this is a conditional GET request.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isConditionalGET = function(){
|
||||
return this.req.headers['if-none-match']
|
||||
|| this.req.headers['if-modified-since'];
|
||||
};
|
||||
|
||||
/**
|
||||
* Strip content-* header fields.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
SendStream.prototype.removeContentHeaderFields = function removeContentHeaderFields() {
|
||||
var res = this.res
|
||||
var headers = Object.keys(res._headers || {})
|
||||
|
||||
for (var i = 0; i < headers.length; i++) {
|
||||
var header = headers[i]
|
||||
if (header.substr(0, 8) === 'content-' && header !== 'content-location') {
|
||||
res.removeHeader(header)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with 304 not modified.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.notModified = function(){
|
||||
var res = this.res;
|
||||
debug('not modified');
|
||||
this.removeContentHeaderFields();
|
||||
res.statusCode = 304;
|
||||
res.end();
|
||||
};
|
||||
|
||||
/**
|
||||
* Raise error that headers already sent.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.headersAlreadySent = function headersAlreadySent(){
|
||||
var err = new Error('Can\'t set headers after they are sent.');
|
||||
debug('headers already sent');
|
||||
this.error(500, err);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the request is cacheable, aka
|
||||
* responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}).
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isCachable = function(){
|
||||
var res = this.res;
|
||||
return (res.statusCode >= 200 && res.statusCode < 300) || 304 == res.statusCode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle stat() error.
|
||||
*
|
||||
* @param {Error} error
|
||||
* @private
|
||||
*/
|
||||
|
||||
SendStream.prototype.onStatError = function onStatError(error) {
|
||||
switch (error.code) {
|
||||
case 'ENAMETOOLONG':
|
||||
case 'ENOENT':
|
||||
case 'ENOTDIR':
|
||||
this.error(404, error)
|
||||
break
|
||||
default:
|
||||
this.error(500, error)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the cache is fresh.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isFresh = function(){
|
||||
return fresh(this.req.headers, this.res._headers);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the range is fresh.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.isRangeFresh = function isRangeFresh(){
|
||||
var ifRange = this.req.headers['if-range'];
|
||||
|
||||
if (!ifRange) return true;
|
||||
|
||||
return ~ifRange.indexOf('"')
|
||||
? ~ifRange.indexOf(this.res._headers['etag'])
|
||||
: Date.parse(this.res._headers['last-modified']) <= Date.parse(ifRange);
|
||||
};
|
||||
|
||||
/**
|
||||
* Redirect to path.
|
||||
*
|
||||
* @param {string} path
|
||||
* @private
|
||||
*/
|
||||
|
||||
SendStream.prototype.redirect = function redirect(path) {
|
||||
if (listenerCount(this, 'directory') !== 0) {
|
||||
this.emit('directory')
|
||||
return
|
||||
}
|
||||
|
||||
if (this.hasTrailingSlash()) {
|
||||
this.error(403)
|
||||
return
|
||||
}
|
||||
|
||||
var loc = path + '/'
|
||||
var msg = 'Redirecting to <a href="' + escapeHtml(loc) + '">' + escapeHtml(loc) + '</a>\n'
|
||||
var res = this.res
|
||||
|
||||
// redirect
|
||||
res.statusCode = 301
|
||||
res.setHeader('Content-Type', 'text/html; charset=UTF-8')
|
||||
res.setHeader('Content-Length', Buffer.byteLength(msg))
|
||||
res.setHeader('X-Content-Type-Options', 'nosniff')
|
||||
res.setHeader('Location', loc)
|
||||
res.end(msg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Pipe to `res.
|
||||
*
|
||||
* @param {Stream} res
|
||||
* @return {Stream} res
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.pipe = function(res){
|
||||
var self = this
|
||||
, args = arguments
|
||||
, root = this._root;
|
||||
|
||||
// references
|
||||
this.res = res;
|
||||
|
||||
// decode the path
|
||||
var path = decode(this.path)
|
||||
if (path === -1) return this.error(400)
|
||||
|
||||
// null byte(s)
|
||||
if (~path.indexOf('\0')) return this.error(400);
|
||||
|
||||
var parts
|
||||
if (root !== null) {
|
||||
// malicious path
|
||||
if (upPathRegexp.test(normalize('.' + sep + path))) {
|
||||
debug('malicious path "%s"', path)
|
||||
return this.error(403)
|
||||
}
|
||||
|
||||
// join / normalize from optional root dir
|
||||
path = normalize(join(root, path))
|
||||
root = normalize(root + sep)
|
||||
|
||||
// explode path parts
|
||||
parts = path.substr(root.length).split(sep)
|
||||
} else {
|
||||
// ".." is malicious without "root"
|
||||
if (upPathRegexp.test(path)) {
|
||||
debug('malicious path "%s"', path)
|
||||
return this.error(403)
|
||||
}
|
||||
|
||||
// explode path parts
|
||||
parts = normalize(path).split(sep)
|
||||
|
||||
// resolve the path
|
||||
path = resolve(path)
|
||||
}
|
||||
|
||||
// dotfile handling
|
||||
if (containsDotFile(parts)) {
|
||||
var access = this._dotfiles
|
||||
|
||||
// legacy support
|
||||
if (access === undefined) {
|
||||
access = parts[parts.length - 1][0] === '.'
|
||||
? (this._hidden ? 'allow' : 'ignore')
|
||||
: 'allow'
|
||||
}
|
||||
|
||||
debug('%s dotfile "%s"', access, path)
|
||||
switch (access) {
|
||||
case 'allow':
|
||||
break
|
||||
case 'deny':
|
||||
return this.error(403)
|
||||
case 'ignore':
|
||||
default:
|
||||
return this.error(404)
|
||||
}
|
||||
}
|
||||
|
||||
// index file support
|
||||
if (this._index.length && this.path[this.path.length - 1] === '/') {
|
||||
this.sendIndex(path);
|
||||
return res;
|
||||
}
|
||||
|
||||
this.sendFile(path);
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transfer `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SendStream.prototype.send = function(path, stat){
|
||||
var len = stat.size;
|
||||
var options = this.options
|
||||
var opts = {}
|
||||
var res = this.res;
|
||||
var req = this.req;
|
||||
var ranges = req.headers.range;
|
||||
var offset = options.start || 0;
|
||||
|
||||
if (res._header) {
|
||||
// impossible to send now
|
||||
return this.headersAlreadySent();
|
||||
}
|
||||
|
||||
debug('pipe "%s"', path)
|
||||
|
||||
// set header fields
|
||||
this.setHeader(path, stat);
|
||||
|
||||
// set content-type
|
||||
this.type(path);
|
||||
|
||||
// conditional GET support
|
||||
if (this.isConditionalGET()
|
||||
&& this.isCachable()
|
||||
&& this.isFresh()) {
|
||||
return this.notModified();
|
||||
}
|
||||
|
||||
// adjust len to start/end options
|
||||
len = Math.max(0, len - offset);
|
||||
if (options.end !== undefined) {
|
||||
var bytes = options.end - offset + 1;
|
||||
if (len > bytes) len = bytes;
|
||||
}
|
||||
|
||||
// Range support
|
||||
if (ranges) {
|
||||
ranges = parseRange(len, ranges);
|
||||
|
||||
// If-Range support
|
||||
if (!this.isRangeFresh()) {
|
||||
debug('range stale');
|
||||
ranges = -2;
|
||||
}
|
||||
|
||||
// unsatisfiable
|
||||
if (-1 == ranges) {
|
||||
debug('range unsatisfiable');
|
||||
res.setHeader('Content-Range', 'bytes */' + stat.size);
|
||||
return this.error(416);
|
||||
}
|
||||
|
||||
// valid (syntactically invalid/multiple ranges are treated as a regular response)
|
||||
if (-2 != ranges && ranges.length === 1) {
|
||||
debug('range %j', ranges);
|
||||
|
||||
// Content-Range
|
||||
res.statusCode = 206;
|
||||
res.setHeader('Content-Range', 'bytes '
|
||||
+ ranges[0].start
|
||||
+ '-'
|
||||
+ ranges[0].end
|
||||
+ '/'
|
||||
+ len);
|
||||
|
||||
offset += ranges[0].start;
|
||||
len = ranges[0].end - ranges[0].start + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// clone options
|
||||
for (var prop in options) {
|
||||
opts[prop] = options[prop]
|
||||
}
|
||||
|
||||
// set read options
|
||||
opts.start = offset
|
||||
opts.end = Math.max(offset, offset + len - 1)
|
||||
|
||||
// content-length
|
||||
res.setHeader('Content-Length', len);
|
||||
|
||||
// HEAD support
|
||||
if ('HEAD' == req.method) return res.end();
|
||||
|
||||
this.stream(path, opts)
|
||||
};
|
||||
|
||||
/**
|
||||
* Transfer file for `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
SendStream.prototype.sendFile = function sendFile(path) {
|
||||
var i = 0
|
||||
var self = this
|
||||
|
||||
debug('stat "%s"', path);
|
||||
fs.stat(path, function onstat(err, stat) {
|
||||
if (err && err.code === 'ENOENT'
|
||||
&& !extname(path)
|
||||
&& path[path.length - 1] !== sep) {
|
||||
// not found, check extensions
|
||||
return next(err)
|
||||
}
|
||||
if (err) return self.onStatError(err)
|
||||
if (stat.isDirectory()) return self.redirect(self.path)
|
||||
self.emit('file', path, stat)
|
||||
self.send(path, stat)
|
||||
})
|
||||
|
||||
function next(err) {
|
||||
if (self._extensions.length <= i) {
|
||||
return err
|
||||
? self.onStatError(err)
|
||||
: self.error(404)
|
||||
}
|
||||
|
||||
var p = path + '.' + self._extensions[i++]
|
||||
|
||||
debug('stat "%s"', p)
|
||||
fs.stat(p, function (err, stat) {
|
||||
if (err) return next(err)
|
||||
if (stat.isDirectory()) return next()
|
||||
self.emit('file', p, stat)
|
||||
self.send(p, stat)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer index for `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
SendStream.prototype.sendIndex = function sendIndex(path){
|
||||
var i = -1;
|
||||
var self = this;
|
||||
|
||||
function next(err){
|
||||
if (++i >= self._index.length) {
|
||||
if (err) return self.onStatError(err);
|
||||
return self.error(404);
|
||||
}
|
||||
|
||||
var p = join(path, self._index[i]);
|
||||
|
||||
debug('stat "%s"', p);
|
||||
fs.stat(p, function(err, stat){
|
||||
if (err) return next(err);
|
||||
if (stat.isDirectory()) return next();
|
||||
self.emit('file', p, stat);
|
||||
self.send(p, stat);
|
||||
});
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
/**
|
||||
* Stream `path` to the response.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} options
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.stream = function(path, options){
|
||||
// TODO: this is all lame, refactor meeee
|
||||
var finished = false;
|
||||
var self = this;
|
||||
var res = this.res;
|
||||
var req = this.req;
|
||||
|
||||
// pipe
|
||||
var stream = fs.createReadStream(path, options);
|
||||
this.emit('stream', stream);
|
||||
stream.pipe(res);
|
||||
|
||||
// response finished, done with the fd
|
||||
onFinished(res, function onfinished(){
|
||||
finished = true;
|
||||
destroy(stream);
|
||||
});
|
||||
|
||||
// error handling code-smell
|
||||
stream.on('error', function onerror(err){
|
||||
// request already finished
|
||||
if (finished) return;
|
||||
|
||||
// clean up stream
|
||||
finished = true;
|
||||
destroy(stream);
|
||||
|
||||
// error
|
||||
self.onStatError(err);
|
||||
});
|
||||
|
||||
// end
|
||||
stream.on('end', function onend(){
|
||||
self.emit('end');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Set content-type based on `path`
|
||||
* if it hasn't been explicitly set.
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.type = function(path){
|
||||
var res = this.res;
|
||||
if (res.getHeader('Content-Type')) return;
|
||||
var type = mime.lookup(path);
|
||||
var charset = mime.charsets.lookup(type);
|
||||
debug('content-type %s', type);
|
||||
res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : ''));
|
||||
};
|
||||
|
||||
/**
|
||||
* Set response header fields, most
|
||||
* fields may be pre-defined.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Object} stat
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SendStream.prototype.setHeader = function setHeader(path, stat){
|
||||
var res = this.res;
|
||||
|
||||
this.emit('headers', res, path, stat);
|
||||
|
||||
if (!res.getHeader('Accept-Ranges')) res.setHeader('Accept-Ranges', 'bytes');
|
||||
if (!res.getHeader('Cache-Control')) res.setHeader('Cache-Control', 'public, max-age=' + Math.floor(this._maxage / 1000));
|
||||
|
||||
if (this._lastModified && !res.getHeader('Last-Modified')) {
|
||||
var modified = stat.mtime.toUTCString()
|
||||
debug('modified %s', modified)
|
||||
res.setHeader('Last-Modified', modified)
|
||||
}
|
||||
|
||||
if (this._etag && !res.getHeader('ETag')) {
|
||||
var val = etag(stat)
|
||||
debug('etag %s', val)
|
||||
res.setHeader('ETag', val)
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine if path parts contain a dotfile.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function containsDotFile(parts) {
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
if (parts[i][0] === '.') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* decodeURIComponent.
|
||||
*
|
||||
* Allows V8 to only deoptimize this fn instead of all
|
||||
* of send().
|
||||
*
|
||||
* @param {String} path
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function decode(path) {
|
||||
try {
|
||||
return decodeURIComponent(path)
|
||||
} catch (err) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the index option into an array.
|
||||
*
|
||||
* @param {boolean|string|array} val
|
||||
* @param {string} name
|
||||
* @private
|
||||
*/
|
||||
|
||||
function normalizeList(val, name) {
|
||||
var list = [].concat(val || [])
|
||||
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (typeof list[i] !== 'string') {
|
||||
throw new TypeError(name + ' must be array of strings or false')
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
75
node_modules/send/node_modules/depd/History.md
generated
vendored
Normal file
75
node_modules/send/node_modules/depd/History.md
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
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/send/node_modules/depd/LICENSE
generated
vendored
Normal file
22
node_modules/send/node_modules/depd/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
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.
|
||||
274
node_modules/send/node_modules/depd/Readme.md
generated
vendored
Normal file
274
node_modules/send/node_modules/depd/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
# 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]
|
||||
[![Gratipay][gratipay-image]][gratipay-url]
|
||||
|
||||
Deprecate all the things
|
||||
|
||||
> With great modules comes great responsibility; mark things deprecated!
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install depd
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```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)
|
||||
|
||||
[npm-version-image]: https://img.shields.io/npm/v/depd.svg
|
||||
[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg
|
||||
[npm-url]: https://npmjs.org/package/depd
|
||||
[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd/master.svg?label=linux
|
||||
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/nodejs-depd/master.svg?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd
|
||||
[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
|
||||
[node-image]: https://img.shields.io/node/v/depd.svg
|
||||
[node-url]: http://nodejs.org/download/
|
||||
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
|
||||
[gratipay-url]: https://www.gratipay.com/dougwilson/
|
||||
529
node_modules/send/node_modules/depd/index.js
generated
vendored
Normal file
529
node_modules/send/node_modules/depd/index.js
generated
vendored
Normal file
@@ -0,0 +1,529 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var callSiteToString = require('./lib/compat').callSiteToString
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var relative = require('path').relative
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = depd
|
||||
|
||||
/**
|
||||
* Get the path to base files on.
|
||||
*/
|
||||
|
||||
var basePath = process.cwd()
|
||||
|
||||
/**
|
||||
* Get listener count on event emitter.
|
||||
*/
|
||||
|
||||
/*istanbul ignore next*/
|
||||
var eventListenerCount = EventEmitter.listenerCount
|
||||
|| function (emitter, type) { return emitter.listeners(type).length }
|
||||
|
||||
/**
|
||||
* Determine if namespace is contained in the string.
|
||||
*/
|
||||
|
||||
function containsNamespace(str, namespace) {
|
||||
var val = str.split(/[ ,]+/)
|
||||
|
||||
namespace = String(namespace).toLowerCase()
|
||||
|
||||
for (var i = 0 ; i < val.length; i++) {
|
||||
if (!(str = val[i])) continue;
|
||||
|
||||
// namespace contained
|
||||
if (str === '*' || str.toLowerCase() === namespace) {
|
||||
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 ' + callSiteToString(stack[i])
|
||||
}
|
||||
|
||||
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 namespace is ignored.
|
||||
*/
|
||||
|
||||
function isignored(namespace) {
|
||||
/* istanbul ignore next: tested in a child processs */
|
||||
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) {
|
||||
/* istanbul ignore next: tested in a child processs */
|
||||
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 = eventListenerCount(process, 'deprecation') !== 0
|
||||
|
||||
// abort early if no destination
|
||||
if (!haslisteners && this._ignored) {
|
||||
return
|
||||
}
|
||||
|
||||
var caller
|
||||
var callFile
|
||||
var callSite
|
||||
var i = 0
|
||||
var seen = false
|
||||
var stack = getStack()
|
||||
var file = this._file
|
||||
|
||||
if (site) {
|
||||
// provided site
|
||||
callSite = callSiteLocation(stack[1])
|
||||
callSite.name = site.name
|
||||
file = callSite[0]
|
||||
} else {
|
||||
// get call site
|
||||
i = 2
|
||||
site = callSiteLocation(stack[i])
|
||||
callSite = site
|
||||
}
|
||||
|
||||
// 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
|
||||
? site.join(':') + '__' + caller.join(':')
|
||||
: undefined
|
||||
|
||||
if (key !== undefined && key in this._warned) {
|
||||
// already warned
|
||||
return
|
||||
}
|
||||
|
||||
this._warned[key] = true
|
||||
|
||||
// generate automatic message from call site
|
||||
if (!message) {
|
||||
message = callSite === site || !callSite.name
|
||||
? defaultMessage(site)
|
||||
: defaultMessage(callSite)
|
||||
}
|
||||
|
||||
// emit deprecation if listeners exist
|
||||
if (haslisteners) {
|
||||
var err = DeprecationError(this._namespace, message, stack.slice(i))
|
||||
process.emit('deprecation', err)
|
||||
return
|
||||
}
|
||||
|
||||
// format and write message
|
||||
var format = process.stderr.isTTY
|
||||
? formatColor
|
||||
: formatPlain
|
||||
var msg = format.call(this, message, caller, stack.slice(i))
|
||||
process.stderr.write(msg + '\n', 'utf8')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ' + callSiteToString(stack[i])
|
||||
}
|
||||
|
||||
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 ' + callSiteToString(stack[i]) + '\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 deprecate = this
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
site.name = fn.name
|
||||
|
||||
var deprecatedfn = eval('(function (' + args + ') {\n'
|
||||
+ '"use strict"\n'
|
||||
+ 'log.call(deprecate, message, site)\n'
|
||||
+ 'return fn.apply(this, arguments)\n'
|
||||
+ '})')
|
||||
|
||||
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
|
||||
}
|
||||
33
node_modules/send/node_modules/depd/lib/compat/buffer-concat.js
generated
vendored
Normal file
33
node_modules/send/node_modules/depd/lib/compat/buffer-concat.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = bufferConcat
|
||||
|
||||
/**
|
||||
* Concatenate an array of Buffers.
|
||||
*/
|
||||
|
||||
function bufferConcat(bufs) {
|
||||
var length = 0
|
||||
|
||||
for (var i = 0, len = bufs.length; i < len; i++) {
|
||||
length += bufs[i].length
|
||||
}
|
||||
|
||||
var buf = new Buffer(length)
|
||||
var pos = 0
|
||||
|
||||
for (var i = 0, len = bufs.length; i < len; i++) {
|
||||
bufs[i].copy(buf, pos)
|
||||
pos += bufs[i].length
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
101
node_modules/send/node_modules/depd/lib/compat/callsite-tostring.js
generated
vendored
Normal file
101
node_modules/send/node_modules/depd/lib/compat/callsite-tostring.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = callSiteToString
|
||||
|
||||
/**
|
||||
* Format a CallSite file location to a string.
|
||||
*/
|
||||
|
||||
function callSiteFileLocation(callSite) {
|
||||
var fileName
|
||||
var fileLocation = ''
|
||||
|
||||
if (callSite.isNative()) {
|
||||
fileLocation = 'native'
|
||||
} else if (callSite.isEval()) {
|
||||
fileName = callSite.getScriptNameOrSourceURL()
|
||||
if (!fileName) {
|
||||
fileLocation = callSite.getEvalOrigin()
|
||||
}
|
||||
} else {
|
||||
fileName = callSite.getFileName()
|
||||
}
|
||||
|
||||
if (fileName) {
|
||||
fileLocation += fileName
|
||||
|
||||
var lineNumber = callSite.getLineNumber()
|
||||
if (lineNumber != null) {
|
||||
fileLocation += ':' + lineNumber
|
||||
|
||||
var columnNumber = callSite.getColumnNumber()
|
||||
if (columnNumber) {
|
||||
fileLocation += ':' + columnNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fileLocation || 'unknown source'
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a CallSite to a string.
|
||||
*/
|
||||
|
||||
function callSiteToString(callSite) {
|
||||
var addSuffix = true
|
||||
var fileLocation = callSiteFileLocation(callSite)
|
||||
var functionName = callSite.getFunctionName()
|
||||
var isConstructor = callSite.isConstructor()
|
||||
var isMethodCall = !(callSite.isToplevel() || isConstructor)
|
||||
var line = ''
|
||||
|
||||
if (isMethodCall) {
|
||||
var methodName = callSite.getMethodName()
|
||||
var typeName = getConstructorName(callSite)
|
||||
|
||||
if (functionName) {
|
||||
if (typeName && functionName.indexOf(typeName) !== 0) {
|
||||
line += typeName + '.'
|
||||
}
|
||||
|
||||
line += functionName
|
||||
|
||||
if (methodName && functionName.lastIndexOf('.' + methodName) !== functionName.length - methodName.length - 1) {
|
||||
line += ' [as ' + methodName + ']'
|
||||
}
|
||||
} else {
|
||||
line += typeName + '.' + (methodName || '<anonymous>')
|
||||
}
|
||||
} else if (isConstructor) {
|
||||
line += 'new ' + (functionName || '<anonymous>')
|
||||
} else if (functionName) {
|
||||
line += functionName
|
||||
} else {
|
||||
addSuffix = false
|
||||
line += fileLocation
|
||||
}
|
||||
|
||||
if (addSuffix) {
|
||||
line += ' (' + fileLocation + ')'
|
||||
}
|
||||
|
||||
return line
|
||||
}
|
||||
|
||||
/**
|
||||
* Get constructor name of reviver.
|
||||
*/
|
||||
|
||||
function getConstructorName(obj) {
|
||||
var receiver = obj.receiver
|
||||
return (receiver.constructor && receiver.constructor.name) || null
|
||||
}
|
||||
69
node_modules/send/node_modules/depd/lib/compat/index.js
generated
vendored
Normal file
69
node_modules/send/node_modules/depd/lib/compat/index.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
lazyProperty(module.exports, 'bufferConcat', function bufferConcat() {
|
||||
return Buffer.concat || require('./buffer-concat')
|
||||
})
|
||||
|
||||
lazyProperty(module.exports, 'callSiteToString', function callSiteToString() {
|
||||
var limit = Error.stackTraceLimit
|
||||
var obj = {}
|
||||
var prep = Error.prepareStackTrace
|
||||
|
||||
function prepareObjectStackTrace(obj, stack) {
|
||||
return stack
|
||||
}
|
||||
|
||||
Error.prepareStackTrace = prepareObjectStackTrace
|
||||
Error.stackTraceLimit = 2
|
||||
|
||||
// capture the stack
|
||||
Error.captureStackTrace(obj)
|
||||
|
||||
// slice the stack
|
||||
var stack = obj.stack.slice()
|
||||
|
||||
Error.prepareStackTrace = prep
|
||||
Error.stackTraceLimit = limit
|
||||
|
||||
return stack[0].toString ? toString : require('./callsite-tostring')
|
||||
})
|
||||
|
||||
/**
|
||||
* Define a lazy property.
|
||||
*/
|
||||
|
||||
function lazyProperty(obj, prop, getter) {
|
||||
function get() {
|
||||
var val = getter()
|
||||
|
||||
Object.defineProperty(obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: val
|
||||
})
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: get
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Call toString() on the obj
|
||||
*/
|
||||
|
||||
function toString(obj) {
|
||||
return obj.toString()
|
||||
}
|
||||
92
node_modules/send/node_modules/depd/package.json
generated
vendored
Normal file
92
node_modules/send/node_modules/depd/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"depd@~1.0.1",
|
||||
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/send"
|
||||
]
|
||||
],
|
||||
"_from": "depd@>=1.0.1 <1.1.0",
|
||||
"_id": "depd@1.0.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/send/depd",
|
||||
"_npmUser": {
|
||||
"email": "doug@somethingdoug.com",
|
||||
"name": "dougwilson"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "depd",
|
||||
"raw": "depd@~1.0.1",
|
||||
"rawSpec": "~1.0.1",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.1 <1.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/send"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/depd/-/depd-1.0.1.tgz",
|
||||
"_shasum": "80aec64c9d6d97e65cc2a9caa93c0aa6abf73aaa",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "depd@~1.0.1",
|
||||
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/send",
|
||||
"author": {
|
||||
"email": "doug@somethingdoug.com",
|
||||
"name": "Douglas Christopher Wilson"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/dougwilson/nodejs-depd/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Deprecate all the things",
|
||||
"devDependencies": {
|
||||
"beautify-benchmark": "0.2.4",
|
||||
"benchmark": "1.0.0",
|
||||
"istanbul": "0.3.5",
|
||||
"mocha": "~1.21.5"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "80aec64c9d6d97e65cc2a9caa93c0aa6abf73aaa",
|
||||
"tarball": "http://registry.npmjs.org/depd/-/depd-1.0.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"History.md",
|
||||
"LICENSE",
|
||||
"Readme.md",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"gitHead": "769e0f8108463c35a6937a9d634ab19fee45100a",
|
||||
"homepage": "https://github.com/dougwilson/nodejs-depd",
|
||||
"keywords": [
|
||||
"deprecate",
|
||||
"deprecated"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"name": "depd",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dougwilson/nodejs-depd.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/index.js",
|
||||
"test": "mocha --reporter spec --bail test/",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/"
|
||||
},
|
||||
"version": "1.0.1"
|
||||
}
|
||||
115
node_modules/send/package.json
generated
vendored
Normal file
115
node_modules/send/package.json
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"send@0.13.0",
|
||||
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/express"
|
||||
]
|
||||
],
|
||||
"_from": "send@0.13.0",
|
||||
"_id": "send@0.13.0",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/send",
|
||||
"_npmUser": {
|
||||
"email": "doug@somethingdoug.com",
|
||||
"name": "dougwilson"
|
||||
},
|
||||
"_npmVersion": "1.4.28",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "send",
|
||||
"raw": "send@0.13.0",
|
||||
"rawSpec": "0.13.0",
|
||||
"scope": null,
|
||||
"spec": "0.13.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express",
|
||||
"/serve-static"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/send/-/send-0.13.0.tgz",
|
||||
"_shasum": "518f921aeb0560aec7dcab2990b14cf6f3cce5de",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "send@0.13.0",
|
||||
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/express",
|
||||
"author": {
|
||||
"email": "tj@vision-media.ca",
|
||||
"name": "TJ Holowaychuk"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pillarjs/send/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"debug": "~2.2.0",
|
||||
"depd": "~1.0.1",
|
||||
"destroy": "1.0.3",
|
||||
"escape-html": "1.0.2",
|
||||
"etag": "~1.7.0",
|
||||
"fresh": "0.3.0",
|
||||
"http-errors": "~1.3.1",
|
||||
"mime": "1.3.4",
|
||||
"ms": "0.7.1",
|
||||
"on-finished": "~2.3.0",
|
||||
"range-parser": "~1.0.2",
|
||||
"statuses": "~1.2.1"
|
||||
},
|
||||
"description": "Better streaming static file server with Range and conditional-GET support",
|
||||
"devDependencies": {
|
||||
"after": "0.8.1",
|
||||
"istanbul": "0.3.9",
|
||||
"mocha": "2.2.5",
|
||||
"supertest": "1.0.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "518f921aeb0560aec7dcab2990b14cf6f3cce5de",
|
||||
"tarball": "http://registry.npmjs.org/send/-/send-0.13.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "80cfa7f54ce87c75e92619d5bc510406bd69133a",
|
||||
"homepage": "https://github.com/pillarjs/send",
|
||||
"keywords": [
|
||||
"file",
|
||||
"server",
|
||||
"static"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"name": "send",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pillarjs/send.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --check-leaks --reporter spec --bail",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot"
|
||||
},
|
||||
"version": "0.13.0"
|
||||
}
|
||||
Reference in New Issue
Block a user