Express Server erstellt
This commit is contained in:
3311
express-server/node_modules/express/History.md
generated
vendored
Normal file
3311
express-server/node_modules/express/History.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
express-server/node_modules/express/LICENSE
generated
vendored
Normal file
24
express-server/node_modules/express/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
Copyright (c) 2013-2014 Roman Shtylman <shtylman+expressjs@gmail.com>
|
||||
Copyright (c) 2014-2015 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.
|
141
express-server/node_modules/express/Readme.md
generated
vendored
Normal file
141
express-server/node_modules/express/Readme.md
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
[](http://expressjs.com/)
|
||||
|
||||
Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).
|
||||
|
||||
[![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]
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('Hello World')
|
||||
})
|
||||
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install express
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
* Robust routing
|
||||
* Focus on high performance
|
||||
* Super-high test coverage
|
||||
* HTTP helpers (redirection, caching, etc)
|
||||
* View system supporting 14+ template engines
|
||||
* Content negotiation
|
||||
* Executable for generating applications quickly
|
||||
|
||||
## Docs & Community
|
||||
|
||||
* [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]
|
||||
* [#express](https://webchat.freenode.net/?channels=express) on freenode IRC
|
||||
* [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules
|
||||
* Visit the [Wiki](https://github.com/expressjs/express/wiki)
|
||||
* [Google Group](https://groups.google.com/group/express-js) for discussion
|
||||
* [Gitter](https://gitter.im/expressjs/express) for support and discussion
|
||||
|
||||
**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x).
|
||||
|
||||
### Security Issues
|
||||
|
||||
If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md).
|
||||
|
||||
## Quick Start
|
||||
|
||||
The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:
|
||||
|
||||
Install the executable. The executable's major version will match Express's:
|
||||
|
||||
```bash
|
||||
$ npm install -g express-generator@4
|
||||
```
|
||||
|
||||
Create the app:
|
||||
|
||||
```bash
|
||||
$ express /tmp/foo && cd /tmp/foo
|
||||
```
|
||||
|
||||
Install dependencies:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Start the server:
|
||||
|
||||
```bash
|
||||
$ npm start
|
||||
```
|
||||
|
||||
## Philosophy
|
||||
|
||||
The Express philosophy is to provide small, robust tooling for HTTP servers, making
|
||||
it a great solution for single page applications, web sites, hybrids, or public
|
||||
HTTP APIs.
|
||||
|
||||
Express does not force you to use any specific ORM or template engine. With support for over
|
||||
14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js),
|
||||
you can quickly craft your perfect framework.
|
||||
|
||||
## Examples
|
||||
|
||||
To view the examples, clone the Express repo and install the dependencies:
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/expressjs/express.git --depth 1
|
||||
$ cd express
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Then run whichever example you want:
|
||||
|
||||
```bash
|
||||
$ node examples/content-negotiation
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
To run the test suite, first install the dependencies, then run `npm test`:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## People
|
||||
|
||||
The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia]
|
||||
|
||||
The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson]
|
||||
|
||||
[List of all contributors](https://github.com/expressjs/express/graphs/contributors)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/express.svg
|
||||
[npm-url]: https://npmjs.org/package/express
|
||||
[downloads-image]: https://img.shields.io/npm/dm/express.svg
|
||||
[downloads-url]: https://npmjs.org/package/express
|
||||
[travis-image]: https://img.shields.io/travis/expressjs/express/master.svg?label=linux
|
||||
[travis-url]: https://travis-ci.org/expressjs/express
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express
|
||||
[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master
|
||||
[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg
|
||||
[gratipay-url-visionmedia]: https://gratipay.com/visionmedia/
|
||||
[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg
|
||||
[gratipay-url-dougwilson]: https://gratipay.com/dougwilson/
|
11
express-server/node_modules/express/index.js
generated
vendored
Normal file
11
express-server/node_modules/express/index.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/express');
|
644
express-server/node_modules/express/lib/application.js
generated
vendored
Normal file
644
express-server/node_modules/express/lib/application.js
generated
vendored
Normal file
@ -0,0 +1,644 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var finalhandler = require('finalhandler');
|
||||
var Router = require('./router');
|
||||
var methods = require('methods');
|
||||
var middleware = require('./middleware/init');
|
||||
var query = require('./middleware/query');
|
||||
var debug = require('debug')('express:application');
|
||||
var View = require('./view');
|
||||
var http = require('http');
|
||||
var compileETag = require('./utils').compileETag;
|
||||
var compileQueryParser = require('./utils').compileQueryParser;
|
||||
var compileTrust = require('./utils').compileTrust;
|
||||
var deprecate = require('depd')('express');
|
||||
var flatten = require('array-flatten');
|
||||
var merge = require('utils-merge');
|
||||
var resolve = require('path').resolve;
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
/**
|
||||
* Application prototype.
|
||||
*/
|
||||
|
||||
var app = exports = module.exports = {};
|
||||
|
||||
/**
|
||||
* Variable for trust proxy inheritance back-compat
|
||||
* @private
|
||||
*/
|
||||
|
||||
var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';
|
||||
|
||||
/**
|
||||
* Initialize the server.
|
||||
*
|
||||
* - setup default configuration
|
||||
* - setup default middleware
|
||||
* - setup route reflection methods
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.init = function init() {
|
||||
this.cache = {};
|
||||
this.engines = {};
|
||||
this.settings = {};
|
||||
|
||||
this.defaultConfiguration();
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize application configuration.
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.defaultConfiguration = function defaultConfiguration() {
|
||||
var env = process.env.NODE_ENV || 'development';
|
||||
|
||||
// default settings
|
||||
this.enable('x-powered-by');
|
||||
this.set('etag', 'weak');
|
||||
this.set('env', env);
|
||||
this.set('query parser', 'extended');
|
||||
this.set('subdomain offset', 2);
|
||||
this.set('trust proxy', false);
|
||||
|
||||
// trust proxy inherit back-compat
|
||||
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
|
||||
configurable: true,
|
||||
value: true
|
||||
});
|
||||
|
||||
debug('booting in %s mode', env);
|
||||
|
||||
this.on('mount', function onmount(parent) {
|
||||
// inherit trust proxy
|
||||
if (this.settings[trustProxyDefaultSymbol] === true
|
||||
&& typeof parent.settings['trust proxy fn'] === 'function') {
|
||||
delete this.settings['trust proxy'];
|
||||
delete this.settings['trust proxy fn'];
|
||||
}
|
||||
|
||||
// inherit protos
|
||||
setPrototypeOf(this.request, parent.request)
|
||||
setPrototypeOf(this.response, parent.response)
|
||||
setPrototypeOf(this.engines, parent.engines)
|
||||
setPrototypeOf(this.settings, parent.settings)
|
||||
});
|
||||
|
||||
// setup locals
|
||||
this.locals = Object.create(null);
|
||||
|
||||
// top-most app is mounted at /
|
||||
this.mountpath = '/';
|
||||
|
||||
// default locals
|
||||
this.locals.settings = this.settings;
|
||||
|
||||
// default configuration
|
||||
this.set('view', View);
|
||||
this.set('views', resolve('views'));
|
||||
this.set('jsonp callback name', 'callback');
|
||||
|
||||
if (env === 'production') {
|
||||
this.enable('view cache');
|
||||
}
|
||||
|
||||
Object.defineProperty(this, 'router', {
|
||||
get: function() {
|
||||
throw new Error('\'app.router\' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* lazily adds the base router if it has not yet been added.
|
||||
*
|
||||
* We cannot add the base router in the defaultConfiguration because
|
||||
* it reads app settings which might be set after that has run.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
app.lazyrouter = function lazyrouter() {
|
||||
if (!this._router) {
|
||||
this._router = new Router({
|
||||
caseSensitive: this.enabled('case sensitive routing'),
|
||||
strict: this.enabled('strict routing')
|
||||
});
|
||||
|
||||
this._router.use(query(this.get('query parser fn')));
|
||||
this._router.use(middleware.init(this));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispatch a req, res pair into the application. Starts pipeline processing.
|
||||
*
|
||||
* If no callback is provided, then default error handlers will respond
|
||||
* in the event of an error bubbling through the stack.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.handle = function handle(req, res, callback) {
|
||||
var router = this._router;
|
||||
|
||||
// final handler
|
||||
var done = callback || finalhandler(req, res, {
|
||||
env: this.get('env'),
|
||||
onerror: logerror.bind(this)
|
||||
});
|
||||
|
||||
// no routes
|
||||
if (!router) {
|
||||
debug('no routes defined on app');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
router.handle(req, res, done);
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy `Router#use()` to add middleware to the app router.
|
||||
* See Router#use() documentation for details.
|
||||
*
|
||||
* If the _fn_ parameter is an express app, then it will be
|
||||
* mounted at the _route_ specified.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.use = function use(fn) {
|
||||
var offset = 0;
|
||||
var path = '/';
|
||||
|
||||
// default path to '/'
|
||||
// disambiguate app.use([fn])
|
||||
if (typeof fn !== 'function') {
|
||||
var arg = fn;
|
||||
|
||||
while (Array.isArray(arg) && arg.length !== 0) {
|
||||
arg = arg[0];
|
||||
}
|
||||
|
||||
// first arg is the path
|
||||
if (typeof arg !== 'function') {
|
||||
offset = 1;
|
||||
path = fn;
|
||||
}
|
||||
}
|
||||
|
||||
var fns = flatten(slice.call(arguments, offset));
|
||||
|
||||
if (fns.length === 0) {
|
||||
throw new TypeError('app.use() requires middleware functions');
|
||||
}
|
||||
|
||||
// setup router
|
||||
this.lazyrouter();
|
||||
var router = this._router;
|
||||
|
||||
fns.forEach(function (fn) {
|
||||
// non-express app
|
||||
if (!fn || !fn.handle || !fn.set) {
|
||||
return router.use(path, fn);
|
||||
}
|
||||
|
||||
debug('.use app under %s', path);
|
||||
fn.mountpath = path;
|
||||
fn.parent = this;
|
||||
|
||||
// restore .app property on req and res
|
||||
router.use(path, function mounted_app(req, res, next) {
|
||||
var orig = req.app;
|
||||
fn.handle(req, res, function (err) {
|
||||
setPrototypeOf(req, orig.request)
|
||||
setPrototypeOf(res, orig.response)
|
||||
next(err);
|
||||
});
|
||||
});
|
||||
|
||||
// mounted an app
|
||||
fn.emit('mount', this);
|
||||
}, this);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy to the app `Router#route()`
|
||||
* Returns a new `Route` instance for the _path_.
|
||||
*
|
||||
* Routes are isolated middleware stacks for specific paths.
|
||||
* See the Route api docs for details.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.route = function route(path) {
|
||||
this.lazyrouter();
|
||||
return this._router.route(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Register the given template engine callback `fn`
|
||||
* as `ext`.
|
||||
*
|
||||
* By default will `require()` the engine based on the
|
||||
* file extension. For example if you try to render
|
||||
* a "foo.ejs" file Express will invoke the following internally:
|
||||
*
|
||||
* app.engine('ejs', require('ejs').__express);
|
||||
*
|
||||
* For engines that do not provide `.__express` out of the box,
|
||||
* or if you wish to "map" a different extension to the template engine
|
||||
* you may use this method. For example mapping the EJS template engine to
|
||||
* ".html" files:
|
||||
*
|
||||
* app.engine('html', require('ejs').renderFile);
|
||||
*
|
||||
* In this case EJS provides a `.renderFile()` method with
|
||||
* the same signature that Express expects: `(path, options, callback)`,
|
||||
* though note that it aliases this method as `ejs.__express` internally
|
||||
* so if you're using ".ejs" extensions you dont need to do anything.
|
||||
*
|
||||
* Some template engines do not follow this convention, the
|
||||
* [Consolidate.js](https://github.com/tj/consolidate.js)
|
||||
* library was created to map all of node's popular template
|
||||
* engines to follow this convention, thus allowing them to
|
||||
* work seamlessly within Express.
|
||||
*
|
||||
* @param {String} ext
|
||||
* @param {Function} fn
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.engine = function engine(ext, fn) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new Error('callback function required');
|
||||
}
|
||||
|
||||
// get file extension
|
||||
var extension = ext[0] !== '.'
|
||||
? '.' + ext
|
||||
: ext;
|
||||
|
||||
// store engine
|
||||
this.engines[extension] = fn;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy to `Router#param()` with one added api feature. The _name_ parameter
|
||||
* can be an array of names.
|
||||
*
|
||||
* See the Router#param() docs for more details.
|
||||
*
|
||||
* @param {String|Array} name
|
||||
* @param {Function} fn
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.param = function param(name, fn) {
|
||||
this.lazyrouter();
|
||||
|
||||
if (Array.isArray(name)) {
|
||||
for (var i = 0; i < name.length; i++) {
|
||||
this.param(name[i], fn);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
this._router.param(name, fn);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Assign `setting` to `val`, or return `setting`'s value.
|
||||
*
|
||||
* app.set('foo', 'bar');
|
||||
* app.get('foo');
|
||||
* // => "bar"
|
||||
*
|
||||
* Mounted servers inherit their parent server's settings.
|
||||
*
|
||||
* @param {String} setting
|
||||
* @param {*} [val]
|
||||
* @return {Server} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.set = function set(setting, val) {
|
||||
if (arguments.length === 1) {
|
||||
// app.get(setting)
|
||||
return this.settings[setting];
|
||||
}
|
||||
|
||||
debug('set "%s" to %o', setting, val);
|
||||
|
||||
// set value
|
||||
this.settings[setting] = val;
|
||||
|
||||
// trigger matched settings
|
||||
switch (setting) {
|
||||
case 'etag':
|
||||
this.set('etag fn', compileETag(val));
|
||||
break;
|
||||
case 'query parser':
|
||||
this.set('query parser fn', compileQueryParser(val));
|
||||
break;
|
||||
case 'trust proxy':
|
||||
this.set('trust proxy fn', compileTrust(val));
|
||||
|
||||
// trust proxy inherit back-compat
|
||||
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
|
||||
configurable: true,
|
||||
value: false
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the app's absolute pathname
|
||||
* based on the parent(s) that have
|
||||
* mounted it.
|
||||
*
|
||||
* For example if the application was
|
||||
* mounted as "/admin", which itself
|
||||
* was mounted as "/blog" then the
|
||||
* return value would be "/blog/admin".
|
||||
*
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.path = function path() {
|
||||
return this.parent
|
||||
? this.parent.path() + this.mountpath
|
||||
: '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if `setting` is enabled (truthy).
|
||||
*
|
||||
* app.enabled('foo')
|
||||
* // => false
|
||||
*
|
||||
* app.enable('foo')
|
||||
* app.enabled('foo')
|
||||
* // => true
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.enabled = function enabled(setting) {
|
||||
return Boolean(this.set(setting));
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if `setting` is disabled.
|
||||
*
|
||||
* app.disabled('foo')
|
||||
* // => true
|
||||
*
|
||||
* app.enable('foo')
|
||||
* app.disabled('foo')
|
||||
* // => false
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.disabled = function disabled(setting) {
|
||||
return !this.set(setting);
|
||||
};
|
||||
|
||||
/**
|
||||
* Enable `setting`.
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.enable = function enable(setting) {
|
||||
return this.set(setting, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Disable `setting`.
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.disable = function disable(setting) {
|
||||
return this.set(setting, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegate `.VERB(...)` calls to `router.VERB(...)`.
|
||||
*/
|
||||
|
||||
methods.forEach(function(method){
|
||||
app[method] = function(path){
|
||||
if (method === 'get' && arguments.length === 1) {
|
||||
// app.get(setting)
|
||||
return this.set(path);
|
||||
}
|
||||
|
||||
this.lazyrouter();
|
||||
|
||||
var route = this._router.route(path);
|
||||
route[method].apply(route, slice.call(arguments, 1));
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Special-cased "all" method, applying the given route `path`,
|
||||
* middleware, and callback to _every_ HTTP method.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} ...
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.all = function all(path) {
|
||||
this.lazyrouter();
|
||||
|
||||
var route = this._router.route(path);
|
||||
var args = slice.call(arguments, 1);
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
route[methods[i]].apply(route, args);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// del -> delete alias
|
||||
|
||||
app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead');
|
||||
|
||||
/**
|
||||
* Render the given view `name` name with `options`
|
||||
* and a callback accepting an error and the
|
||||
* rendered template string.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* app.render('email', { name: 'Tobi' }, function(err, html){
|
||||
* // ...
|
||||
* })
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Object|Function} options or fn
|
||||
* @param {Function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.render = function render(name, options, callback) {
|
||||
var cache = this.cache;
|
||||
var done = callback;
|
||||
var engines = this.engines;
|
||||
var opts = options;
|
||||
var renderOptions = {};
|
||||
var view;
|
||||
|
||||
// support callback function as second arg
|
||||
if (typeof options === 'function') {
|
||||
done = options;
|
||||
opts = {};
|
||||
}
|
||||
|
||||
// merge app.locals
|
||||
merge(renderOptions, this.locals);
|
||||
|
||||
// merge options._locals
|
||||
if (opts._locals) {
|
||||
merge(renderOptions, opts._locals);
|
||||
}
|
||||
|
||||
// merge options
|
||||
merge(renderOptions, opts);
|
||||
|
||||
// set .cache unless explicitly provided
|
||||
if (renderOptions.cache == null) {
|
||||
renderOptions.cache = this.enabled('view cache');
|
||||
}
|
||||
|
||||
// primed cache
|
||||
if (renderOptions.cache) {
|
||||
view = cache[name];
|
||||
}
|
||||
|
||||
// view
|
||||
if (!view) {
|
||||
var View = this.get('view');
|
||||
|
||||
view = new View(name, {
|
||||
defaultEngine: this.get('view engine'),
|
||||
root: this.get('views'),
|
||||
engines: engines
|
||||
});
|
||||
|
||||
if (!view.path) {
|
||||
var dirs = Array.isArray(view.root) && view.root.length > 1
|
||||
? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"'
|
||||
: 'directory "' + view.root + '"'
|
||||
var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs);
|
||||
err.view = view;
|
||||
return done(err);
|
||||
}
|
||||
|
||||
// prime the cache
|
||||
if (renderOptions.cache) {
|
||||
cache[name] = view;
|
||||
}
|
||||
}
|
||||
|
||||
// render
|
||||
tryRender(view, renderOptions, done);
|
||||
};
|
||||
|
||||
/**
|
||||
* Listen for connections.
|
||||
*
|
||||
* A node `http.Server` is returned, with this
|
||||
* application (which is a `Function`) as its
|
||||
* callback. If you wish to create both an HTTP
|
||||
* and HTTPS server you may do so with the "http"
|
||||
* and "https" modules as shown here:
|
||||
*
|
||||
* var http = require('http')
|
||||
* , https = require('https')
|
||||
* , express = require('express')
|
||||
* , app = express();
|
||||
*
|
||||
* http.createServer(app).listen(80);
|
||||
* https.createServer({ ... }, app).listen(443);
|
||||
*
|
||||
* @return {http.Server}
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.listen = function listen() {
|
||||
var server = http.createServer(this);
|
||||
return server.listen.apply(server, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Log error using console.error.
|
||||
*
|
||||
* @param {Error} err
|
||||
* @private
|
||||
*/
|
||||
|
||||
function logerror(err) {
|
||||
/* istanbul ignore next */
|
||||
if (this.get('env') !== 'test') console.error(err.stack || err.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Try rendering a view.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryRender(view, options, callback) {
|
||||
try {
|
||||
view.render(options, callback);
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
}
|
111
express-server/node_modules/express/lib/express.js
generated
vendored
Normal file
111
express-server/node_modules/express/lib/express.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var mixin = require('merge-descriptors');
|
||||
var proto = require('./application');
|
||||
var Route = require('./router/route');
|
||||
var Router = require('./router');
|
||||
var req = require('./request');
|
||||
var res = require('./response');
|
||||
|
||||
/**
|
||||
* Expose `createApplication()`.
|
||||
*/
|
||||
|
||||
exports = module.exports = createApplication;
|
||||
|
||||
/**
|
||||
* Create an express application.
|
||||
*
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function createApplication() {
|
||||
var app = function(req, res, next) {
|
||||
app.handle(req, res, next);
|
||||
};
|
||||
|
||||
mixin(app, EventEmitter.prototype, false);
|
||||
mixin(app, proto, false);
|
||||
|
||||
// expose the prototype that will get set on requests
|
||||
app.request = Object.create(req, {
|
||||
app: { configurable: true, enumerable: true, writable: true, value: app }
|
||||
})
|
||||
|
||||
// expose the prototype that will get set on responses
|
||||
app.response = Object.create(res, {
|
||||
app: { configurable: true, enumerable: true, writable: true, value: app }
|
||||
})
|
||||
|
||||
app.init();
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose the prototypes.
|
||||
*/
|
||||
|
||||
exports.application = proto;
|
||||
exports.request = req;
|
||||
exports.response = res;
|
||||
|
||||
/**
|
||||
* Expose constructors.
|
||||
*/
|
||||
|
||||
exports.Route = Route;
|
||||
exports.Router = Router;
|
||||
|
||||
/**
|
||||
* Expose middleware
|
||||
*/
|
||||
|
||||
exports.query = require('./middleware/query');
|
||||
exports.static = require('serve-static');
|
||||
|
||||
/**
|
||||
* Replace removed middleware with an appropriate error message.
|
||||
*/
|
||||
|
||||
[
|
||||
'json',
|
||||
'urlencoded',
|
||||
'bodyParser',
|
||||
'compress',
|
||||
'cookieSession',
|
||||
'session',
|
||||
'logger',
|
||||
'cookieParser',
|
||||
'favicon',
|
||||
'responseTime',
|
||||
'errorHandler',
|
||||
'timeout',
|
||||
'methodOverride',
|
||||
'vhost',
|
||||
'csrf',
|
||||
'directory',
|
||||
'limit',
|
||||
'multipart',
|
||||
'staticCache',
|
||||
].forEach(function (name) {
|
||||
Object.defineProperty(exports, name, {
|
||||
get: function () {
|
||||
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
});
|
43
express-server/node_modules/express/lib/middleware/init.js
generated
vendored
Normal file
43
express-server/node_modules/express/lib/middleware/init.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
|
||||
/**
|
||||
* Initialization middleware, exposing the
|
||||
* request and response to each other, as well
|
||||
* as defaulting the X-Powered-By header field.
|
||||
*
|
||||
* @param {Function} app
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.init = function(app){
|
||||
return function expressInit(req, res, next){
|
||||
if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
|
||||
req.res = res;
|
||||
res.req = req;
|
||||
req.next = next;
|
||||
|
||||
setPrototypeOf(req, app.request)
|
||||
setPrototypeOf(res, app.response)
|
||||
|
||||
res.locals = res.locals || Object.create(null);
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
47
express-server/node_modules/express/lib/middleware/query.js
generated
vendored
Normal file
47
express-server/node_modules/express/lib/middleware/query.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var merge = require('utils-merge')
|
||||
var parseUrl = require('parseurl');
|
||||
var qs = require('qs');
|
||||
|
||||
/**
|
||||
* @param {Object} options
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function query(options) {
|
||||
var opts = merge({}, options)
|
||||
var queryparse = qs.parse;
|
||||
|
||||
if (typeof options === 'function') {
|
||||
queryparse = options;
|
||||
opts = undefined;
|
||||
}
|
||||
|
||||
if (opts !== undefined && opts.allowPrototypes === undefined) {
|
||||
// back-compat for qs module
|
||||
opts.allowPrototypes = true;
|
||||
}
|
||||
|
||||
return function query(req, res, next){
|
||||
if (!req.query) {
|
||||
var val = parseUrl(req).query;
|
||||
req.query = queryparse(val, opts);
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
517
express-server/node_modules/express/lib/request.js
generated
vendored
Normal file
517
express-server/node_modules/express/lib/request.js
generated
vendored
Normal file
@ -0,0 +1,517 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var accepts = require('accepts');
|
||||
var deprecate = require('depd')('express');
|
||||
var isIP = require('net').isIP;
|
||||
var typeis = require('type-is');
|
||||
var http = require('http');
|
||||
var fresh = require('fresh');
|
||||
var parseRange = require('range-parser');
|
||||
var parse = require('parseurl');
|
||||
var proxyaddr = require('proxy-addr');
|
||||
|
||||
/**
|
||||
* Request prototype.
|
||||
* @public
|
||||
*/
|
||||
|
||||
var req = Object.create(http.IncomingMessage.prototype)
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = req
|
||||
|
||||
/**
|
||||
* Return request header.
|
||||
*
|
||||
* The `Referrer` header field is special-cased,
|
||||
* both `Referrer` and `Referer` are interchangeable.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* req.get('Content-Type');
|
||||
* // => "text/plain"
|
||||
*
|
||||
* req.get('content-type');
|
||||
* // => "text/plain"
|
||||
*
|
||||
* req.get('Something');
|
||||
* // => undefined
|
||||
*
|
||||
* Aliased as `req.header()`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.get =
|
||||
req.header = function header(name) {
|
||||
if (!name) {
|
||||
throw new TypeError('name argument is required to req.get');
|
||||
}
|
||||
|
||||
if (typeof name !== 'string') {
|
||||
throw new TypeError('name must be a string to req.get');
|
||||
}
|
||||
|
||||
var lc = name.toLowerCase();
|
||||
|
||||
switch (lc) {
|
||||
case 'referer':
|
||||
case 'referrer':
|
||||
return this.headers.referrer
|
||||
|| this.headers.referer;
|
||||
default:
|
||||
return this.headers[lc];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* To do: update docs.
|
||||
*
|
||||
* Check if the given `type(s)` is acceptable, returning
|
||||
* the best match when true, otherwise `undefined`, in which
|
||||
* case you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* The `type` value may be a single MIME type string
|
||||
* such as "application/json", an extension name
|
||||
* such as "json", a comma-delimited list such as "json, html, text/plain",
|
||||
* an argument list such as `"json", "html", "text/plain"`,
|
||||
* or an array `["json", "html", "text/plain"]`. When a list
|
||||
* or array is given, the _best_ match, if any is returned.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // Accept: text/html
|
||||
* req.accepts('html');
|
||||
* // => "html"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* req.accepts('html');
|
||||
* // => "html"
|
||||
* req.accepts('text/html');
|
||||
* // => "text/html"
|
||||
* req.accepts('json, text');
|
||||
* // => "json"
|
||||
* req.accepts('application/json');
|
||||
* // => "application/json"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* req.accepts('image/png');
|
||||
* req.accepts('png');
|
||||
* // => undefined
|
||||
*
|
||||
* // Accept: text/*;q=.5, application/json
|
||||
* req.accepts(['html', 'json']);
|
||||
* req.accepts('html', 'json');
|
||||
* req.accepts('html, json');
|
||||
* // => "json"
|
||||
*
|
||||
* @param {String|Array} type(s)
|
||||
* @return {String|Array|Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.accepts = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.types.apply(accept, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the given `encoding`s are accepted.
|
||||
*
|
||||
* @param {String} ...encoding
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsEncodings = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.encodings.apply(accept, arguments);
|
||||
};
|
||||
|
||||
req.acceptsEncoding = deprecate.function(req.acceptsEncodings,
|
||||
'req.acceptsEncoding: Use acceptsEncodings instead');
|
||||
|
||||
/**
|
||||
* Check if the given `charset`s are acceptable,
|
||||
* otherwise you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* @param {String} ...charset
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsCharsets = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.charsets.apply(accept, arguments);
|
||||
};
|
||||
|
||||
req.acceptsCharset = deprecate.function(req.acceptsCharsets,
|
||||
'req.acceptsCharset: Use acceptsCharsets instead');
|
||||
|
||||
/**
|
||||
* Check if the given `lang`s are acceptable,
|
||||
* otherwise you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* @param {String} ...lang
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsLanguages = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.languages.apply(accept, arguments);
|
||||
};
|
||||
|
||||
req.acceptsLanguage = deprecate.function(req.acceptsLanguages,
|
||||
'req.acceptsLanguage: Use acceptsLanguages instead');
|
||||
|
||||
/**
|
||||
* Parse Range header field, capping to the given `size`.
|
||||
*
|
||||
* Unspecified ranges such as "0-" require knowledge of your resource length. In
|
||||
* the case of a byte range this is of course the total number of bytes. If the
|
||||
* Range header field is not given `undefined` is returned, `-1` when unsatisfiable,
|
||||
* and `-2` when syntactically invalid.
|
||||
*
|
||||
* When ranges are returned, the array has a "type" property which is the type of
|
||||
* range that is required (most commonly, "bytes"). Each array element is an object
|
||||
* with a "start" and "end" property for the portion of the range.
|
||||
*
|
||||
* The "combine" option can be set to `true` and overlapping & adjacent ranges
|
||||
* will be combined into a single range.
|
||||
*
|
||||
* NOTE: remember that ranges are inclusive, so for example "Range: users=0-3"
|
||||
* should respond with 4 users when available, not 3.
|
||||
*
|
||||
* @param {number} size
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.combine=false]
|
||||
* @return {number|array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.range = function range(size, options) {
|
||||
var range = this.get('Range');
|
||||
if (!range) return;
|
||||
return parseRange(size, range, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the value of param `name` when present or `defaultValue`.
|
||||
*
|
||||
* - Checks route placeholders, ex: _/user/:id_
|
||||
* - Checks body params, ex: id=12, {"id":12}
|
||||
* - Checks query string params, ex: ?id=12
|
||||
*
|
||||
* To utilize request bodies, `req.body`
|
||||
* should be an object. This can be done by using
|
||||
* the `bodyParser()` middleware.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Mixed} [defaultValue]
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.param = function param(name, defaultValue) {
|
||||
var params = this.params || {};
|
||||
var body = this.body || {};
|
||||
var query = this.query || {};
|
||||
|
||||
var args = arguments.length === 1
|
||||
? 'name'
|
||||
: 'name, default';
|
||||
deprecate('req.param(' + args + '): Use req.params, req.body, or req.query instead');
|
||||
|
||||
if (null != params[name] && params.hasOwnProperty(name)) return params[name];
|
||||
if (null != body[name]) return body[name];
|
||||
if (null != query[name]) return query[name];
|
||||
|
||||
return defaultValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the incoming request contains the "Content-Type"
|
||||
* header field, and it contains the give mime `type`.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // With Content-Type: text/html; charset=utf-8
|
||||
* req.is('html');
|
||||
* req.is('text/html');
|
||||
* req.is('text/*');
|
||||
* // => true
|
||||
*
|
||||
* // When Content-Type is application/json
|
||||
* req.is('json');
|
||||
* req.is('application/json');
|
||||
* req.is('application/*');
|
||||
* // => true
|
||||
*
|
||||
* req.is('html');
|
||||
* // => false
|
||||
*
|
||||
* @param {String|Array} types...
|
||||
* @return {String|false|null}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.is = function is(types) {
|
||||
var arr = types;
|
||||
|
||||
// support flattened arguments
|
||||
if (!Array.isArray(types)) {
|
||||
arr = new Array(arguments.length);
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
arr[i] = arguments[i];
|
||||
}
|
||||
}
|
||||
|
||||
return typeis(this, arr);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the protocol string "http" or "https"
|
||||
* when requested with TLS. When the "trust proxy"
|
||||
* setting trusts the socket address, the
|
||||
* "X-Forwarded-Proto" header field will be trusted
|
||||
* and used if present.
|
||||
*
|
||||
* If you're running behind a reverse proxy that
|
||||
* supplies https for you this may be enabled.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'protocol', function protocol(){
|
||||
var proto = this.connection.encrypted
|
||||
? 'https'
|
||||
: 'http';
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
|
||||
if (!trust(this.connection.remoteAddress, 0)) {
|
||||
return proto;
|
||||
}
|
||||
|
||||
// Note: X-Forwarded-Proto is normally only ever a
|
||||
// single value, but this is to be safe.
|
||||
proto = this.get('X-Forwarded-Proto') || proto;
|
||||
return proto.split(/\s*,\s*/)[0];
|
||||
});
|
||||
|
||||
/**
|
||||
* Short-hand for:
|
||||
*
|
||||
* req.protocol === 'https'
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'secure', function secure(){
|
||||
return this.protocol === 'https';
|
||||
});
|
||||
|
||||
/**
|
||||
* Return the remote address from the trusted proxy.
|
||||
*
|
||||
* The is the remote address on the socket unless
|
||||
* "trust proxy" is set.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'ip', function ip(){
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
return proxyaddr(this, trust);
|
||||
});
|
||||
|
||||
/**
|
||||
* When "trust proxy" is set, trusted proxy addresses + client.
|
||||
*
|
||||
* For example if the value were "client, proxy1, proxy2"
|
||||
* you would receive the array `["client", "proxy1", "proxy2"]`
|
||||
* where "proxy2" is the furthest down-stream and "proxy1" and
|
||||
* "proxy2" were trusted.
|
||||
*
|
||||
* @return {Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'ips', function ips() {
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
var addrs = proxyaddr.all(this, trust);
|
||||
|
||||
// reverse the order (to farthest -> closest)
|
||||
// and remove socket address
|
||||
addrs.reverse().pop()
|
||||
|
||||
return addrs
|
||||
});
|
||||
|
||||
/**
|
||||
* Return subdomains as an array.
|
||||
*
|
||||
* Subdomains are the dot-separated parts of the host before the main domain of
|
||||
* the app. By default, the domain of the app is assumed to be the last two
|
||||
* parts of the host. This can be changed by setting "subdomain offset".
|
||||
*
|
||||
* For example, if the domain is "tobi.ferrets.example.com":
|
||||
* If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`.
|
||||
* If "subdomain offset" is 3, req.subdomains is `["tobi"]`.
|
||||
*
|
||||
* @return {Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'subdomains', function subdomains() {
|
||||
var hostname = this.hostname;
|
||||
|
||||
if (!hostname) return [];
|
||||
|
||||
var offset = this.app.get('subdomain offset');
|
||||
var subdomains = !isIP(hostname)
|
||||
? hostname.split('.').reverse()
|
||||
: [hostname];
|
||||
|
||||
return subdomains.slice(offset);
|
||||
});
|
||||
|
||||
/**
|
||||
* Short-hand for `url.parse(req.url).pathname`.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'path', function path() {
|
||||
return parse(this).pathname;
|
||||
});
|
||||
|
||||
/**
|
||||
* Parse the "Host" header field to a hostname.
|
||||
*
|
||||
* When the "trust proxy" setting trusts the socket
|
||||
* address, the "X-Forwarded-Host" header field will
|
||||
* be trusted.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'hostname', function hostname(){
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
var host = this.get('X-Forwarded-Host');
|
||||
|
||||
if (!host || !trust(this.connection.remoteAddress, 0)) {
|
||||
host = this.get('Host');
|
||||
}
|
||||
|
||||
if (!host) return;
|
||||
|
||||
// IPv6 literal support
|
||||
var offset = host[0] === '['
|
||||
? host.indexOf(']') + 1
|
||||
: 0;
|
||||
var index = host.indexOf(':', offset);
|
||||
|
||||
return index !== -1
|
||||
? host.substring(0, index)
|
||||
: host;
|
||||
});
|
||||
|
||||
// TODO: change req.host to return host in next major
|
||||
|
||||
defineGetter(req, 'host', deprecate.function(function host(){
|
||||
return this.hostname;
|
||||
}, 'req.host: Use req.hostname instead'));
|
||||
|
||||
/**
|
||||
* Check if the request is fresh, aka
|
||||
* Last-Modified and/or the ETag
|
||||
* still match.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'fresh', function(){
|
||||
var method = this.method;
|
||||
var res = this.res
|
||||
var status = res.statusCode
|
||||
|
||||
// GET or HEAD for weak freshness validation only
|
||||
if ('GET' !== method && 'HEAD' !== method) return false;
|
||||
|
||||
// 2xx or 304 as per rfc2616 14.26
|
||||
if ((status >= 200 && status < 300) || 304 === status) {
|
||||
return fresh(this.headers, {
|
||||
'etag': res.get('ETag'),
|
||||
'last-modified': res.get('Last-Modified')
|
||||
})
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if the request is stale, aka
|
||||
* "Last-Modified" and / or the "ETag" for the
|
||||
* resource has changed.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'stale', function stale(){
|
||||
return !this.fresh;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if the request was an _XMLHttpRequest_.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'xhr', function xhr(){
|
||||
var val = this.get('X-Requested-With') || '';
|
||||
return val.toLowerCase() === 'xmlhttprequest';
|
||||
});
|
||||
|
||||
/**
|
||||
* Helper function for creating a getter on an object.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} name
|
||||
* @param {Function} getter
|
||||
* @private
|
||||
*/
|
||||
function defineGetter(obj, name, getter) {
|
||||
Object.defineProperty(obj, name, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: getter
|
||||
});
|
||||
}
|
1076
express-server/node_modules/express/lib/response.js
generated
vendored
Normal file
1076
express-server/node_modules/express/lib/response.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
662
express-server/node_modules/express/lib/router/index.js
generated
vendored
Normal file
662
express-server/node_modules/express/lib/router/index.js
generated
vendored
Normal file
@ -0,0 +1,662 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var Route = require('./route');
|
||||
var Layer = require('./layer');
|
||||
var methods = require('methods');
|
||||
var mixin = require('utils-merge');
|
||||
var debug = require('debug')('express:router');
|
||||
var deprecate = require('depd')('express');
|
||||
var flatten = require('array-flatten');
|
||||
var parseUrl = require('parseurl');
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var objectRegExp = /^\[object (\S+)\]$/;
|
||||
var slice = Array.prototype.slice;
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Initialize a new `Router` with the given `options`.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {Router} which is an callable function
|
||||
* @public
|
||||
*/
|
||||
|
||||
var proto = module.exports = function(options) {
|
||||
var opts = options || {};
|
||||
|
||||
function router(req, res, next) {
|
||||
router.handle(req, res, next);
|
||||
}
|
||||
|
||||
// mixin Router class functions
|
||||
setPrototypeOf(router, proto)
|
||||
|
||||
router.params = {};
|
||||
router._params = [];
|
||||
router.caseSensitive = opts.caseSensitive;
|
||||
router.mergeParams = opts.mergeParams;
|
||||
router.strict = opts.strict;
|
||||
router.stack = [];
|
||||
|
||||
return router;
|
||||
};
|
||||
|
||||
/**
|
||||
* Map the given param placeholder `name`(s) to the given callback.
|
||||
*
|
||||
* Parameter mapping is used to provide pre-conditions to routes
|
||||
* which use normalized placeholders. For example a _:user_id_ parameter
|
||||
* could automatically load a user's information from the database without
|
||||
* any additional code,
|
||||
*
|
||||
* The callback uses the same signature as middleware, the only difference
|
||||
* being that the value of the placeholder is passed, in this case the _id_
|
||||
* of the user. Once the `next()` function is invoked, just like middleware
|
||||
* it will continue on to execute the route, or subsequent parameter functions.
|
||||
*
|
||||
* Just like in middleware, you must either respond to the request or call next
|
||||
* to avoid stalling the request.
|
||||
*
|
||||
* app.param('user_id', function(req, res, next, id){
|
||||
* User.find(id, function(err, user){
|
||||
* if (err) {
|
||||
* return next(err);
|
||||
* } else if (!user) {
|
||||
* return next(new Error('failed to load user'));
|
||||
* }
|
||||
* req.user = user;
|
||||
* next();
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Function} fn
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
proto.param = function param(name, fn) {
|
||||
// param logic
|
||||
if (typeof name === 'function') {
|
||||
deprecate('router.param(fn): Refactor to use path params');
|
||||
this._params.push(name);
|
||||
return;
|
||||
}
|
||||
|
||||
// apply param functions
|
||||
var params = this._params;
|
||||
var len = params.length;
|
||||
var ret;
|
||||
|
||||
if (name[0] === ':') {
|
||||
deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.substr(1)) + ', fn) instead');
|
||||
name = name.substr(1);
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; ++i) {
|
||||
if (ret = params[i](name, fn)) {
|
||||
fn = ret;
|
||||
}
|
||||
}
|
||||
|
||||
// ensure we end up with a
|
||||
// middleware function
|
||||
if ('function' !== typeof fn) {
|
||||
throw new Error('invalid param() call for ' + name + ', got ' + fn);
|
||||
}
|
||||
|
||||
(this.params[name] = this.params[name] || []).push(fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispatch a req, res into the router.
|
||||
* @private
|
||||
*/
|
||||
|
||||
proto.handle = function handle(req, res, out) {
|
||||
var self = this;
|
||||
|
||||
debug('dispatching %s %s', req.method, req.url);
|
||||
|
||||
var idx = 0;
|
||||
var protohost = getProtohost(req.url) || ''
|
||||
var removed = '';
|
||||
var slashAdded = false;
|
||||
var paramcalled = {};
|
||||
|
||||
// store options for OPTIONS request
|
||||
// only used if OPTIONS request
|
||||
var options = [];
|
||||
|
||||
// middleware and routes
|
||||
var stack = self.stack;
|
||||
|
||||
// manage inter-router variables
|
||||
var parentParams = req.params;
|
||||
var parentUrl = req.baseUrl || '';
|
||||
var done = restore(out, req, 'baseUrl', 'next', 'params');
|
||||
|
||||
// setup next layer
|
||||
req.next = next;
|
||||
|
||||
// for options requests, respond with a default if nothing else responds
|
||||
if (req.method === 'OPTIONS') {
|
||||
done = wrap(done, function(old, err) {
|
||||
if (err || options.length === 0) return old(err);
|
||||
sendOptionsResponse(res, options, old);
|
||||
});
|
||||
}
|
||||
|
||||
// setup basic req values
|
||||
req.baseUrl = parentUrl;
|
||||
req.originalUrl = req.originalUrl || req.url;
|
||||
|
||||
next();
|
||||
|
||||
function next(err) {
|
||||
var layerError = err === 'route'
|
||||
? null
|
||||
: err;
|
||||
|
||||
// remove added slash
|
||||
if (slashAdded) {
|
||||
req.url = req.url.substr(1);
|
||||
slashAdded = false;
|
||||
}
|
||||
|
||||
// restore altered req.url
|
||||
if (removed.length !== 0) {
|
||||
req.baseUrl = parentUrl;
|
||||
req.url = protohost + removed + req.url.substr(protohost.length);
|
||||
removed = '';
|
||||
}
|
||||
|
||||
// signal to exit router
|
||||
if (layerError === 'router') {
|
||||
setImmediate(done, null)
|
||||
return
|
||||
}
|
||||
|
||||
// no more matching layers
|
||||
if (idx >= stack.length) {
|
||||
setImmediate(done, layerError);
|
||||
return;
|
||||
}
|
||||
|
||||
// get pathname of request
|
||||
var path = getPathname(req);
|
||||
|
||||
if (path == null) {
|
||||
return done(layerError);
|
||||
}
|
||||
|
||||
// find next matching layer
|
||||
var layer;
|
||||
var match;
|
||||
var route;
|
||||
|
||||
while (match !== true && idx < stack.length) {
|
||||
layer = stack[idx++];
|
||||
match = matchLayer(layer, path);
|
||||
route = layer.route;
|
||||
|
||||
if (typeof match !== 'boolean') {
|
||||
// hold on to layerError
|
||||
layerError = layerError || match;
|
||||
}
|
||||
|
||||
if (match !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!route) {
|
||||
// process non-route handlers normally
|
||||
continue;
|
||||
}
|
||||
|
||||
if (layerError) {
|
||||
// routes do not match with a pending error
|
||||
match = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
var method = req.method;
|
||||
var has_method = route._handles_method(method);
|
||||
|
||||
// build up automatic options response
|
||||
if (!has_method && method === 'OPTIONS') {
|
||||
appendMethods(options, route._options());
|
||||
}
|
||||
|
||||
// don't even bother matching route
|
||||
if (!has_method && method !== 'HEAD') {
|
||||
match = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// no match
|
||||
if (match !== true) {
|
||||
return done(layerError);
|
||||
}
|
||||
|
||||
// store route for dispatch on change
|
||||
if (route) {
|
||||
req.route = route;
|
||||
}
|
||||
|
||||
// Capture one-time layer values
|
||||
req.params = self.mergeParams
|
||||
? mergeParams(layer.params, parentParams)
|
||||
: layer.params;
|
||||
var layerPath = layer.path;
|
||||
|
||||
// this should be done for the layer
|
||||
self.process_params(layer, paramcalled, req, res, function (err) {
|
||||
if (err) {
|
||||
return next(layerError || err);
|
||||
}
|
||||
|
||||
if (route) {
|
||||
return layer.handle_request(req, res, next);
|
||||
}
|
||||
|
||||
trim_prefix(layer, layerError, layerPath, path);
|
||||
});
|
||||
}
|
||||
|
||||
function trim_prefix(layer, layerError, layerPath, path) {
|
||||
if (layerPath.length !== 0) {
|
||||
// Validate path breaks on a path separator
|
||||
var c = path[layerPath.length]
|
||||
if (c && c !== '/' && c !== '.') return next(layerError)
|
||||
|
||||
// Trim off the part of the url that matches the route
|
||||
// middleware (.use stuff) needs to have the path stripped
|
||||
debug('trim prefix (%s) from url %s', layerPath, req.url);
|
||||
removed = layerPath;
|
||||
req.url = protohost + req.url.substr(protohost.length + removed.length);
|
||||
|
||||
// Ensure leading slash
|
||||
if (!protohost && req.url[0] !== '/') {
|
||||
req.url = '/' + req.url;
|
||||
slashAdded = true;
|
||||
}
|
||||
|
||||
// Setup base URL (no trailing slash)
|
||||
req.baseUrl = parentUrl + (removed[removed.length - 1] === '/'
|
||||
? removed.substring(0, removed.length - 1)
|
||||
: removed);
|
||||
}
|
||||
|
||||
debug('%s %s : %s', layer.name, layerPath, req.originalUrl);
|
||||
|
||||
if (layerError) {
|
||||
layer.handle_error(layerError, req, res, next);
|
||||
} else {
|
||||
layer.handle_request(req, res, next);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Process any parameters for the layer.
|
||||
* @private
|
||||
*/
|
||||
|
||||
proto.process_params = function process_params(layer, called, req, res, done) {
|
||||
var params = this.params;
|
||||
|
||||
// captured parameters from the layer, keys and values
|
||||
var keys = layer.keys;
|
||||
|
||||
// fast track
|
||||
if (!keys || keys.length === 0) {
|
||||
return done();
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var name;
|
||||
var paramIndex = 0;
|
||||
var key;
|
||||
var paramVal;
|
||||
var paramCallbacks;
|
||||
var paramCalled;
|
||||
|
||||
// process params in order
|
||||
// param callbacks can be async
|
||||
function param(err) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (i >= keys.length ) {
|
||||
return done();
|
||||
}
|
||||
|
||||
paramIndex = 0;
|
||||
key = keys[i++];
|
||||
name = key.name;
|
||||
paramVal = req.params[name];
|
||||
paramCallbacks = params[name];
|
||||
paramCalled = called[name];
|
||||
|
||||
if (paramVal === undefined || !paramCallbacks) {
|
||||
return param();
|
||||
}
|
||||
|
||||
// param previously called with same value or error occurred
|
||||
if (paramCalled && (paramCalled.match === paramVal
|
||||
|| (paramCalled.error && paramCalled.error !== 'route'))) {
|
||||
// restore value
|
||||
req.params[name] = paramCalled.value;
|
||||
|
||||
// next param
|
||||
return param(paramCalled.error);
|
||||
}
|
||||
|
||||
called[name] = paramCalled = {
|
||||
error: null,
|
||||
match: paramVal,
|
||||
value: paramVal
|
||||
};
|
||||
|
||||
paramCallback();
|
||||
}
|
||||
|
||||
// single param callbacks
|
||||
function paramCallback(err) {
|
||||
var fn = paramCallbacks[paramIndex++];
|
||||
|
||||
// store updated value
|
||||
paramCalled.value = req.params[key.name];
|
||||
|
||||
if (err) {
|
||||
// store error
|
||||
paramCalled.error = err;
|
||||
param(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fn) return param();
|
||||
|
||||
try {
|
||||
fn(req, res, paramCallback, paramVal, key.name);
|
||||
} catch (e) {
|
||||
paramCallback(e);
|
||||
}
|
||||
}
|
||||
|
||||
param();
|
||||
};
|
||||
|
||||
/**
|
||||
* Use the given middleware function, with optional path, defaulting to "/".
|
||||
*
|
||||
* Use (like `.all`) will run for any http METHOD, but it will not add
|
||||
* handlers for those methods so OPTIONS requests will not consider `.use`
|
||||
* functions even if they could respond.
|
||||
*
|
||||
* The other difference is that _route_ path is stripped and not visible
|
||||
* to the handler function. The main effect of this feature is that mounted
|
||||
* handlers can operate without any code changes regardless of the "prefix"
|
||||
* pathname.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
proto.use = function use(fn) {
|
||||
var offset = 0;
|
||||
var path = '/';
|
||||
|
||||
// default path to '/'
|
||||
// disambiguate router.use([fn])
|
||||
if (typeof fn !== 'function') {
|
||||
var arg = fn;
|
||||
|
||||
while (Array.isArray(arg) && arg.length !== 0) {
|
||||
arg = arg[0];
|
||||
}
|
||||
|
||||
// first arg is the path
|
||||
if (typeof arg !== 'function') {
|
||||
offset = 1;
|
||||
path = fn;
|
||||
}
|
||||
}
|
||||
|
||||
var callbacks = flatten(slice.call(arguments, offset));
|
||||
|
||||
if (callbacks.length === 0) {
|
||||
throw new TypeError('Router.use() requires middleware functions');
|
||||
}
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
var fn = callbacks[i];
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn));
|
||||
}
|
||||
|
||||
// add the middleware
|
||||
debug('use %o %s', path, fn.name || '<anonymous>')
|
||||
|
||||
var layer = new Layer(path, {
|
||||
sensitive: this.caseSensitive,
|
||||
strict: false,
|
||||
end: false
|
||||
}, fn);
|
||||
|
||||
layer.route = undefined;
|
||||
|
||||
this.stack.push(layer);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new Route for the given path.
|
||||
*
|
||||
* Each route contains a separate middleware stack and VERB handlers.
|
||||
*
|
||||
* See the Route api documentation for details on adding handlers
|
||||
* and middleware to routes.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Route}
|
||||
* @public
|
||||
*/
|
||||
|
||||
proto.route = function route(path) {
|
||||
var route = new Route(path);
|
||||
|
||||
var layer = new Layer(path, {
|
||||
sensitive: this.caseSensitive,
|
||||
strict: this.strict,
|
||||
end: true
|
||||
}, route.dispatch.bind(route));
|
||||
|
||||
layer.route = route;
|
||||
|
||||
this.stack.push(layer);
|
||||
return route;
|
||||
};
|
||||
|
||||
// create Router#VERB functions
|
||||
methods.concat('all').forEach(function(method){
|
||||
proto[method] = function(path){
|
||||
var route = this.route(path)
|
||||
route[method].apply(route, slice.call(arguments, 1));
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
// append methods to a list of methods
|
||||
function appendMethods(list, addition) {
|
||||
for (var i = 0; i < addition.length; i++) {
|
||||
var method = addition[i];
|
||||
if (list.indexOf(method) === -1) {
|
||||
list.push(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get pathname of request
|
||||
function getPathname(req) {
|
||||
try {
|
||||
return parseUrl(req).pathname;
|
||||
} catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Get get protocol + host for a URL
|
||||
function getProtohost(url) {
|
||||
if (typeof url !== 'string' || url.length === 0 || url[0] === '/') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var searchIndex = url.indexOf('?')
|
||||
var pathLength = searchIndex !== -1
|
||||
? searchIndex
|
||||
: url.length
|
||||
var fqdnIndex = url.substr(0, pathLength).indexOf('://')
|
||||
|
||||
return fqdnIndex !== -1
|
||||
? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
|
||||
: undefined
|
||||
}
|
||||
|
||||
// get type for error message
|
||||
function gettype(obj) {
|
||||
var type = typeof obj;
|
||||
|
||||
if (type !== 'object') {
|
||||
return type;
|
||||
}
|
||||
|
||||
// inspect [[Class]] for objects
|
||||
return toString.call(obj)
|
||||
.replace(objectRegExp, '$1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Match path to a layer.
|
||||
*
|
||||
* @param {Layer} layer
|
||||
* @param {string} path
|
||||
* @private
|
||||
*/
|
||||
|
||||
function matchLayer(layer, path) {
|
||||
try {
|
||||
return layer.match(path);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
// merge params with parent params
|
||||
function mergeParams(params, parent) {
|
||||
if (typeof parent !== 'object' || !parent) {
|
||||
return params;
|
||||
}
|
||||
|
||||
// make copy of parent for base
|
||||
var obj = mixin({}, parent);
|
||||
|
||||
// simple non-numeric merging
|
||||
if (!(0 in params) || !(0 in parent)) {
|
||||
return mixin(obj, params);
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var o = 0;
|
||||
|
||||
// determine numeric gaps
|
||||
while (i in params) {
|
||||
i++;
|
||||
}
|
||||
|
||||
while (o in parent) {
|
||||
o++;
|
||||
}
|
||||
|
||||
// offset numeric indices in params before merge
|
||||
for (i--; i >= 0; i--) {
|
||||
params[i + o] = params[i];
|
||||
|
||||
// create holes for the merge when necessary
|
||||
if (i < o) {
|
||||
delete params[i];
|
||||
}
|
||||
}
|
||||
|
||||
return mixin(obj, params);
|
||||
}
|
||||
|
||||
// restore obj props after function
|
||||
function restore(fn, obj) {
|
||||
var props = new Array(arguments.length - 2);
|
||||
var vals = new Array(arguments.length - 2);
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
props[i] = arguments[i + 2];
|
||||
vals[i] = obj[props[i]];
|
||||
}
|
||||
|
||||
return function () {
|
||||
// restore vals
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
obj[props[i]] = vals[i];
|
||||
}
|
||||
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// send an OPTIONS response
|
||||
function sendOptionsResponse(res, options, next) {
|
||||
try {
|
||||
var body = options.join(',');
|
||||
res.set('Allow', body);
|
||||
res.send(body);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
||||
// wrap a function
|
||||
function wrap(old, fn) {
|
||||
return function proxy() {
|
||||
var args = new Array(arguments.length + 1);
|
||||
|
||||
args[0] = old;
|
||||
for (var i = 0, len = arguments.length; i < len; i++) {
|
||||
args[i + 1] = arguments[i];
|
||||
}
|
||||
|
||||
fn.apply(this, args);
|
||||
};
|
||||
}
|
181
express-server/node_modules/express/lib/router/layer.js
generated
vendored
Normal file
181
express-server/node_modules/express/lib/router/layer.js
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var pathRegexp = require('path-to-regexp');
|
||||
var debug = require('debug')('express:router:layer');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = Layer;
|
||||
|
||||
function Layer(path, options, fn) {
|
||||
if (!(this instanceof Layer)) {
|
||||
return new Layer(path, options, fn);
|
||||
}
|
||||
|
||||
debug('new %o', path)
|
||||
var opts = options || {};
|
||||
|
||||
this.handle = fn;
|
||||
this.name = fn.name || '<anonymous>';
|
||||
this.params = undefined;
|
||||
this.path = undefined;
|
||||
this.regexp = pathRegexp(path, this.keys = [], opts);
|
||||
|
||||
// set fast path flags
|
||||
this.regexp.fast_star = path === '*'
|
||||
this.regexp.fast_slash = path === '/' && opts.end === false
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the error for the layer.
|
||||
*
|
||||
* @param {Error} error
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {function} next
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handle_error = function handle_error(error, req, res, next) {
|
||||
var fn = this.handle;
|
||||
|
||||
if (fn.length !== 4) {
|
||||
// not a standard error handler
|
||||
return next(error);
|
||||
}
|
||||
|
||||
try {
|
||||
fn(error, req, res, next);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the request for the layer.
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {function} next
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handle_request = function handle(req, res, next) {
|
||||
var fn = this.handle;
|
||||
|
||||
if (fn.length > 3) {
|
||||
// not a standard request handler
|
||||
return next();
|
||||
}
|
||||
|
||||
try {
|
||||
fn(req, res, next);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this route matches `path`, if so
|
||||
* populate `.params`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.match = function match(path) {
|
||||
var match
|
||||
|
||||
if (path != null) {
|
||||
// fast path non-ending match for / (any path matches)
|
||||
if (this.regexp.fast_slash) {
|
||||
this.params = {}
|
||||
this.path = ''
|
||||
return true
|
||||
}
|
||||
|
||||
// fast path for * (everything matched in a param)
|
||||
if (this.regexp.fast_star) {
|
||||
this.params = {'0': decode_param(path)}
|
||||
this.path = path
|
||||
return true
|
||||
}
|
||||
|
||||
// match the path
|
||||
match = this.regexp.exec(path)
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
this.params = undefined;
|
||||
this.path = undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
// store values
|
||||
this.params = {};
|
||||
this.path = match[0]
|
||||
|
||||
var keys = this.keys;
|
||||
var params = this.params;
|
||||
|
||||
for (var i = 1; i < match.length; i++) {
|
||||
var key = keys[i - 1];
|
||||
var prop = key.name;
|
||||
var val = decode_param(match[i])
|
||||
|
||||
if (val !== undefined || !(hasOwnProperty.call(params, prop))) {
|
||||
params[prop] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode param value.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function decode_param(val) {
|
||||
if (typeof val !== 'string' || val.length === 0) {
|
||||
return val;
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURIComponent(val);
|
||||
} catch (err) {
|
||||
if (err instanceof URIError) {
|
||||
err.message = 'Failed to decode param \'' + val + '\'';
|
||||
err.status = err.statusCode = 400;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
216
express-server/node_modules/express/lib/router/route.js
generated
vendored
Normal file
216
express-server/node_modules/express/lib/router/route.js
generated
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var debug = require('debug')('express:router:route');
|
||||
var flatten = require('array-flatten');
|
||||
var Layer = require('./layer');
|
||||
var methods = require('methods');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var slice = Array.prototype.slice;
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = Route;
|
||||
|
||||
/**
|
||||
* Initialize `Route` with the given `path`,
|
||||
*
|
||||
* @param {String} path
|
||||
* @public
|
||||
*/
|
||||
|
||||
function Route(path) {
|
||||
this.path = path;
|
||||
this.stack = [];
|
||||
|
||||
debug('new %o', path)
|
||||
|
||||
// route handlers for various http methods
|
||||
this.methods = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the route handles a given method.
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype._handles_method = function _handles_method(method) {
|
||||
if (this.methods._all) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var name = method.toLowerCase();
|
||||
|
||||
if (name === 'head' && !this.methods['head']) {
|
||||
name = 'get';
|
||||
}
|
||||
|
||||
return Boolean(this.methods[name]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Array} supported HTTP methods
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype._options = function _options() {
|
||||
var methods = Object.keys(this.methods);
|
||||
|
||||
// append automatic head
|
||||
if (this.methods.get && !this.methods.head) {
|
||||
methods.push('head');
|
||||
}
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
// make upper case
|
||||
methods[i] = methods[i].toUpperCase();
|
||||
}
|
||||
|
||||
return methods;
|
||||
};
|
||||
|
||||
/**
|
||||
* dispatch req, res into this route
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype.dispatch = function dispatch(req, res, done) {
|
||||
var idx = 0;
|
||||
var stack = this.stack;
|
||||
if (stack.length === 0) {
|
||||
return done();
|
||||
}
|
||||
|
||||
var method = req.method.toLowerCase();
|
||||
if (method === 'head' && !this.methods['head']) {
|
||||
method = 'get';
|
||||
}
|
||||
|
||||
req.route = this;
|
||||
|
||||
next();
|
||||
|
||||
function next(err) {
|
||||
// signal to exit route
|
||||
if (err && err === 'route') {
|
||||
return done();
|
||||
}
|
||||
|
||||
// signal to exit router
|
||||
if (err && err === 'router') {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
var layer = stack[idx++];
|
||||
if (!layer) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (layer.method && layer.method !== method) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
layer.handle_error(err, req, res, next);
|
||||
} else {
|
||||
layer.handle_request(req, res, next);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a handler for all HTTP verbs to this route.
|
||||
*
|
||||
* Behaves just like middleware and can respond or call `next`
|
||||
* to continue processing.
|
||||
*
|
||||
* You can use multiple `.all` call to add multiple handlers.
|
||||
*
|
||||
* function check_something(req, res, next){
|
||||
* next();
|
||||
* };
|
||||
*
|
||||
* function validate_user(req, res, next){
|
||||
* next();
|
||||
* };
|
||||
*
|
||||
* route
|
||||
* .all(validate_user)
|
||||
* .all(check_something)
|
||||
* .get(function(req, res, next){
|
||||
* res.send('hello world');
|
||||
* });
|
||||
*
|
||||
* @param {function} handler
|
||||
* @return {Route} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Route.prototype.all = function all() {
|
||||
var handles = flatten(slice.call(arguments));
|
||||
|
||||
for (var i = 0; i < handles.length; i++) {
|
||||
var handle = handles[i];
|
||||
|
||||
if (typeof handle !== 'function') {
|
||||
var type = toString.call(handle);
|
||||
var msg = 'Route.all() requires callback functions but got a ' + type;
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
|
||||
var layer = Layer('/', {}, handle);
|
||||
layer.method = undefined;
|
||||
|
||||
this.methods._all = true;
|
||||
this.stack.push(layer);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
methods.forEach(function(method){
|
||||
Route.prototype[method] = function(){
|
||||
var handles = flatten(slice.call(arguments));
|
||||
|
||||
for (var i = 0; i < handles.length; i++) {
|
||||
var handle = handles[i];
|
||||
|
||||
if (typeof handle !== 'function') {
|
||||
var type = toString.call(handle);
|
||||
var msg = 'Route.' + method + '() requires callback functions but got a ' + type;
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
debug('%s %o', method, this.path)
|
||||
|
||||
var layer = Layer('/', {}, handle);
|
||||
layer.method = method;
|
||||
|
||||
this.methods[method] = true;
|
||||
this.stack.push(layer);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
298
express-server/node_modules/express/lib/utils.js
generated
vendored
Normal file
298
express-server/node_modules/express/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,298 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var contentDisposition = require('content-disposition');
|
||||
var contentType = require('content-type');
|
||||
var deprecate = require('depd')('express');
|
||||
var flatten = require('array-flatten');
|
||||
var mime = require('send').mime;
|
||||
var etag = require('etag');
|
||||
var proxyaddr = require('proxy-addr');
|
||||
var qs = require('qs');
|
||||
var querystring = require('querystring');
|
||||
|
||||
/**
|
||||
* Return strong ETag for `body`.
|
||||
*
|
||||
* @param {String|Buffer} body
|
||||
* @param {String} [encoding]
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.etag = function (body, encoding) {
|
||||
var buf = !Buffer.isBuffer(body)
|
||||
? new Buffer(body, encoding)
|
||||
: body;
|
||||
|
||||
return etag(buf, {weak: false});
|
||||
};
|
||||
|
||||
/**
|
||||
* Return weak ETag for `body`.
|
||||
*
|
||||
* @param {String|Buffer} body
|
||||
* @param {String} [encoding]
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.wetag = function wetag(body, encoding){
|
||||
var buf = !Buffer.isBuffer(body)
|
||||
? new Buffer(body, encoding)
|
||||
: body;
|
||||
|
||||
return etag(buf, {weak: true});
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if `path` looks absolute.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.isAbsolute = function(path){
|
||||
if ('/' === path[0]) return true;
|
||||
if (':' === path[1] && ('\\' === path[2] || '/' === path[2])) return true; // Windows device path
|
||||
if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path
|
||||
};
|
||||
|
||||
/**
|
||||
* Flatten the given `arr`.
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @return {Array}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.flatten = deprecate.function(flatten,
|
||||
'utils.flatten: use array-flatten npm module instead');
|
||||
|
||||
/**
|
||||
* Normalize the given `type`, for example "html" becomes "text/html".
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.normalizeType = function(type){
|
||||
return ~type.indexOf('/')
|
||||
? acceptParams(type)
|
||||
: { value: mime.lookup(type), params: {} };
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize `types`, for example "html" becomes "text/html".
|
||||
*
|
||||
* @param {Array} types
|
||||
* @return {Array}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.normalizeTypes = function(types){
|
||||
var ret = [];
|
||||
|
||||
for (var i = 0; i < types.length; ++i) {
|
||||
ret.push(exports.normalizeType(types[i]));
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate Content-Disposition header appropriate for the filename.
|
||||
* non-ascii filenames are urlencoded and a filename* parameter is added
|
||||
*
|
||||
* @param {String} filename
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.contentDisposition = deprecate.function(contentDisposition,
|
||||
'utils.contentDisposition: use content-disposition npm module instead');
|
||||
|
||||
/**
|
||||
* Parse accept params `str` returning an
|
||||
* object with `.value`, `.quality` and `.params`.
|
||||
* also includes `.originalIndex` for stable sorting
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function acceptParams(str, index) {
|
||||
var parts = str.split(/ *; */);
|
||||
var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index };
|
||||
|
||||
for (var i = 1; i < parts.length; ++i) {
|
||||
var pms = parts[i].split(/ *= */);
|
||||
if ('q' === pms[0]) {
|
||||
ret.quality = parseFloat(pms[1]);
|
||||
} else {
|
||||
ret.params[pms[0]] = pms[1];
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile "etag" value to function.
|
||||
*
|
||||
* @param {Boolean|String|Function} val
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.compileETag = function(val) {
|
||||
var fn;
|
||||
|
||||
if (typeof val === 'function') {
|
||||
return val;
|
||||
}
|
||||
|
||||
switch (val) {
|
||||
case true:
|
||||
fn = exports.wetag;
|
||||
break;
|
||||
case false:
|
||||
break;
|
||||
case 'strong':
|
||||
fn = exports.etag;
|
||||
break;
|
||||
case 'weak':
|
||||
fn = exports.wetag;
|
||||
break;
|
||||
default:
|
||||
throw new TypeError('unknown value for etag function: ' + val);
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile "query parser" value to function.
|
||||
*
|
||||
* @param {String|Function} val
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.compileQueryParser = function compileQueryParser(val) {
|
||||
var fn;
|
||||
|
||||
if (typeof val === 'function') {
|
||||
return val;
|
||||
}
|
||||
|
||||
switch (val) {
|
||||
case true:
|
||||
fn = querystring.parse;
|
||||
break;
|
||||
case false:
|
||||
fn = newObject;
|
||||
break;
|
||||
case 'extended':
|
||||
fn = parseExtendedQueryString;
|
||||
break;
|
||||
case 'simple':
|
||||
fn = querystring.parse;
|
||||
break;
|
||||
default:
|
||||
throw new TypeError('unknown value for query parser function: ' + val);
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile "proxy trust" value to function.
|
||||
*
|
||||
* @param {Boolean|String|Number|Array|Function} val
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.compileTrust = function(val) {
|
||||
if (typeof val === 'function') return val;
|
||||
|
||||
if (val === true) {
|
||||
// Support plain true/false
|
||||
return function(){ return true };
|
||||
}
|
||||
|
||||
if (typeof val === 'number') {
|
||||
// Support trusting hop count
|
||||
return function(a, i){ return i < val };
|
||||
}
|
||||
|
||||
if (typeof val === 'string') {
|
||||
// Support comma-separated values
|
||||
val = val.split(/ *, */);
|
||||
}
|
||||
|
||||
return proxyaddr.compile(val || []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the charset in a given Content-Type string.
|
||||
*
|
||||
* @param {String} type
|
||||
* @param {String} charset
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.setCharset = function setCharset(type, charset) {
|
||||
if (!type || !charset) {
|
||||
return type;
|
||||
}
|
||||
|
||||
// parse type
|
||||
var parsed = contentType.parse(type);
|
||||
|
||||
// set charset
|
||||
parsed.parameters.charset = charset;
|
||||
|
||||
// format type
|
||||
return contentType.format(parsed);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse an extended query string with qs.
|
||||
*
|
||||
* @return {Object}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseExtendedQueryString(str) {
|
||||
return qs.parse(str, {
|
||||
allowPrototypes: true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return new empty object.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function newObject() {
|
||||
return {};
|
||||
}
|
174
express-server/node_modules/express/lib/view.js
generated
vendored
Normal file
174
express-server/node_modules/express/lib/view.js
generated
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var debug = require('debug')('express:view');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var dirname = path.dirname;
|
||||
var basename = path.basename;
|
||||
var extname = path.extname;
|
||||
var join = path.join;
|
||||
var resolve = path.resolve;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = View;
|
||||
|
||||
/**
|
||||
* Initialize a new `View` with the given `name`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `defaultEngine` the default template engine name
|
||||
* - `engines` template engine require() cache
|
||||
* - `root` root path for view lookup
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {object} options
|
||||
* @public
|
||||
*/
|
||||
|
||||
function View(name, options) {
|
||||
var opts = options || {};
|
||||
|
||||
this.defaultEngine = opts.defaultEngine;
|
||||
this.ext = extname(name);
|
||||
this.name = name;
|
||||
this.root = opts.root;
|
||||
|
||||
if (!this.ext && !this.defaultEngine) {
|
||||
throw new Error('No default engine was specified and no extension was provided.');
|
||||
}
|
||||
|
||||
var fileName = name;
|
||||
|
||||
if (!this.ext) {
|
||||
// get extension from default engine name
|
||||
this.ext = this.defaultEngine[0] !== '.'
|
||||
? '.' + this.defaultEngine
|
||||
: this.defaultEngine;
|
||||
|
||||
fileName += this.ext;
|
||||
}
|
||||
|
||||
if (!opts.engines[this.ext]) {
|
||||
// load engine
|
||||
var mod = this.ext.substr(1)
|
||||
debug('require "%s"', mod)
|
||||
opts.engines[this.ext] = require(mod).__express
|
||||
}
|
||||
|
||||
// store loaded engine
|
||||
this.engine = opts.engines[this.ext];
|
||||
|
||||
// lookup path
|
||||
this.path = this.lookup(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup view by the given `name`
|
||||
*
|
||||
* @param {string} name
|
||||
* @private
|
||||
*/
|
||||
|
||||
View.prototype.lookup = function lookup(name) {
|
||||
var path;
|
||||
var roots = [].concat(this.root);
|
||||
|
||||
debug('lookup "%s"', name);
|
||||
|
||||
for (var i = 0; i < roots.length && !path; i++) {
|
||||
var root = roots[i];
|
||||
|
||||
// resolve the path
|
||||
var loc = resolve(root, name);
|
||||
var dir = dirname(loc);
|
||||
var file = basename(loc);
|
||||
|
||||
// resolve the file
|
||||
path = this.resolve(dir, file);
|
||||
}
|
||||
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Render with the given options.
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {function} callback
|
||||
* @private
|
||||
*/
|
||||
|
||||
View.prototype.render = function render(options, callback) {
|
||||
debug('render "%s"', this.path);
|
||||
this.engine(this.path, options, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolve the file within the given directory.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {string} file
|
||||
* @private
|
||||
*/
|
||||
|
||||
View.prototype.resolve = function resolve(dir, file) {
|
||||
var ext = this.ext;
|
||||
|
||||
// <path>.<ext>
|
||||
var path = join(dir, file);
|
||||
var stat = tryStat(path);
|
||||
|
||||
if (stat && stat.isFile()) {
|
||||
return path;
|
||||
}
|
||||
|
||||
// <path>/index.<ext>
|
||||
path = join(dir, basename(file, ext), 'index' + ext);
|
||||
stat = tryStat(path);
|
||||
|
||||
if (stat && stat.isFile()) {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a stat, maybe.
|
||||
*
|
||||
* @param {string} path
|
||||
* @return {fs.Stats}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryStat(path) {
|
||||
debug('stat "%s"', path);
|
||||
|
||||
try {
|
||||
return fs.statSync(path);
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
30
express-server/node_modules/express/node_modules/qs/.editorconfig
generated
vendored
Normal file
30
express-server/node_modules/express/node_modules/qs/.editorconfig
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 140
|
||||
|
||||
[test/*]
|
||||
max_line_length = off
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
|
||||
[*.json]
|
||||
max_line_length = off
|
||||
|
||||
[Makefile]
|
||||
max_line_length = off
|
||||
|
||||
[CHANGELOG.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[LICENSE]
|
||||
indent_size = 2
|
||||
max_line_length = off
|
1
express-server/node_modules/express/node_modules/qs/.eslintignore
generated
vendored
Normal file
1
express-server/node_modules/express/node_modules/qs/.eslintignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
dist
|
18
express-server/node_modules/express/node_modules/qs/.eslintrc
generated
vendored
Normal file
18
express-server/node_modules/express/node_modules/qs/.eslintrc
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"complexity": [2, 28],
|
||||
"consistent-return": 1,
|
||||
"id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
|
||||
"indent": [2, 4],
|
||||
"max-params": [2, 12],
|
||||
"max-statements": [2, 45],
|
||||
"no-continue": 1,
|
||||
"no-magic-numbers": 0,
|
||||
"no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
|
||||
"operator-linebreak": [2, "before"],
|
||||
}
|
||||
}
|
212
express-server/node_modules/express/node_modules/qs/CHANGELOG.md
generated
vendored
Normal file
212
express-server/node_modules/express/node_modules/qs/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
## **6.5.0**
|
||||
- [New] add `utils.assign`
|
||||
- [New] pass default encoder/decoder to custom encoder/decoder functions (#206)
|
||||
- [New] `parse`/`stringify`: add `ignoreQueryPrefix`/`addQueryPrefix` options, respectively (#213)
|
||||
- [Fix] Handle stringifying empty objects with addQueryPrefix (#217)
|
||||
- [Fix] do not mutate `options` argument (#207)
|
||||
- [Refactor] `parse`: cache index to reuse in else statement (#182)
|
||||
- [Docs] add various badges to readme (#208)
|
||||
- [Dev Deps] update `eslint`, `browserify`, `iconv-lite`, `tape`
|
||||
- [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`; npm v4.6 breaks on node < v1; npm v5+ breaks on node < v4
|
||||
- [Tests] add `editorconfig-tools`
|
||||
|
||||
## **6.4.0**
|
||||
- [New] `qs.stringify`: add `encodeValuesOnly` option
|
||||
- [Fix] follow `allowPrototypes` option during merge (#201, #201)
|
||||
- [Fix] support keys starting with brackets (#202, #200)
|
||||
- [Fix] chmod a-x
|
||||
- [Dev Deps] update `eslint`
|
||||
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||
- [eslint] reduce warnings
|
||||
|
||||
## **6.3.2**
|
||||
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||
- [Dev Deps] update `eslint`
|
||||
- [Fix] chmod a-x
|
||||
- [Fix] support keys starting with brackets (#202, #200)
|
||||
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||
|
||||
## **6.3.1**
|
||||
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape`
|
||||
- [Tests] on all node minors; improve test matrix
|
||||
- [Docs] document stringify option `allowDots` (#195)
|
||||
- [Docs] add empty object and array values example (#195)
|
||||
- [Docs] Fix minor inconsistency/typo (#192)
|
||||
- [Docs] document stringify option `sort` (#191)
|
||||
- [Refactor] `stringify`: throw faster with an invalid encoder
|
||||
- [Refactor] remove unnecessary escapes (#184)
|
||||
- Remove contributing.md, since `qs` is no longer part of `hapi` (#183)
|
||||
|
||||
## **6.3.0**
|
||||
- [New] Add support for RFC 1738 (#174, #173)
|
||||
- [New] `stringify`: Add `serializeDate` option to customize Date serialization (#159)
|
||||
- [Fix] ensure `utils.merge` handles merging two arrays
|
||||
- [Refactor] only constructors should be capitalized
|
||||
- [Refactor] capitalized var names are for constructors only
|
||||
- [Refactor] avoid using a sparse array
|
||||
- [Robustness] `formats`: cache `String#replace`
|
||||
- [Dev Deps] update `browserify`, `eslint`, `@ljharb/eslint-config`; add `safe-publish-latest`
|
||||
- [Tests] up to `node` `v6.8`, `v4.6`; improve test matrix
|
||||
- [Tests] flesh out arrayLimit/arrayFormat tests (#107)
|
||||
- [Tests] skip Object.create tests when null objects are not available
|
||||
- [Tests] Turn on eslint for test files (#175)
|
||||
|
||||
## **6.2.3**
|
||||
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||
- [Fix] chmod a-x
|
||||
- [Fix] support keys starting with brackets (#202, #200)
|
||||
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||
|
||||
## **6.2.2**
|
||||
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
|
||||
|
||||
## **6.2.1**
|
||||
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
|
||||
- [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call`
|
||||
- [Tests] remove `parallelshell` since it does not reliably report failures
|
||||
- [Tests] up to `node` `v6.3`, `v5.12`
|
||||
- [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config`, `qs-iconv`
|
||||
|
||||
## [**6.2.0**](https://github.com/ljharb/qs/issues?milestone=36&state=closed)
|
||||
- [New] pass Buffers to the encoder/decoder directly (#161)
|
||||
- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
|
||||
- [Fix] fix compacting of nested sparse arrays (#150)
|
||||
|
||||
## **6.1.2
|
||||
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||
- [Fix] chmod a-x
|
||||
- [Fix] support keys starting with brackets (#202, #200)
|
||||
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||
|
||||
## **6.1.1**
|
||||
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
|
||||
|
||||
## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed)
|
||||
- [New] allowDots option for `stringify` (#151)
|
||||
- [Fix] "sort" option should work at a depth of 3 or more (#151)
|
||||
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
|
||||
|
||||
## **6.0.4**
|
||||
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||
- [Fix] chmod a-x
|
||||
- [Fix] support keys starting with brackets (#202, #200)
|
||||
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||
|
||||
## **6.0.3**
|
||||
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
|
||||
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
|
||||
|
||||
## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed)
|
||||
- Revert ES6 requirement and restore support for node down to v0.8.
|
||||
|
||||
## [**6.0.1**](https://github.com/ljharb/qs/issues?milestone=32&state=closed)
|
||||
- [**#127**](https://github.com/ljharb/qs/pull/127) Fix engines definition in package.json
|
||||
|
||||
## [**6.0.0**](https://github.com/ljharb/qs/issues?milestone=31&state=closed)
|
||||
- [**#124**](https://github.com/ljharb/qs/issues/124) Use ES6 and drop support for node < v4
|
||||
|
||||
## **5.2.1**
|
||||
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
|
||||
|
||||
## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed)
|
||||
- [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string
|
||||
|
||||
## [**5.1.0**](https://github.com/ljharb/qs/issues?milestone=29&state=closed)
|
||||
- [**#117**](https://github.com/ljharb/qs/issues/117) make URI encoding stringified results optional
|
||||
- [**#106**](https://github.com/ljharb/qs/issues/106) Add flag `skipNulls` to optionally skip null values in stringify
|
||||
|
||||
## [**5.0.0**](https://github.com/ljharb/qs/issues?milestone=28&state=closed)
|
||||
- [**#114**](https://github.com/ljharb/qs/issues/114) default allowDots to false
|
||||
- [**#100**](https://github.com/ljharb/qs/issues/100) include dist to npm
|
||||
|
||||
## [**4.0.0**](https://github.com/ljharb/qs/issues?milestone=26&state=closed)
|
||||
- [**#98**](https://github.com/ljharb/qs/issues/98) make returning plain objects and allowing prototype overwriting properties optional
|
||||
|
||||
## [**3.1.0**](https://github.com/ljharb/qs/issues?milestone=24&state=closed)
|
||||
- [**#89**](https://github.com/ljharb/qs/issues/89) Add option to disable "Transform dot notation to bracket notation"
|
||||
|
||||
## [**3.0.0**](https://github.com/ljharb/qs/issues?milestone=23&state=closed)
|
||||
- [**#80**](https://github.com/ljharb/qs/issues/80) qs.parse silently drops properties
|
||||
- [**#77**](https://github.com/ljharb/qs/issues/77) Perf boost
|
||||
- [**#60**](https://github.com/ljharb/qs/issues/60) Add explicit option to disable array parsing
|
||||
- [**#74**](https://github.com/ljharb/qs/issues/74) Bad parse when turning array into object
|
||||
- [**#81**](https://github.com/ljharb/qs/issues/81) Add a `filter` option
|
||||
- [**#68**](https://github.com/ljharb/qs/issues/68) Fixed issue with recursion and passing strings into objects.
|
||||
- [**#66**](https://github.com/ljharb/qs/issues/66) Add mixed array and object dot notation support Closes: #47
|
||||
- [**#76**](https://github.com/ljharb/qs/issues/76) RFC 3986
|
||||
- [**#85**](https://github.com/ljharb/qs/issues/85) No equal sign
|
||||
- [**#84**](https://github.com/ljharb/qs/issues/84) update license attribute
|
||||
|
||||
## [**2.4.1**](https://github.com/ljharb/qs/issues?milestone=20&state=closed)
|
||||
- [**#73**](https://github.com/ljharb/qs/issues/73) Property 'hasOwnProperty' of object #<Object> is not a function
|
||||
|
||||
## [**2.4.0**](https://github.com/ljharb/qs/issues?milestone=19&state=closed)
|
||||
- [**#70**](https://github.com/ljharb/qs/issues/70) Add arrayFormat option
|
||||
|
||||
## [**2.3.3**](https://github.com/ljharb/qs/issues?milestone=18&state=closed)
|
||||
- [**#59**](https://github.com/ljharb/qs/issues/59) make sure array indexes are >= 0, closes #57
|
||||
- [**#58**](https://github.com/ljharb/qs/issues/58) make qs usable for browser loader
|
||||
|
||||
## [**2.3.2**](https://github.com/ljharb/qs/issues?milestone=17&state=closed)
|
||||
- [**#55**](https://github.com/ljharb/qs/issues/55) allow merging a string into an object
|
||||
|
||||
## [**2.3.1**](https://github.com/ljharb/qs/issues?milestone=16&state=closed)
|
||||
- [**#52**](https://github.com/ljharb/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError".
|
||||
|
||||
## [**2.3.0**](https://github.com/ljharb/qs/issues?milestone=15&state=closed)
|
||||
- [**#50**](https://github.com/ljharb/qs/issues/50) add option to omit array indices, closes #46
|
||||
|
||||
## [**2.2.5**](https://github.com/ljharb/qs/issues?milestone=14&state=closed)
|
||||
- [**#39**](https://github.com/ljharb/qs/issues/39) Is there an alternative to Buffer.isBuffer?
|
||||
- [**#49**](https://github.com/ljharb/qs/issues/49) refactor utils.merge, fixes #45
|
||||
- [**#41**](https://github.com/ljharb/qs/issues/41) avoid browserifying Buffer, for #39
|
||||
|
||||
## [**2.2.4**](https://github.com/ljharb/qs/issues?milestone=13&state=closed)
|
||||
- [**#38**](https://github.com/ljharb/qs/issues/38) how to handle object keys beginning with a number
|
||||
|
||||
## [**2.2.3**](https://github.com/ljharb/qs/issues?milestone=12&state=closed)
|
||||
- [**#37**](https://github.com/ljharb/qs/issues/37) parser discards first empty value in array
|
||||
- [**#36**](https://github.com/ljharb/qs/issues/36) Update to lab 4.x
|
||||
|
||||
## [**2.2.2**](https://github.com/ljharb/qs/issues?milestone=11&state=closed)
|
||||
- [**#33**](https://github.com/ljharb/qs/issues/33) Error when plain object in a value
|
||||
- [**#34**](https://github.com/ljharb/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty
|
||||
- [**#24**](https://github.com/ljharb/qs/issues/24) Changelog? Semver?
|
||||
|
||||
## [**2.2.1**](https://github.com/ljharb/qs/issues?milestone=10&state=closed)
|
||||
- [**#32**](https://github.com/ljharb/qs/issues/32) account for circular references properly, closes #31
|
||||
- [**#31**](https://github.com/ljharb/qs/issues/31) qs.parse stackoverflow on circular objects
|
||||
|
||||
## [**2.2.0**](https://github.com/ljharb/qs/issues?milestone=9&state=closed)
|
||||
- [**#26**](https://github.com/ljharb/qs/issues/26) Don't use Buffer global if it's not present
|
||||
- [**#30**](https://github.com/ljharb/qs/issues/30) Bug when merging non-object values into arrays
|
||||
- [**#29**](https://github.com/ljharb/qs/issues/29) Don't call Utils.clone at the top of Utils.merge
|
||||
- [**#23**](https://github.com/ljharb/qs/issues/23) Ability to not limit parameters?
|
||||
|
||||
## [**2.1.0**](https://github.com/ljharb/qs/issues?milestone=8&state=closed)
|
||||
- [**#22**](https://github.com/ljharb/qs/issues/22) Enable using a RegExp as delimiter
|
||||
|
||||
## [**2.0.0**](https://github.com/ljharb/qs/issues?milestone=7&state=closed)
|
||||
- [**#18**](https://github.com/ljharb/qs/issues/18) Why is there arrayLimit?
|
||||
- [**#20**](https://github.com/ljharb/qs/issues/20) Configurable parametersLimit
|
||||
- [**#21**](https://github.com/ljharb/qs/issues/21) make all limits optional, for #18, for #20
|
||||
|
||||
## [**1.2.2**](https://github.com/ljharb/qs/issues?milestone=6&state=closed)
|
||||
- [**#19**](https://github.com/ljharb/qs/issues/19) Don't overwrite null values
|
||||
|
||||
## [**1.2.1**](https://github.com/ljharb/qs/issues?milestone=5&state=closed)
|
||||
- [**#16**](https://github.com/ljharb/qs/issues/16) ignore non-string delimiters
|
||||
- [**#15**](https://github.com/ljharb/qs/issues/15) Close code block
|
||||
|
||||
## [**1.2.0**](https://github.com/ljharb/qs/issues?milestone=4&state=closed)
|
||||
- [**#12**](https://github.com/ljharb/qs/issues/12) Add optional delim argument
|
||||
- [**#13**](https://github.com/ljharb/qs/issues/13) fix #11: flattened keys in array are now correctly parsed
|
||||
|
||||
## [**1.1.0**](https://github.com/ljharb/qs/issues?milestone=3&state=closed)
|
||||
- [**#7**](https://github.com/ljharb/qs/issues/7) Empty values of a POST array disappear after being submitted
|
||||
- [**#9**](https://github.com/ljharb/qs/issues/9) Should not omit equals signs (=) when value is null
|
||||
- [**#6**](https://github.com/ljharb/qs/issues/6) Minor grammar fix in README
|
||||
|
||||
## [**1.0.2**](https://github.com/ljharb/qs/issues?milestone=2&state=closed)
|
||||
- [**#5**](https://github.com/ljharb/qs/issues/5) array holes incorrectly copied into object on large index
|
28
express-server/node_modules/express/node_modules/qs/LICENSE
generated
vendored
Normal file
28
express-server/node_modules/express/node_modules/qs/LICENSE
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
Copyright (c) 2014 Nathan LaFreniere and other contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* The names of any contributors may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
* * *
|
||||
|
||||
The complete list of contributors can be found at: https://github.com/hapijs/qs/graphs/contributors
|
475
express-server/node_modules/express/node_modules/qs/README.md
generated
vendored
Normal file
475
express-server/node_modules/express/node_modules/qs/README.md
generated
vendored
Normal file
@ -0,0 +1,475 @@
|
||||
# qs <sup>[![Version Badge][2]][1]</sup>
|
||||
|
||||
[![Build Status][3]][4]
|
||||
[![dependency status][5]][6]
|
||||
[![dev dependency status][7]][8]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][11]][1]
|
||||
|
||||
A querystring parsing and stringifying library with some added security.
|
||||
|
||||
Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
|
||||
|
||||
The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var qs = require('qs');
|
||||
var assert = require('assert');
|
||||
|
||||
var obj = qs.parse('a=c');
|
||||
assert.deepEqual(obj, { a: 'c' });
|
||||
|
||||
var str = qs.stringify(obj);
|
||||
assert.equal(str, 'a=c');
|
||||
```
|
||||
|
||||
### Parsing Objects
|
||||
|
||||
[](#preventEval)
|
||||
```javascript
|
||||
qs.parse(string, [options]);
|
||||
```
|
||||
|
||||
**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`.
|
||||
For example, the string `'foo[bar]=baz'` converts to:
|
||||
|
||||
```javascript
|
||||
assert.deepEqual(qs.parse('foo[bar]=baz'), {
|
||||
foo: {
|
||||
bar: 'baz'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
When using the `plainObjects` option the parsed value is returned as a null object, created via `Object.create(null)` and as such you should be aware that prototype methods will not exist on it and a user may set those names to whatever value they like:
|
||||
|
||||
```javascript
|
||||
var nullObject = qs.parse('a[hasOwnProperty]=b', { plainObjects: true });
|
||||
assert.deepEqual(nullObject, { a: { hasOwnProperty: 'b' } });
|
||||
```
|
||||
|
||||
By default parameters that would overwrite properties on the object prototype are ignored, if you wish to keep the data from those fields either use `plainObjects` as mentioned above, or set `allowPrototypes` to `true` which will allow user input to overwrite those properties. *WARNING* It is generally a bad idea to enable this option as it can cause problems when attempting to use the properties that have been overwritten. Always be careful with this option.
|
||||
|
||||
```javascript
|
||||
var protoObject = qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true });
|
||||
assert.deepEqual(protoObject, { a: { hasOwnProperty: 'b' } });
|
||||
```
|
||||
|
||||
URI encoded strings work too:
|
||||
|
||||
```javascript
|
||||
assert.deepEqual(qs.parse('a%5Bb%5D=c'), {
|
||||
a: { b: 'c' }
|
||||
});
|
||||
```
|
||||
|
||||
You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:
|
||||
|
||||
```javascript
|
||||
assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), {
|
||||
foo: {
|
||||
bar: {
|
||||
baz: 'foobarbaz'
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
By default, when nesting objects **qs** will only parse up to 5 children deep. This means if you attempt to parse a string like
|
||||
`'a[b][c][d][e][f][g][h][i]=j'` your resulting object will be:
|
||||
|
||||
```javascript
|
||||
var expected = {
|
||||
a: {
|
||||
b: {
|
||||
c: {
|
||||
d: {
|
||||
e: {
|
||||
f: {
|
||||
'[g][h][i]': 'j'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var string = 'a[b][c][d][e][f][g][h][i]=j';
|
||||
assert.deepEqual(qs.parse(string), expected);
|
||||
```
|
||||
|
||||
This depth can be overridden by passing a `depth` option to `qs.parse(string, [options])`:
|
||||
|
||||
```javascript
|
||||
var deep = qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 });
|
||||
assert.deepEqual(deep, { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } });
|
||||
```
|
||||
|
||||
The depth limit helps mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.
|
||||
|
||||
For similar reasons, by default **qs** will only parse up to 1000 parameters. This can be overridden by passing a `parameterLimit` option:
|
||||
|
||||
```javascript
|
||||
var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
|
||||
assert.deepEqual(limited, { a: 'b' });
|
||||
```
|
||||
|
||||
To bypass the leading question mark, use `ignoreQueryPrefix`:
|
||||
|
||||
```javascript
|
||||
var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true });
|
||||
assert.deepEqual(prefixed, { a: 'b', c: 'd' });
|
||||
```
|
||||
|
||||
An optional delimiter can also be passed:
|
||||
|
||||
```javascript
|
||||
var delimited = qs.parse('a=b;c=d', { delimiter: ';' });
|
||||
assert.deepEqual(delimited, { a: 'b', c: 'd' });
|
||||
```
|
||||
|
||||
Delimiters can be a regular expression too:
|
||||
|
||||
```javascript
|
||||
var regexed = qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ });
|
||||
assert.deepEqual(regexed, { a: 'b', c: 'd', e: 'f' });
|
||||
```
|
||||
|
||||
Option `allowDots` can be used to enable dot notation:
|
||||
|
||||
```javascript
|
||||
var withDots = qs.parse('a.b=c', { allowDots: true });
|
||||
assert.deepEqual(withDots, { a: { b: 'c' } });
|
||||
```
|
||||
|
||||
### Parsing Arrays
|
||||
|
||||
**qs** can also parse arrays using a similar `[]` notation:
|
||||
|
||||
```javascript
|
||||
var withArray = qs.parse('a[]=b&a[]=c');
|
||||
assert.deepEqual(withArray, { a: ['b', 'c'] });
|
||||
```
|
||||
|
||||
You may specify an index as well:
|
||||
|
||||
```javascript
|
||||
var withIndexes = qs.parse('a[1]=c&a[0]=b');
|
||||
assert.deepEqual(withIndexes, { a: ['b', 'c'] });
|
||||
```
|
||||
|
||||
Note that the only difference between an index in an array and a key in an object is that the value between the brackets must be a number
|
||||
to create an array. When creating arrays with specific indices, **qs** will compact a sparse array to only the existing values preserving
|
||||
their order:
|
||||
|
||||
```javascript
|
||||
var noSparse = qs.parse('a[1]=b&a[15]=c');
|
||||
assert.deepEqual(noSparse, { a: ['b', 'c'] });
|
||||
```
|
||||
|
||||
Note that an empty string is also a value, and will be preserved:
|
||||
|
||||
```javascript
|
||||
var withEmptyString = qs.parse('a[]=&a[]=b');
|
||||
assert.deepEqual(withEmptyString, { a: ['', 'b'] });
|
||||
|
||||
var withIndexedEmptyString = qs.parse('a[0]=b&a[1]=&a[2]=c');
|
||||
assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] });
|
||||
```
|
||||
|
||||
**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will
|
||||
instead be converted to an object with the index as the key:
|
||||
|
||||
```javascript
|
||||
var withMaxIndex = qs.parse('a[100]=b');
|
||||
assert.deepEqual(withMaxIndex, { a: { '100': 'b' } });
|
||||
```
|
||||
|
||||
This limit can be overridden by passing an `arrayLimit` option:
|
||||
|
||||
```javascript
|
||||
var withArrayLimit = qs.parse('a[1]=b', { arrayLimit: 0 });
|
||||
assert.deepEqual(withArrayLimit, { a: { '1': 'b' } });
|
||||
```
|
||||
|
||||
To disable array parsing entirely, set `parseArrays` to `false`.
|
||||
|
||||
```javascript
|
||||
var noParsingArrays = qs.parse('a[]=b', { parseArrays: false });
|
||||
assert.deepEqual(noParsingArrays, { a: { '0': 'b' } });
|
||||
```
|
||||
|
||||
If you mix notations, **qs** will merge the two items into an object:
|
||||
|
||||
```javascript
|
||||
var mixedNotation = qs.parse('a[0]=b&a[b]=c');
|
||||
assert.deepEqual(mixedNotation, { a: { '0': 'b', b: 'c' } });
|
||||
```
|
||||
|
||||
You can also create arrays of objects:
|
||||
|
||||
```javascript
|
||||
var arraysOfObjects = qs.parse('a[][b]=c');
|
||||
assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] });
|
||||
```
|
||||
|
||||
### Stringifying
|
||||
|
||||
[](#preventEval)
|
||||
```javascript
|
||||
qs.stringify(object, [options]);
|
||||
```
|
||||
|
||||
When stringifying, **qs** by default URI encodes output. Objects are stringified as you would expect:
|
||||
|
||||
```javascript
|
||||
assert.equal(qs.stringify({ a: 'b' }), 'a=b');
|
||||
assert.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
|
||||
```
|
||||
|
||||
This encoding can be disabled by setting the `encode` option to `false`:
|
||||
|
||||
```javascript
|
||||
var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false });
|
||||
assert.equal(unencoded, 'a[b]=c');
|
||||
```
|
||||
|
||||
Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`:
|
||||
```javascript
|
||||
var encodedValues = qs.stringify(
|
||||
{ a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
|
||||
{ encodeValuesOnly: true }
|
||||
);
|
||||
assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
|
||||
```
|
||||
|
||||
This encoding can also be replaced by a custom encoding method set as `encoder` option:
|
||||
|
||||
```javascript
|
||||
var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) {
|
||||
// Passed in values `a`, `b`, `c`
|
||||
return // Return encoded string
|
||||
}})
|
||||
```
|
||||
|
||||
_(Note: the `encoder` option does not apply if `encode` is `false`)_
|
||||
|
||||
Analogue to the `encoder` there is a `decoder` option for `parse` to override decoding of properties and values:
|
||||
|
||||
```javascript
|
||||
var decoded = qs.parse('x=z', { decoder: function (str) {
|
||||
// Passed in values `x`, `z`
|
||||
return // Return decoded string
|
||||
}})
|
||||
```
|
||||
|
||||
Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage.
|
||||
|
||||
When arrays are stringified, by default they are given explicit indices:
|
||||
|
||||
```javascript
|
||||
qs.stringify({ a: ['b', 'c', 'd'] });
|
||||
// 'a[0]=b&a[1]=c&a[2]=d'
|
||||
```
|
||||
|
||||
You may override this by setting the `indices` option to `false`:
|
||||
|
||||
```javascript
|
||||
qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false });
|
||||
// 'a=b&a=c&a=d'
|
||||
```
|
||||
|
||||
You may use the `arrayFormat` option to specify the format of the output array:
|
||||
|
||||
```javascript
|
||||
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
|
||||
// 'a[0]=b&a[1]=c'
|
||||
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
|
||||
// 'a[]=b&a[]=c'
|
||||
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
|
||||
// 'a=b&a=c'
|
||||
```
|
||||
|
||||
When objects are stringified, by default they use bracket notation:
|
||||
|
||||
```javascript
|
||||
qs.stringify({ a: { b: { c: 'd', e: 'f' } } });
|
||||
// 'a[b][c]=d&a[b][e]=f'
|
||||
```
|
||||
|
||||
You may override this to use dot notation by setting the `allowDots` option to `true`:
|
||||
|
||||
```javascript
|
||||
qs.stringify({ a: { b: { c: 'd', e: 'f' } } }, { allowDots: true });
|
||||
// 'a.b.c=d&a.b.e=f'
|
||||
```
|
||||
|
||||
Empty strings and null values will omit the value, but the equals sign (=) remains in place:
|
||||
|
||||
```javascript
|
||||
assert.equal(qs.stringify({ a: '' }), 'a=');
|
||||
```
|
||||
|
||||
Key with no values (such as an empty object or array) will return nothing:
|
||||
|
||||
```javascript
|
||||
assert.equal(qs.stringify({ a: [] }), '');
|
||||
assert.equal(qs.stringify({ a: {} }), '');
|
||||
assert.equal(qs.stringify({ a: [{}] }), '');
|
||||
assert.equal(qs.stringify({ a: { b: []} }), '');
|
||||
assert.equal(qs.stringify({ a: { b: {}} }), '');
|
||||
```
|
||||
|
||||
Properties that are set to `undefined` will be omitted entirely:
|
||||
|
||||
```javascript
|
||||
assert.equal(qs.stringify({ a: null, b: undefined }), 'a=');
|
||||
```
|
||||
|
||||
The query string may optionally be prepended with a question mark:
|
||||
|
||||
```javascript
|
||||
assert.equal(qs.stringify({ a: 'b', c: 'd' }, { addQueryPrefix: true }), '?a=b&c=d');
|
||||
```
|
||||
|
||||
The delimiter may be overridden with stringify as well:
|
||||
|
||||
```javascript
|
||||
assert.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d');
|
||||
```
|
||||
|
||||
If you only want to override the serialization of `Date` objects, you can provide a `serializeDate` option:
|
||||
|
||||
```javascript
|
||||
var date = new Date(7);
|
||||
assert.equal(qs.stringify({ a: date }), 'a=1970-01-01T00:00:00.007Z'.replace(/:/g, '%3A'));
|
||||
assert.equal(
|
||||
qs.stringify({ a: date }, { serializeDate: function (d) { return d.getTime(); } }),
|
||||
'a=7'
|
||||
);
|
||||
```
|
||||
|
||||
You may use the `sort` option to affect the order of parameter keys:
|
||||
|
||||
```javascript
|
||||
function alphabeticalSort(a, b) {
|
||||
return a.localeCompare(b);
|
||||
}
|
||||
assert.equal(qs.stringify({ a: 'c', z: 'y', b : 'f' }, { sort: alphabeticalSort }), 'a=c&b=f&z=y');
|
||||
```
|
||||
|
||||
Finally, you can use the `filter` option to restrict which keys will be included in the stringified output.
|
||||
If you pass a function, it will be called for each key to obtain the replacement value. Otherwise, if you
|
||||
pass an array, it will be used to select properties and array indices for stringification:
|
||||
|
||||
```javascript
|
||||
function filterFunc(prefix, value) {
|
||||
if (prefix == 'b') {
|
||||
// Return an `undefined` value to omit a property.
|
||||
return;
|
||||
}
|
||||
if (prefix == 'e[f]') {
|
||||
return value.getTime();
|
||||
}
|
||||
if (prefix == 'e[g][0]') {
|
||||
return value * 2;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: filterFunc });
|
||||
// 'a=b&c=d&e[f]=123&e[g][0]=4'
|
||||
qs.stringify({ a: 'b', c: 'd', e: 'f' }, { filter: ['a', 'e'] });
|
||||
// 'a=b&e=f'
|
||||
qs.stringify({ a: ['b', 'c', 'd'], e: 'f' }, { filter: ['a', 0, 2] });
|
||||
// 'a[0]=b&a[2]=d'
|
||||
```
|
||||
|
||||
### Handling of `null` values
|
||||
|
||||
By default, `null` values are treated like empty strings:
|
||||
|
||||
```javascript
|
||||
var withNull = qs.stringify({ a: null, b: '' });
|
||||
assert.equal(withNull, 'a=&b=');
|
||||
```
|
||||
|
||||
Parsing does not distinguish between parameters with and without equal signs. Both are converted to empty strings.
|
||||
|
||||
```javascript
|
||||
var equalsInsensitive = qs.parse('a&b=');
|
||||
assert.deepEqual(equalsInsensitive, { a: '', b: '' });
|
||||
```
|
||||
|
||||
To distinguish between `null` values and empty strings use the `strictNullHandling` flag. In the result string the `null`
|
||||
values have no `=` sign:
|
||||
|
||||
```javascript
|
||||
var strictNull = qs.stringify({ a: null, b: '' }, { strictNullHandling: true });
|
||||
assert.equal(strictNull, 'a&b=');
|
||||
```
|
||||
|
||||
To parse values without `=` back to `null` use the `strictNullHandling` flag:
|
||||
|
||||
```javascript
|
||||
var parsedStrictNull = qs.parse('a&b=', { strictNullHandling: true });
|
||||
assert.deepEqual(parsedStrictNull, { a: null, b: '' });
|
||||
```
|
||||
|
||||
To completely skip rendering keys with `null` values, use the `skipNulls` flag:
|
||||
|
||||
```javascript
|
||||
var nullsSkipped = qs.stringify({ a: 'b', c: null}, { skipNulls: true });
|
||||
assert.equal(nullsSkipped, 'a=b');
|
||||
```
|
||||
|
||||
### Dealing with special character sets
|
||||
|
||||
By default the encoding and decoding of characters is done in `utf-8`. If you
|
||||
wish to encode querystrings to a different character set (i.e.
|
||||
[Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the
|
||||
[`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library:
|
||||
|
||||
```javascript
|
||||
var encoder = require('qs-iconv/encoder')('shift_jis');
|
||||
var shiftJISEncoded = qs.stringify({ a: 'こんにちは!' }, { encoder: encoder });
|
||||
assert.equal(shiftJISEncoded, 'a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I');
|
||||
```
|
||||
|
||||
This also works for decoding of query strings:
|
||||
|
||||
```javascript
|
||||
var decoder = require('qs-iconv/decoder')('shift_jis');
|
||||
var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder });
|
||||
assert.deepEqual(obj, { a: 'こんにちは!' });
|
||||
```
|
||||
|
||||
### RFC 3986 and RFC 1738 space encoding
|
||||
|
||||
RFC3986 used as default option and encodes ' ' to *%20* which is backward compatible.
|
||||
In the same time, output can be stringified as per RFC1738 with ' ' equal to '+'.
|
||||
|
||||
```
|
||||
assert.equal(qs.stringify({ a: 'b c' }), 'a=b%20c');
|
||||
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
|
||||
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
|
||||
```
|
||||
|
||||
[1]: https://npmjs.org/package/qs
|
||||
[2]: http://versionbadg.es/ljharb/qs.svg
|
||||
[3]: https://api.travis-ci.org/ljharb/qs.svg
|
||||
[4]: https://travis-ci.org/ljharb/qs
|
||||
[5]: https://david-dm.org/ljharb/qs.svg
|
||||
[6]: https://david-dm.org/ljharb/qs
|
||||
[7]: https://david-dm.org/ljharb/qs/dev-status.svg
|
||||
[8]: https://david-dm.org/ljharb/qs?type=dev
|
||||
[9]: https://ci.testling.com/ljharb/qs.png
|
||||
[10]: https://ci.testling.com/ljharb/qs
|
||||
[11]: https://nodei.co/npm/qs.png?downloads=true&stars=true
|
||||
[license-image]: http://img.shields.io/npm/l/qs.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: http://img.shields.io/npm/dm/qs.svg
|
||||
[downloads-url]: http://npm-stat.com/charts.html?package=qs
|
615
express-server/node_modules/express/node_modules/qs/dist/qs.js
generated
vendored
Normal file
615
express-server/node_modules/express/node_modules/qs/dist/qs.js
generated
vendored
Normal file
@ -0,0 +1,615 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
var replace = String.prototype.replace;
|
||||
var percentTwenties = /%20/g;
|
||||
|
||||
module.exports = {
|
||||
'default': 'RFC3986',
|
||||
formatters: {
|
||||
RFC1738: function (value) {
|
||||
return replace.call(value, percentTwenties, '+');
|
||||
},
|
||||
RFC3986: function (value) {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
RFC1738: 'RFC1738',
|
||||
RFC3986: 'RFC3986'
|
||||
};
|
||||
|
||||
},{}],2:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
var stringify = require('./stringify');
|
||||
var parse = require('./parse');
|
||||
var formats = require('./formats');
|
||||
|
||||
module.exports = {
|
||||
formats: formats,
|
||||
parse: parse,
|
||||
stringify: stringify
|
||||
};
|
||||
|
||||
},{"./formats":1,"./parse":3,"./stringify":4}],3:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
var defaults = {
|
||||
allowDots: false,
|
||||
allowPrototypes: false,
|
||||
arrayLimit: 20,
|
||||
decoder: utils.decode,
|
||||
delimiter: '&',
|
||||
depth: 5,
|
||||
parameterLimit: 1000,
|
||||
plainObjects: false,
|
||||
strictNullHandling: false
|
||||
};
|
||||
|
||||
var parseValues = function parseQueryStringValues(str, options) {
|
||||
var obj = {};
|
||||
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
||||
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
||||
var parts = cleanStr.split(options.delimiter, limit);
|
||||
|
||||
for (var i = 0; i < parts.length; ++i) {
|
||||
var part = parts[i];
|
||||
|
||||
var bracketEqualsPos = part.indexOf(']=');
|
||||
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
||||
|
||||
var key, val;
|
||||
if (pos === -1) {
|
||||
key = options.decoder(part, defaults.decoder);
|
||||
val = options.strictNullHandling ? null : '';
|
||||
} else {
|
||||
key = options.decoder(part.slice(0, pos), defaults.decoder);
|
||||
val = options.decoder(part.slice(pos + 1), defaults.decoder);
|
||||
}
|
||||
if (has.call(obj, key)) {
|
||||
obj[key] = [].concat(obj[key]).concat(val);
|
||||
} else {
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var parseObject = function parseObjectRecursive(chain, val, options) {
|
||||
if (!chain.length) {
|
||||
return val;
|
||||
}
|
||||
|
||||
var root = chain.shift();
|
||||
|
||||
var obj;
|
||||
if (root === '[]') {
|
||||
obj = [];
|
||||
obj = obj.concat(parseObject(chain, val, options));
|
||||
} else {
|
||||
obj = options.plainObjects ? Object.create(null) : {};
|
||||
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
||||
var index = parseInt(cleanRoot, 10);
|
||||
if (
|
||||
!isNaN(index)
|
||||
&& root !== cleanRoot
|
||||
&& String(index) === cleanRoot
|
||||
&& index >= 0
|
||||
&& (options.parseArrays && index <= options.arrayLimit)
|
||||
) {
|
||||
obj = [];
|
||||
obj[index] = parseObject(chain, val, options);
|
||||
} else {
|
||||
obj[cleanRoot] = parseObject(chain, val, options);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
|
||||
if (!givenKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Transform dot notation to bracket notation
|
||||
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
||||
|
||||
// The regex chunks
|
||||
|
||||
var brackets = /(\[[^[\]]*])/;
|
||||
var child = /(\[[^[\]]*])/g;
|
||||
|
||||
// Get the parent
|
||||
|
||||
var segment = brackets.exec(key);
|
||||
var parent = segment ? key.slice(0, segment.index) : key;
|
||||
|
||||
// Stash the parent if it exists
|
||||
|
||||
var keys = [];
|
||||
if (parent) {
|
||||
// If we aren't using plain objects, optionally prefix keys
|
||||
// that would overwrite object prototype properties
|
||||
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
||||
if (!options.allowPrototypes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
keys.push(parent);
|
||||
}
|
||||
|
||||
// Loop through children appending to the array until we hit depth
|
||||
|
||||
var i = 0;
|
||||
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
||||
i += 1;
|
||||
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
||||
if (!options.allowPrototypes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
keys.push(segment[1]);
|
||||
}
|
||||
|
||||
// If there's a remainder, just add whatever is left
|
||||
|
||||
if (segment) {
|
||||
keys.push('[' + key.slice(segment.index) + ']');
|
||||
}
|
||||
|
||||
return parseObject(keys, val, options);
|
||||
};
|
||||
|
||||
module.exports = function (str, opts) {
|
||||
var options = opts ? utils.assign({}, opts) : {};
|
||||
|
||||
if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
|
||||
throw new TypeError('Decoder has to be a function.');
|
||||
}
|
||||
|
||||
options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;
|
||||
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
|
||||
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
|
||||
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
|
||||
options.parseArrays = options.parseArrays !== false;
|
||||
options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
|
||||
options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
|
||||
options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
|
||||
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
|
||||
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
|
||||
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
||||
|
||||
if (str === '' || str === null || typeof str === 'undefined') {
|
||||
return options.plainObjects ? Object.create(null) : {};
|
||||
}
|
||||
|
||||
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
||||
var obj = options.plainObjects ? Object.create(null) : {};
|
||||
|
||||
// Iterate over the keys and setup the new object
|
||||
|
||||
var keys = Object.keys(tempObj);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
var newObj = parseKeys(key, tempObj[key], options);
|
||||
obj = utils.merge(obj, newObj, options);
|
||||
}
|
||||
|
||||
return utils.compact(obj);
|
||||
};
|
||||
|
||||
},{"./utils":5}],4:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
var formats = require('./formats');
|
||||
|
||||
var arrayPrefixGenerators = {
|
||||
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
|
||||
return prefix + '[]';
|
||||
},
|
||||
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
|
||||
return prefix + '[' + key + ']';
|
||||
},
|
||||
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
|
||||
return prefix;
|
||||
}
|
||||
};
|
||||
|
||||
var toISO = Date.prototype.toISOString;
|
||||
|
||||
var defaults = {
|
||||
delimiter: '&',
|
||||
encode: true,
|
||||
encoder: utils.encode,
|
||||
encodeValuesOnly: false,
|
||||
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
|
||||
return toISO.call(date);
|
||||
},
|
||||
skipNulls: false,
|
||||
strictNullHandling: false
|
||||
};
|
||||
|
||||
var stringify = function stringify( // eslint-disable-line func-name-matching
|
||||
object,
|
||||
prefix,
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encoder,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
) {
|
||||
var obj = object;
|
||||
if (typeof filter === 'function') {
|
||||
obj = filter(prefix, obj);
|
||||
} else if (obj instanceof Date) {
|
||||
obj = serializeDate(obj);
|
||||
} else if (obj === null) {
|
||||
if (strictNullHandling) {
|
||||
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder) : prefix;
|
||||
}
|
||||
|
||||
obj = '';
|
||||
}
|
||||
|
||||
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
|
||||
if (encoder) {
|
||||
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder);
|
||||
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))];
|
||||
}
|
||||
return [formatter(prefix) + '=' + formatter(String(obj))];
|
||||
}
|
||||
|
||||
var values = [];
|
||||
|
||||
if (typeof obj === 'undefined') {
|
||||
return values;
|
||||
}
|
||||
|
||||
var objKeys;
|
||||
if (Array.isArray(filter)) {
|
||||
objKeys = filter;
|
||||
} else {
|
||||
var keys = Object.keys(obj);
|
||||
objKeys = sort ? keys.sort(sort) : keys;
|
||||
}
|
||||
|
||||
for (var i = 0; i < objKeys.length; ++i) {
|
||||
var key = objKeys[i];
|
||||
|
||||
if (skipNulls && obj[key] === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
values = values.concat(stringify(
|
||||
obj[key],
|
||||
generateArrayPrefix(prefix, key),
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encoder,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
));
|
||||
} else {
|
||||
values = values.concat(stringify(
|
||||
obj[key],
|
||||
prefix + (allowDots ? '.' + key : '[' + key + ']'),
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encoder,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
};
|
||||
|
||||
module.exports = function (object, opts) {
|
||||
var obj = object;
|
||||
var options = opts ? utils.assign({}, opts) : {};
|
||||
|
||||
if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
|
||||
throw new TypeError('Encoder has to be a function.');
|
||||
}
|
||||
|
||||
var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
|
||||
var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
||||
var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
|
||||
var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
|
||||
var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder;
|
||||
var sort = typeof options.sort === 'function' ? options.sort : null;
|
||||
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
|
||||
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
|
||||
var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly;
|
||||
if (typeof options.format === 'undefined') {
|
||||
options.format = formats.default;
|
||||
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
|
||||
throw new TypeError('Unknown format option provided.');
|
||||
}
|
||||
var formatter = formats.formatters[options.format];
|
||||
var objKeys;
|
||||
var filter;
|
||||
|
||||
if (typeof options.filter === 'function') {
|
||||
filter = options.filter;
|
||||
obj = filter('', obj);
|
||||
} else if (Array.isArray(options.filter)) {
|
||||
filter = options.filter;
|
||||
objKeys = filter;
|
||||
}
|
||||
|
||||
var keys = [];
|
||||
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var arrayFormat;
|
||||
if (options.arrayFormat in arrayPrefixGenerators) {
|
||||
arrayFormat = options.arrayFormat;
|
||||
} else if ('indices' in options) {
|
||||
arrayFormat = options.indices ? 'indices' : 'repeat';
|
||||
} else {
|
||||
arrayFormat = 'indices';
|
||||
}
|
||||
|
||||
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
||||
|
||||
if (!objKeys) {
|
||||
objKeys = Object.keys(obj);
|
||||
}
|
||||
|
||||
if (sort) {
|
||||
objKeys.sort(sort);
|
||||
}
|
||||
|
||||
for (var i = 0; i < objKeys.length; ++i) {
|
||||
var key = objKeys[i];
|
||||
|
||||
if (skipNulls && obj[key] === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
keys = keys.concat(stringify(
|
||||
obj[key],
|
||||
key,
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encode ? encoder : null,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
));
|
||||
}
|
||||
|
||||
var joined = keys.join(delimiter);
|
||||
var prefix = options.addQueryPrefix === true ? '?' : '';
|
||||
|
||||
return joined.length > 0 ? prefix + joined : '';
|
||||
};
|
||||
|
||||
},{"./formats":1,"./utils":5}],5:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
var hexTable = (function () {
|
||||
var array = [];
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
||||
}
|
||||
|
||||
return array;
|
||||
}());
|
||||
|
||||
exports.arrayToObject = function (source, options) {
|
||||
var obj = options && options.plainObjects ? Object.create(null) : {};
|
||||
for (var i = 0; i < source.length; ++i) {
|
||||
if (typeof source[i] !== 'undefined') {
|
||||
obj[i] = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
exports.merge = function (target, source, options) {
|
||||
if (!source) {
|
||||
return target;
|
||||
}
|
||||
|
||||
if (typeof source !== 'object') {
|
||||
if (Array.isArray(target)) {
|
||||
target.push(source);
|
||||
} else if (typeof target === 'object') {
|
||||
if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
|
||||
target[source] = true;
|
||||
}
|
||||
} else {
|
||||
return [target, source];
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
if (typeof target !== 'object') {
|
||||
return [target].concat(source);
|
||||
}
|
||||
|
||||
var mergeTarget = target;
|
||||
if (Array.isArray(target) && !Array.isArray(source)) {
|
||||
mergeTarget = exports.arrayToObject(target, options);
|
||||
}
|
||||
|
||||
if (Array.isArray(target) && Array.isArray(source)) {
|
||||
source.forEach(function (item, i) {
|
||||
if (has.call(target, i)) {
|
||||
if (target[i] && typeof target[i] === 'object') {
|
||||
target[i] = exports.merge(target[i], item, options);
|
||||
} else {
|
||||
target.push(item);
|
||||
}
|
||||
} else {
|
||||
target[i] = item;
|
||||
}
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
return Object.keys(source).reduce(function (acc, key) {
|
||||
var value = source[key];
|
||||
|
||||
if (has.call(acc, key)) {
|
||||
acc[key] = exports.merge(acc[key], value, options);
|
||||
} else {
|
||||
acc[key] = value;
|
||||
}
|
||||
return acc;
|
||||
}, mergeTarget);
|
||||
};
|
||||
|
||||
exports.assign = function assignSingleSource(target, source) {
|
||||
return Object.keys(source).reduce(function (acc, key) {
|
||||
acc[key] = source[key];
|
||||
return acc;
|
||||
}, target);
|
||||
};
|
||||
|
||||
exports.decode = function (str) {
|
||||
try {
|
||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
exports.encode = function (str) {
|
||||
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
||||
// It has been adapted here for stricter adherence to RFC 3986
|
||||
if (str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
var string = typeof str === 'string' ? str : String(str);
|
||||
|
||||
var out = '';
|
||||
for (var i = 0; i < string.length; ++i) {
|
||||
var c = string.charCodeAt(i);
|
||||
|
||||
if (
|
||||
c === 0x2D // -
|
||||
|| c === 0x2E // .
|
||||
|| c === 0x5F // _
|
||||
|| c === 0x7E // ~
|
||||
|| (c >= 0x30 && c <= 0x39) // 0-9
|
||||
|| (c >= 0x41 && c <= 0x5A) // a-z
|
||||
|| (c >= 0x61 && c <= 0x7A) // A-Z
|
||||
) {
|
||||
out += string.charAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < 0x80) {
|
||||
out = out + hexTable[c];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < 0x800) {
|
||||
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < 0xD800 || c >= 0xE000) {
|
||||
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
|
||||
continue;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
||||
out += hexTable[0xF0 | (c >> 18)]
|
||||
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
|
||||
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
|
||||
+ hexTable[0x80 | (c & 0x3F)];
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
exports.compact = function (obj, references) {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
var refs = references || [];
|
||||
var lookup = refs.indexOf(obj);
|
||||
if (lookup !== -1) {
|
||||
return refs[lookup];
|
||||
}
|
||||
|
||||
refs.push(obj);
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
var compacted = [];
|
||||
|
||||
for (var i = 0; i < obj.length; ++i) {
|
||||
if (obj[i] && typeof obj[i] === 'object') {
|
||||
compacted.push(exports.compact(obj[i], refs));
|
||||
} else if (typeof obj[i] !== 'undefined') {
|
||||
compacted.push(obj[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return compacted;
|
||||
}
|
||||
|
||||
var keys = Object.keys(obj);
|
||||
keys.forEach(function (key) {
|
||||
obj[key] = exports.compact(obj[key], refs);
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
exports.isRegExp = function (obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||
};
|
||||
|
||||
exports.isBuffer = function (obj) {
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
||||
};
|
||||
|
||||
},{}]},{},[2])(2)
|
||||
});
|
18
express-server/node_modules/express/node_modules/qs/lib/formats.js
generated
vendored
Normal file
18
express-server/node_modules/express/node_modules/qs/lib/formats.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var replace = String.prototype.replace;
|
||||
var percentTwenties = /%20/g;
|
||||
|
||||
module.exports = {
|
||||
'default': 'RFC3986',
|
||||
formatters: {
|
||||
RFC1738: function (value) {
|
||||
return replace.call(value, percentTwenties, '+');
|
||||
},
|
||||
RFC3986: function (value) {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
RFC1738: 'RFC1738',
|
||||
RFC3986: 'RFC3986'
|
||||
};
|
11
express-server/node_modules/express/node_modules/qs/lib/index.js
generated
vendored
Normal file
11
express-server/node_modules/express/node_modules/qs/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var stringify = require('./stringify');
|
||||
var parse = require('./parse');
|
||||
var formats = require('./formats');
|
||||
|
||||
module.exports = {
|
||||
formats: formats,
|
||||
parse: parse,
|
||||
stringify: stringify
|
||||
};
|
172
express-server/node_modules/express/node_modules/qs/lib/parse.js
generated
vendored
Normal file
172
express-server/node_modules/express/node_modules/qs/lib/parse.js
generated
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
var defaults = {
|
||||
allowDots: false,
|
||||
allowPrototypes: false,
|
||||
arrayLimit: 20,
|
||||
decoder: utils.decode,
|
||||
delimiter: '&',
|
||||
depth: 5,
|
||||
parameterLimit: 1000,
|
||||
plainObjects: false,
|
||||
strictNullHandling: false
|
||||
};
|
||||
|
||||
var parseValues = function parseQueryStringValues(str, options) {
|
||||
var obj = {};
|
||||
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
||||
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
||||
var parts = cleanStr.split(options.delimiter, limit);
|
||||
|
||||
for (var i = 0; i < parts.length; ++i) {
|
||||
var part = parts[i];
|
||||
|
||||
var bracketEqualsPos = part.indexOf(']=');
|
||||
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
||||
|
||||
var key, val;
|
||||
if (pos === -1) {
|
||||
key = options.decoder(part, defaults.decoder);
|
||||
val = options.strictNullHandling ? null : '';
|
||||
} else {
|
||||
key = options.decoder(part.slice(0, pos), defaults.decoder);
|
||||
val = options.decoder(part.slice(pos + 1), defaults.decoder);
|
||||
}
|
||||
if (has.call(obj, key)) {
|
||||
obj[key] = [].concat(obj[key]).concat(val);
|
||||
} else {
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var parseObject = function parseObjectRecursive(chain, val, options) {
|
||||
if (!chain.length) {
|
||||
return val;
|
||||
}
|
||||
|
||||
var root = chain.shift();
|
||||
|
||||
var obj;
|
||||
if (root === '[]') {
|
||||
obj = [];
|
||||
obj = obj.concat(parseObject(chain, val, options));
|
||||
} else {
|
||||
obj = options.plainObjects ? Object.create(null) : {};
|
||||
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
||||
var index = parseInt(cleanRoot, 10);
|
||||
if (
|
||||
!isNaN(index)
|
||||
&& root !== cleanRoot
|
||||
&& String(index) === cleanRoot
|
||||
&& index >= 0
|
||||
&& (options.parseArrays && index <= options.arrayLimit)
|
||||
) {
|
||||
obj = [];
|
||||
obj[index] = parseObject(chain, val, options);
|
||||
} else {
|
||||
obj[cleanRoot] = parseObject(chain, val, options);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
|
||||
if (!givenKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Transform dot notation to bracket notation
|
||||
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
||||
|
||||
// The regex chunks
|
||||
|
||||
var brackets = /(\[[^[\]]*])/;
|
||||
var child = /(\[[^[\]]*])/g;
|
||||
|
||||
// Get the parent
|
||||
|
||||
var segment = brackets.exec(key);
|
||||
var parent = segment ? key.slice(0, segment.index) : key;
|
||||
|
||||
// Stash the parent if it exists
|
||||
|
||||
var keys = [];
|
||||
if (parent) {
|
||||
// If we aren't using plain objects, optionally prefix keys
|
||||
// that would overwrite object prototype properties
|
||||
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
||||
if (!options.allowPrototypes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
keys.push(parent);
|
||||
}
|
||||
|
||||
// Loop through children appending to the array until we hit depth
|
||||
|
||||
var i = 0;
|
||||
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
||||
i += 1;
|
||||
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
||||
if (!options.allowPrototypes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
keys.push(segment[1]);
|
||||
}
|
||||
|
||||
// If there's a remainder, just add whatever is left
|
||||
|
||||
if (segment) {
|
||||
keys.push('[' + key.slice(segment.index) + ']');
|
||||
}
|
||||
|
||||
return parseObject(keys, val, options);
|
||||
};
|
||||
|
||||
module.exports = function (str, opts) {
|
||||
var options = opts ? utils.assign({}, opts) : {};
|
||||
|
||||
if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
|
||||
throw new TypeError('Decoder has to be a function.');
|
||||
}
|
||||
|
||||
options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;
|
||||
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
|
||||
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
|
||||
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
|
||||
options.parseArrays = options.parseArrays !== false;
|
||||
options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
|
||||
options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
|
||||
options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
|
||||
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
|
||||
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
|
||||
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
||||
|
||||
if (str === '' || str === null || typeof str === 'undefined') {
|
||||
return options.plainObjects ? Object.create(null) : {};
|
||||
}
|
||||
|
||||
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
||||
var obj = options.plainObjects ? Object.create(null) : {};
|
||||
|
||||
// Iterate over the keys and setup the new object
|
||||
|
||||
var keys = Object.keys(tempObj);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
var newObj = parseKeys(key, tempObj[key], options);
|
||||
obj = utils.merge(obj, newObj, options);
|
||||
}
|
||||
|
||||
return utils.compact(obj);
|
||||
};
|
210
express-server/node_modules/express/node_modules/qs/lib/stringify.js
generated
vendored
Normal file
210
express-server/node_modules/express/node_modules/qs/lib/stringify.js
generated
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
var formats = require('./formats');
|
||||
|
||||
var arrayPrefixGenerators = {
|
||||
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
|
||||
return prefix + '[]';
|
||||
},
|
||||
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
|
||||
return prefix + '[' + key + ']';
|
||||
},
|
||||
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
|
||||
return prefix;
|
||||
}
|
||||
};
|
||||
|
||||
var toISO = Date.prototype.toISOString;
|
||||
|
||||
var defaults = {
|
||||
delimiter: '&',
|
||||
encode: true,
|
||||
encoder: utils.encode,
|
||||
encodeValuesOnly: false,
|
||||
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
|
||||
return toISO.call(date);
|
||||
},
|
||||
skipNulls: false,
|
||||
strictNullHandling: false
|
||||
};
|
||||
|
||||
var stringify = function stringify( // eslint-disable-line func-name-matching
|
||||
object,
|
||||
prefix,
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encoder,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
) {
|
||||
var obj = object;
|
||||
if (typeof filter === 'function') {
|
||||
obj = filter(prefix, obj);
|
||||
} else if (obj instanceof Date) {
|
||||
obj = serializeDate(obj);
|
||||
} else if (obj === null) {
|
||||
if (strictNullHandling) {
|
||||
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder) : prefix;
|
||||
}
|
||||
|
||||
obj = '';
|
||||
}
|
||||
|
||||
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
|
||||
if (encoder) {
|
||||
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder);
|
||||
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))];
|
||||
}
|
||||
return [formatter(prefix) + '=' + formatter(String(obj))];
|
||||
}
|
||||
|
||||
var values = [];
|
||||
|
||||
if (typeof obj === 'undefined') {
|
||||
return values;
|
||||
}
|
||||
|
||||
var objKeys;
|
||||
if (Array.isArray(filter)) {
|
||||
objKeys = filter;
|
||||
} else {
|
||||
var keys = Object.keys(obj);
|
||||
objKeys = sort ? keys.sort(sort) : keys;
|
||||
}
|
||||
|
||||
for (var i = 0; i < objKeys.length; ++i) {
|
||||
var key = objKeys[i];
|
||||
|
||||
if (skipNulls && obj[key] === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
values = values.concat(stringify(
|
||||
obj[key],
|
||||
generateArrayPrefix(prefix, key),
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encoder,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
));
|
||||
} else {
|
||||
values = values.concat(stringify(
|
||||
obj[key],
|
||||
prefix + (allowDots ? '.' + key : '[' + key + ']'),
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encoder,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
};
|
||||
|
||||
module.exports = function (object, opts) {
|
||||
var obj = object;
|
||||
var options = opts ? utils.assign({}, opts) : {};
|
||||
|
||||
if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
|
||||
throw new TypeError('Encoder has to be a function.');
|
||||
}
|
||||
|
||||
var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
|
||||
var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
||||
var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
|
||||
var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
|
||||
var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder;
|
||||
var sort = typeof options.sort === 'function' ? options.sort : null;
|
||||
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
|
||||
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
|
||||
var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly;
|
||||
if (typeof options.format === 'undefined') {
|
||||
options.format = formats.default;
|
||||
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
|
||||
throw new TypeError('Unknown format option provided.');
|
||||
}
|
||||
var formatter = formats.formatters[options.format];
|
||||
var objKeys;
|
||||
var filter;
|
||||
|
||||
if (typeof options.filter === 'function') {
|
||||
filter = options.filter;
|
||||
obj = filter('', obj);
|
||||
} else if (Array.isArray(options.filter)) {
|
||||
filter = options.filter;
|
||||
objKeys = filter;
|
||||
}
|
||||
|
||||
var keys = [];
|
||||
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var arrayFormat;
|
||||
if (options.arrayFormat in arrayPrefixGenerators) {
|
||||
arrayFormat = options.arrayFormat;
|
||||
} else if ('indices' in options) {
|
||||
arrayFormat = options.indices ? 'indices' : 'repeat';
|
||||
} else {
|
||||
arrayFormat = 'indices';
|
||||
}
|
||||
|
||||
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
||||
|
||||
if (!objKeys) {
|
||||
objKeys = Object.keys(obj);
|
||||
}
|
||||
|
||||
if (sort) {
|
||||
objKeys.sort(sort);
|
||||
}
|
||||
|
||||
for (var i = 0; i < objKeys.length; ++i) {
|
||||
var key = objKeys[i];
|
||||
|
||||
if (skipNulls && obj[key] === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
keys = keys.concat(stringify(
|
||||
obj[key],
|
||||
key,
|
||||
generateArrayPrefix,
|
||||
strictNullHandling,
|
||||
skipNulls,
|
||||
encode ? encoder : null,
|
||||
filter,
|
||||
sort,
|
||||
allowDots,
|
||||
serializeDate,
|
||||
formatter,
|
||||
encodeValuesOnly
|
||||
));
|
||||
}
|
||||
|
||||
var joined = keys.join(delimiter);
|
||||
var prefix = options.addQueryPrefix === true ? '?' : '';
|
||||
|
||||
return joined.length > 0 ? prefix + joined : '';
|
||||
};
|
192
express-server/node_modules/express/node_modules/qs/lib/utils.js
generated
vendored
Normal file
192
express-server/node_modules/express/node_modules/qs/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
'use strict';
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
var hexTable = (function () {
|
||||
var array = [];
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
||||
}
|
||||
|
||||
return array;
|
||||
}());
|
||||
|
||||
exports.arrayToObject = function (source, options) {
|
||||
var obj = options && options.plainObjects ? Object.create(null) : {};
|
||||
for (var i = 0; i < source.length; ++i) {
|
||||
if (typeof source[i] !== 'undefined') {
|
||||
obj[i] = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
exports.merge = function (target, source, options) {
|
||||
if (!source) {
|
||||
return target;
|
||||
}
|
||||
|
||||
if (typeof source !== 'object') {
|
||||
if (Array.isArray(target)) {
|
||||
target.push(source);
|
||||
} else if (typeof target === 'object') {
|
||||
if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
|
||||
target[source] = true;
|
||||
}
|
||||
} else {
|
||||
return [target, source];
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
if (typeof target !== 'object') {
|
||||
return [target].concat(source);
|
||||
}
|
||||
|
||||
var mergeTarget = target;
|
||||
if (Array.isArray(target) && !Array.isArray(source)) {
|
||||
mergeTarget = exports.arrayToObject(target, options);
|
||||
}
|
||||
|
||||
if (Array.isArray(target) && Array.isArray(source)) {
|
||||
source.forEach(function (item, i) {
|
||||
if (has.call(target, i)) {
|
||||
if (target[i] && typeof target[i] === 'object') {
|
||||
target[i] = exports.merge(target[i], item, options);
|
||||
} else {
|
||||
target.push(item);
|
||||
}
|
||||
} else {
|
||||
target[i] = item;
|
||||
}
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
return Object.keys(source).reduce(function (acc, key) {
|
||||
var value = source[key];
|
||||
|
||||
if (has.call(acc, key)) {
|
||||
acc[key] = exports.merge(acc[key], value, options);
|
||||
} else {
|
||||
acc[key] = value;
|
||||
}
|
||||
return acc;
|
||||
}, mergeTarget);
|
||||
};
|
||||
|
||||
exports.assign = function assignSingleSource(target, source) {
|
||||
return Object.keys(source).reduce(function (acc, key) {
|
||||
acc[key] = source[key];
|
||||
return acc;
|
||||
}, target);
|
||||
};
|
||||
|
||||
exports.decode = function (str) {
|
||||
try {
|
||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
exports.encode = function (str) {
|
||||
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
||||
// It has been adapted here for stricter adherence to RFC 3986
|
||||
if (str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
var string = typeof str === 'string' ? str : String(str);
|
||||
|
||||
var out = '';
|
||||
for (var i = 0; i < string.length; ++i) {
|
||||
var c = string.charCodeAt(i);
|
||||
|
||||
if (
|
||||
c === 0x2D // -
|
||||
|| c === 0x2E // .
|
||||
|| c === 0x5F // _
|
||||
|| c === 0x7E // ~
|
||||
|| (c >= 0x30 && c <= 0x39) // 0-9
|
||||
|| (c >= 0x41 && c <= 0x5A) // a-z
|
||||
|| (c >= 0x61 && c <= 0x7A) // A-Z
|
||||
) {
|
||||
out += string.charAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < 0x80) {
|
||||
out = out + hexTable[c];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < 0x800) {
|
||||
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < 0xD800 || c >= 0xE000) {
|
||||
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
|
||||
continue;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
||||
out += hexTable[0xF0 | (c >> 18)]
|
||||
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
|
||||
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
|
||||
+ hexTable[0x80 | (c & 0x3F)];
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
exports.compact = function (obj, references) {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
var refs = references || [];
|
||||
var lookup = refs.indexOf(obj);
|
||||
if (lookup !== -1) {
|
||||
return refs[lookup];
|
||||
}
|
||||
|
||||
refs.push(obj);
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
var compacted = [];
|
||||
|
||||
for (var i = 0; i < obj.length; ++i) {
|
||||
if (obj[i] && typeof obj[i] === 'object') {
|
||||
compacted.push(exports.compact(obj[i], refs));
|
||||
} else if (typeof obj[i] !== 'undefined') {
|
||||
compacted.push(obj[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return compacted;
|
||||
}
|
||||
|
||||
var keys = Object.keys(obj);
|
||||
keys.forEach(function (key) {
|
||||
obj[key] = exports.compact(obj[key], refs);
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
exports.isRegExp = function (obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||
};
|
||||
|
||||
exports.isBuffer = function (obj) {
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
||||
};
|
79
express-server/node_modules/express/node_modules/qs/package.json
generated
vendored
Normal file
79
express-server/node_modules/express/node_modules/qs/package.json
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
{
|
||||
"_from": "qs@6.5.0",
|
||||
"_id": "qs@6.5.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-fjVFjW9yhqMhVGwRExCXLhJKrLlkYSaxNWdyc9rmHlrVZbk35YHH312dFd7191uQeXkI3mKLZTIbSvIeFwFemg==",
|
||||
"_location": "/express/qs",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "qs@6.5.0",
|
||||
"name": "qs",
|
||||
"escapedName": "qs",
|
||||
"rawSpec": "6.5.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "6.5.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/qs/-/qs-6.5.0.tgz",
|
||||
"_shasum": "8d04954d364def3efc55b5a0793e1e2c8b1e6e49",
|
||||
"_spec": "qs@6.5.0",
|
||||
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\express-server\\node_modules\\express",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ljharb/qs/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jordan Harband",
|
||||
"email": "ljharb@gmail.com",
|
||||
"url": "http://ljharb.codes"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^11.0.0",
|
||||
"browserify": "^14.4.0",
|
||||
"covert": "^1.1.0",
|
||||
"editorconfig-tools": "^0.1.1",
|
||||
"eslint": "^3.19.0",
|
||||
"evalmd": "^0.0.17",
|
||||
"iconv-lite": "^0.4.18",
|
||||
"mkdirp": "^0.5.1",
|
||||
"qs-iconv": "^1.0.4",
|
||||
"safe-publish-latest": "^1.1.1",
|
||||
"tape": "^4.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"homepage": "https://github.com/ljharb/qs",
|
||||
"keywords": [
|
||||
"querystring",
|
||||
"qs"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "lib/index.js",
|
||||
"name": "qs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ljharb/qs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "covert test",
|
||||
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js",
|
||||
"lint": "eslint lib/*.js test/*.js",
|
||||
"prelint": "editorconfig-tools check * lib/* test/*",
|
||||
"prepublish": "safe-publish-latest && npm run dist",
|
||||
"pretest": "npm run --silent readme && npm run --silent lint",
|
||||
"readme": "evalmd README.md",
|
||||
"test": "npm run --silent coverage",
|
||||
"tests-only": "node test"
|
||||
},
|
||||
"version": "6.5.0"
|
||||
}
|
11
express-server/node_modules/express/node_modules/qs/test/.eslintrc
generated
vendored
Normal file
11
express-server/node_modules/express/node_modules/qs/test/.eslintrc
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"rules": {
|
||||
"consistent-return": 2,
|
||||
"max-lines": 0,
|
||||
"max-nested-callbacks": [2, 3],
|
||||
"max-statements": 0,
|
||||
"no-extend-native": 0,
|
||||
"no-magic-numbers": 0,
|
||||
"sort-keys": 0
|
||||
}
|
||||
}
|
7
express-server/node_modules/express/node_modules/qs/test/index.js
generated
vendored
Normal file
7
express-server/node_modules/express/node_modules/qs/test/index.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
require('./parse');
|
||||
|
||||
require('./stringify');
|
||||
|
||||
require('./utils');
|
546
express-server/node_modules/express/node_modules/qs/test/parse.js
generated
vendored
Normal file
546
express-server/node_modules/express/node_modules/qs/test/parse.js
generated
vendored
Normal file
@ -0,0 +1,546 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var qs = require('../');
|
||||
var utils = require('../lib/utils');
|
||||
var iconv = require('iconv-lite');
|
||||
|
||||
test('parse()', function (t) {
|
||||
t.test('parses a simple string', function (st) {
|
||||
st.deepEqual(qs.parse('0=foo'), { 0: 'foo' });
|
||||
st.deepEqual(qs.parse('foo=c++'), { foo: 'c ' });
|
||||
st.deepEqual(qs.parse('a[>=]=23'), { a: { '>=': '23' } });
|
||||
st.deepEqual(qs.parse('a[<=>]==23'), { a: { '<=>': '=23' } });
|
||||
st.deepEqual(qs.parse('a[==]=23'), { a: { '==': '23' } });
|
||||
st.deepEqual(qs.parse('foo', { strictNullHandling: true }), { foo: null });
|
||||
st.deepEqual(qs.parse('foo'), { foo: '' });
|
||||
st.deepEqual(qs.parse('foo='), { foo: '' });
|
||||
st.deepEqual(qs.parse('foo=bar'), { foo: 'bar' });
|
||||
st.deepEqual(qs.parse(' foo = bar = baz '), { ' foo ': ' bar = baz ' });
|
||||
st.deepEqual(qs.parse('foo=bar=baz'), { foo: 'bar=baz' });
|
||||
st.deepEqual(qs.parse('foo=bar&bar=baz'), { foo: 'bar', bar: 'baz' });
|
||||
st.deepEqual(qs.parse('foo2=bar2&baz2='), { foo2: 'bar2', baz2: '' });
|
||||
st.deepEqual(qs.parse('foo=bar&baz', { strictNullHandling: true }), { foo: 'bar', baz: null });
|
||||
st.deepEqual(qs.parse('foo=bar&baz'), { foo: 'bar', baz: '' });
|
||||
st.deepEqual(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'), {
|
||||
cht: 'p3',
|
||||
chd: 't:60,40',
|
||||
chs: '250x100',
|
||||
chl: 'Hello|World'
|
||||
});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows enabling dot notation', function (st) {
|
||||
st.deepEqual(qs.parse('a.b=c'), { 'a.b': 'c' });
|
||||
st.deepEqual(qs.parse('a.b=c', { allowDots: true }), { a: { b: 'c' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.deepEqual(qs.parse('a[b]=c'), { a: { b: 'c' } }, 'parses a single nested string');
|
||||
t.deepEqual(qs.parse('a[b][c]=d'), { a: { b: { c: 'd' } } }, 'parses a double nested string');
|
||||
t.deepEqual(
|
||||
qs.parse('a[b][c][d][e][f][g][h]=i'),
|
||||
{ a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } },
|
||||
'defaults to a depth of 5'
|
||||
);
|
||||
|
||||
t.test('only parses one level when depth = 1', function (st) {
|
||||
st.deepEqual(qs.parse('a[b][c]=d', { depth: 1 }), { a: { b: { '[c]': 'd' } } });
|
||||
st.deepEqual(qs.parse('a[b][c][d]=e', { depth: 1 }), { a: { b: { '[c][d]': 'e' } } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] }, 'parses a simple array');
|
||||
|
||||
t.test('parses an explicit array', function (st) {
|
||||
st.deepEqual(qs.parse('a[]=b'), { a: ['b'] });
|
||||
st.deepEqual(qs.parse('a[]=b&a[]=c'), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a[]=b&a[]=c&a[]=d'), { a: ['b', 'c', 'd'] });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses a mix of simple and explicit arrays', function (st) {
|
||||
st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a[0]=b&a=c'), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a=b&a[0]=c'), { a: ['b', 'c'] });
|
||||
|
||||
st.deepEqual(qs.parse('a[1]=b&a=c', { arrayLimit: 20 }), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a[]=b&a=c', { arrayLimit: 0 }), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] });
|
||||
|
||||
st.deepEqual(qs.parse('a=b&a[1]=c', { arrayLimit: 20 }), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a=b&a[]=c', { arrayLimit: 0 }), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] });
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses a nested array', function (st) {
|
||||
st.deepEqual(qs.parse('a[b][]=c&a[b][]=d'), { a: { b: ['c', 'd'] } });
|
||||
st.deepEqual(qs.parse('a[>=]=25'), { a: { '>=': '25' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows to specify array indices', function (st) {
|
||||
st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] });
|
||||
st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] });
|
||||
st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 20 }), { a: ['c'] });
|
||||
st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 0 }), { a: { 1: 'c' } });
|
||||
st.deepEqual(qs.parse('a[1]=c'), { a: ['c'] });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('limits specific array indices to arrayLimit', function (st) {
|
||||
st.deepEqual(qs.parse('a[20]=a', { arrayLimit: 20 }), { a: ['a'] });
|
||||
st.deepEqual(qs.parse('a[21]=a', { arrayLimit: 20 }), { a: { 21: 'a' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.deepEqual(qs.parse('a[12b]=c'), { a: { '12b': 'c' } }, 'supports keys that begin with a number');
|
||||
|
||||
t.test('supports encoded = signs', function (st) {
|
||||
st.deepEqual(qs.parse('he%3Dllo=th%3Dere'), { 'he=llo': 'th=ere' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('is ok with url encoded strings', function (st) {
|
||||
st.deepEqual(qs.parse('a[b%20c]=d'), { a: { 'b c': 'd' } });
|
||||
st.deepEqual(qs.parse('a[b]=c%20d'), { a: { b: 'c d' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows brackets in the value', function (st) {
|
||||
st.deepEqual(qs.parse('pets=["tobi"]'), { pets: '["tobi"]' });
|
||||
st.deepEqual(qs.parse('operators=[">=", "<="]'), { operators: '[">=", "<="]' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows empty values', function (st) {
|
||||
st.deepEqual(qs.parse(''), {});
|
||||
st.deepEqual(qs.parse(null), {});
|
||||
st.deepEqual(qs.parse(undefined), {});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('transforms arrays to objects', function (st) {
|
||||
st.deepEqual(qs.parse('foo[0]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } });
|
||||
st.deepEqual(qs.parse('foo[bad]=baz&foo[0]=bar'), { foo: { bad: 'baz', 0: 'bar' } });
|
||||
st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar'), { foo: { bad: 'baz', 0: 'bar' } });
|
||||
st.deepEqual(qs.parse('foo[]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } });
|
||||
st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
|
||||
st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] });
|
||||
|
||||
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', t: 'u' } });
|
||||
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { 0: 'b', t: 'u', hasOwnProperty: 'c' } });
|
||||
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', x: 'y' } });
|
||||
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { 0: 'b', hasOwnProperty: 'c', x: 'y' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('transforms arrays to objects (dot notation)', function (st) {
|
||||
st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: 'baz' } });
|
||||
st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad.boo=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } });
|
||||
st.deepEqual(qs.parse('foo[0][0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } });
|
||||
st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15'], bar: '2' }] });
|
||||
st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].baz[1]=16&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15', '16'], bar: '2' }] });
|
||||
st.deepEqual(qs.parse('foo.bad=baz&foo[0]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } });
|
||||
st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } });
|
||||
st.deepEqual(qs.parse('foo[]=bar&foo.bad=baz', { allowDots: true }), { foo: { 0: 'bar', bad: 'baz' } });
|
||||
st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
|
||||
st.deepEqual(qs.parse('foo[0].a=a&foo[0].b=b&foo[1].a=aa&foo[1].b=bb', { allowDots: true }), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('correctly prunes undefined values when converting an array to an object', function (st) {
|
||||
st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('supports malformed uri characters', function (st) {
|
||||
st.deepEqual(qs.parse('{%:%}', { strictNullHandling: true }), { '{%:%}': null });
|
||||
st.deepEqual(qs.parse('{%:%}='), { '{%:%}': '' });
|
||||
st.deepEqual(qs.parse('foo=%:%}'), { foo: '%:%}' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('doesn\'t produce empty keys', function (st) {
|
||||
st.deepEqual(qs.parse('_r=1&'), { _r: '1' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('cannot access Object prototype', function (st) {
|
||||
qs.parse('constructor[prototype][bad]=bad');
|
||||
qs.parse('bad[constructor][prototype][bad]=bad');
|
||||
st.equal(typeof Object.prototype.bad, 'undefined');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses arrays of objects', function (st) {
|
||||
st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] });
|
||||
st.deepEqual(qs.parse('a[0][b]=c'), { a: [{ b: 'c' }] });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows for empty strings in arrays', function (st) {
|
||||
st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] });
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true, arrayLimit: 20 }),
|
||||
{ a: ['b', null, 'c', ''] },
|
||||
'with arrayLimit 20 + array indices: null then empty string works'
|
||||
);
|
||||
st.deepEqual(
|
||||
qs.parse('a[]=b&a[]&a[]=c&a[]=', { strictNullHandling: true, arrayLimit: 0 }),
|
||||
{ a: ['b', null, 'c', ''] },
|
||||
'with arrayLimit 0 + array brackets: null then empty string works'
|
||||
);
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true, arrayLimit: 20 }),
|
||||
{ a: ['b', '', 'c', null] },
|
||||
'with arrayLimit 20 + array indices: empty string then null works'
|
||||
);
|
||||
st.deepEqual(
|
||||
qs.parse('a[]=b&a[]=&a[]=c&a[]', { strictNullHandling: true, arrayLimit: 0 }),
|
||||
{ a: ['b', '', 'c', null] },
|
||||
'with arrayLimit 0 + array brackets: empty string then null works'
|
||||
);
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('a[]=&a[]=b&a[]=c'),
|
||||
{ a: ['', 'b', 'c'] },
|
||||
'array brackets: empty strings work'
|
||||
);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('compacts sparse arrays', function (st) {
|
||||
st.deepEqual(qs.parse('a[10]=1&a[2]=2', { arrayLimit: 20 }), { a: ['2', '1'] });
|
||||
st.deepEqual(qs.parse('a[1][b][2][c]=1', { arrayLimit: 20 }), { a: [{ b: [{ c: '1' }] }] });
|
||||
st.deepEqual(qs.parse('a[1][2][3][c]=1', { arrayLimit: 20 }), { a: [[[{ c: '1' }]]] });
|
||||
st.deepEqual(qs.parse('a[1][2][3][c][1]=1', { arrayLimit: 20 }), { a: [[[{ c: ['1'] }]]] });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses semi-parsed strings', function (st) {
|
||||
st.deepEqual(qs.parse({ 'a[b]': 'c' }), { a: { b: 'c' } });
|
||||
st.deepEqual(qs.parse({ 'a[b]': 'c', 'a[d]': 'e' }), { a: { b: 'c', d: 'e' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses buffers correctly', function (st) {
|
||||
var b = new Buffer('test');
|
||||
st.deepEqual(qs.parse({ a: b }), { a: b });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('continues parsing when no parent is found', function (st) {
|
||||
st.deepEqual(qs.parse('[]=&a=b'), { 0: '', a: 'b' });
|
||||
st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { 0: null, a: 'b' });
|
||||
st.deepEqual(qs.parse('[foo]=bar'), { foo: 'bar' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not error when parsing a very long array', function (st) {
|
||||
var str = 'a[]=a';
|
||||
while (Buffer.byteLength(str) < 128 * 1024) {
|
||||
str = str + '&' + str;
|
||||
}
|
||||
|
||||
st.doesNotThrow(function () {
|
||||
qs.parse(str);
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('should not throw when a native prototype has an enumerable property', { parallel: false }, function (st) {
|
||||
Object.prototype.crash = '';
|
||||
Array.prototype.crash = '';
|
||||
st.doesNotThrow(qs.parse.bind(null, 'a=b'));
|
||||
st.deepEqual(qs.parse('a=b'), { a: 'b' });
|
||||
st.doesNotThrow(qs.parse.bind(null, 'a[][b]=c'));
|
||||
st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] });
|
||||
delete Object.prototype.crash;
|
||||
delete Array.prototype.crash;
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses a string with an alternative string delimiter', function (st) {
|
||||
st.deepEqual(qs.parse('a=b;c=d', { delimiter: ';' }), { a: 'b', c: 'd' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses a string with an alternative RegExp delimiter', function (st) {
|
||||
st.deepEqual(qs.parse('a=b; c=d', { delimiter: /[;,] */ }), { a: 'b', c: 'd' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not use non-splittable objects as delimiters', function (st) {
|
||||
st.deepEqual(qs.parse('a=b&c=d', { delimiter: true }), { a: 'b', c: 'd' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows overriding parameter limit', function (st) {
|
||||
st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: 1 }), { a: 'b' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows setting the parameter limit to Infinity', function (st) {
|
||||
st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: Infinity }), { a: 'b', c: 'd' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows overriding array limit', function (st) {
|
||||
st.deepEqual(qs.parse('a[0]=b', { arrayLimit: -1 }), { a: { 0: 'b' } });
|
||||
st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: -1 }), { a: { '-1': 'b' } });
|
||||
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 }), { a: { 0: 'b', 1: 'c' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows disabling array parsing', function (st) {
|
||||
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { parseArrays: false }), { a: { 0: 'b', 1: 'c' } });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('allows for query string prefix', function (st) {
|
||||
st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
|
||||
st.deepEqual(qs.parse('foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
|
||||
st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: false }), { '?foo': 'bar' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses an object', function (st) {
|
||||
var input = {
|
||||
'user[name]': { 'pop[bob]': 3 },
|
||||
'user[email]': null
|
||||
};
|
||||
|
||||
var expected = {
|
||||
user: {
|
||||
name: { 'pop[bob]': 3 },
|
||||
email: null
|
||||
}
|
||||
};
|
||||
|
||||
var result = qs.parse(input);
|
||||
|
||||
st.deepEqual(result, expected);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses an object in dot notation', function (st) {
|
||||
var input = {
|
||||
'user.name': { 'pop[bob]': 3 },
|
||||
'user.email.': null
|
||||
};
|
||||
|
||||
var expected = {
|
||||
user: {
|
||||
name: { 'pop[bob]': 3 },
|
||||
email: null
|
||||
}
|
||||
};
|
||||
|
||||
var result = qs.parse(input, { allowDots: true });
|
||||
|
||||
st.deepEqual(result, expected);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses an object and not child values', function (st) {
|
||||
var input = {
|
||||
'user[name]': { 'pop[bob]': { test: 3 } },
|
||||
'user[email]': null
|
||||
};
|
||||
|
||||
var expected = {
|
||||
user: {
|
||||
name: { 'pop[bob]': { test: 3 } },
|
||||
email: null
|
||||
}
|
||||
};
|
||||
|
||||
var result = qs.parse(input);
|
||||
|
||||
st.deepEqual(result, expected);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not blow up when Buffer global is missing', function (st) {
|
||||
var tempBuffer = global.Buffer;
|
||||
delete global.Buffer;
|
||||
var result = qs.parse('a=b&c=d');
|
||||
global.Buffer = tempBuffer;
|
||||
st.deepEqual(result, { a: 'b', c: 'd' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not crash when parsing circular references', function (st) {
|
||||
var a = {};
|
||||
a.b = a;
|
||||
|
||||
var parsed;
|
||||
|
||||
st.doesNotThrow(function () {
|
||||
parsed = qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a });
|
||||
});
|
||||
|
||||
st.equal('foo' in parsed, true, 'parsed has "foo" property');
|
||||
st.equal('bar' in parsed.foo, true);
|
||||
st.equal('baz' in parsed.foo, true);
|
||||
st.equal(parsed.foo.bar, 'baz');
|
||||
st.deepEqual(parsed.foo.baz, a);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses null objects correctly', { skip: !Object.create }, function (st) {
|
||||
var a = Object.create(null);
|
||||
a.b = 'c';
|
||||
|
||||
st.deepEqual(qs.parse(a), { b: 'c' });
|
||||
var result = qs.parse({ a: a });
|
||||
st.equal('a' in result, true, 'result has "a" property');
|
||||
st.deepEqual(result.a, a);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses dates correctly', function (st) {
|
||||
var now = new Date();
|
||||
st.deepEqual(qs.parse({ a: now }), { a: now });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('parses regular expressions correctly', function (st) {
|
||||
var re = /^test$/;
|
||||
st.deepEqual(qs.parse({ a: re }), { a: re });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not allow overwriting prototype properties', function (st) {
|
||||
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: false }), {});
|
||||
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: false }), {});
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('toString', { allowPrototypes: false }),
|
||||
{},
|
||||
'bare "toString" results in {}'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can allow overwriting prototype properties', function (st) {
|
||||
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } });
|
||||
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' });
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('toString', { allowPrototypes: true }),
|
||||
{ toString: '' },
|
||||
'bare "toString" results in { toString: "" }'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('params starting with a closing bracket', function (st) {
|
||||
st.deepEqual(qs.parse(']=toString'), { ']': 'toString' });
|
||||
st.deepEqual(qs.parse(']]=toString'), { ']]': 'toString' });
|
||||
st.deepEqual(qs.parse(']hello]=toString'), { ']hello]': 'toString' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('params starting with a starting bracket', function (st) {
|
||||
st.deepEqual(qs.parse('[=toString'), { '[': 'toString' });
|
||||
st.deepEqual(qs.parse('[[=toString'), { '[[': 'toString' });
|
||||
st.deepEqual(qs.parse('[hello[=toString'), { '[hello[': 'toString' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('add keys to objects', function (st) {
|
||||
st.deepEqual(
|
||||
qs.parse('a[b]=c&a=d'),
|
||||
{ a: { b: 'c', d: true } },
|
||||
'can add keys to objects'
|
||||
);
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('a[b]=c&a=toString'),
|
||||
{ a: { b: 'c' } },
|
||||
'can not overwrite prototype'
|
||||
);
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('a[b]=c&a=toString', { allowPrototypes: true }),
|
||||
{ a: { b: 'c', toString: true } },
|
||||
'can overwrite prototype with allowPrototypes true'
|
||||
);
|
||||
|
||||
st.deepEqual(
|
||||
qs.parse('a[b]=c&a=toString', { plainObjects: true }),
|
||||
{ a: { b: 'c', toString: true } },
|
||||
'can overwrite prototype with plainObjects true'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can return null objects', { skip: !Object.create }, function (st) {
|
||||
var expected = Object.create(null);
|
||||
expected.a = Object.create(null);
|
||||
expected.a.b = 'c';
|
||||
expected.a.hasOwnProperty = 'd';
|
||||
st.deepEqual(qs.parse('a[b]=c&a[hasOwnProperty]=d', { plainObjects: true }), expected);
|
||||
st.deepEqual(qs.parse(null, { plainObjects: true }), Object.create(null));
|
||||
var expectedArray = Object.create(null);
|
||||
expectedArray.a = Object.create(null);
|
||||
expectedArray.a[0] = 'b';
|
||||
expectedArray.a.c = 'd';
|
||||
st.deepEqual(qs.parse('a[]=b&a[c]=d', { plainObjects: true }), expectedArray);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can parse with custom encoding', function (st) {
|
||||
st.deepEqual(qs.parse('%8c%a7=%91%e5%8d%e3%95%7b', {
|
||||
decoder: function (str) {
|
||||
var reg = /%([0-9A-F]{2})/ig;
|
||||
var result = [];
|
||||
var parts = reg.exec(str);
|
||||
while (parts) {
|
||||
result.push(parseInt(parts[1], 16));
|
||||
parts = reg.exec(str);
|
||||
}
|
||||
return iconv.decode(new Buffer(result), 'shift_jis').toString();
|
||||
}
|
||||
}), { 県: '大阪府' });
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('receives the default decoder as a second argument', function (st) {
|
||||
st.plan(1);
|
||||
qs.parse('a', {
|
||||
decoder: function (str, defaultDecoder) {
|
||||
st.equal(defaultDecoder, utils.decode);
|
||||
}
|
||||
});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('throws error with wrong decoder', function (st) {
|
||||
st.throws(function () {
|
||||
qs.parse({}, { decoder: 'string' });
|
||||
}, new TypeError('Decoder has to be a function.'));
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not mutate the options argument', function (st) {
|
||||
var options = {};
|
||||
qs.parse('a[b]=true', options);
|
||||
st.deepEqual(options, {});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
596
express-server/node_modules/express/node_modules/qs/test/stringify.js
generated
vendored
Normal file
596
express-server/node_modules/express/node_modules/qs/test/stringify.js
generated
vendored
Normal file
@ -0,0 +1,596 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var qs = require('../');
|
||||
var utils = require('../lib/utils');
|
||||
var iconv = require('iconv-lite');
|
||||
|
||||
test('stringify()', function (t) {
|
||||
t.test('stringifies a querystring object', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b' }), 'a=b');
|
||||
st.equal(qs.stringify({ a: 1 }), 'a=1');
|
||||
st.equal(qs.stringify({ a: 1, b: 2 }), 'a=1&b=2');
|
||||
st.equal(qs.stringify({ a: 'A_Z' }), 'a=A_Z');
|
||||
st.equal(qs.stringify({ a: '€' }), 'a=%E2%82%AC');
|
||||
st.equal(qs.stringify({ a: '' }), 'a=%EE%80%80');
|
||||
st.equal(qs.stringify({ a: 'א' }), 'a=%D7%90');
|
||||
st.equal(qs.stringify({ a: '𐐷' }), 'a=%F0%90%90%B7');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('adds query prefix', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b' }, { addQueryPrefix: true }), '?a=b');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('with query prefix, outputs blank string given an empty object', function (st) {
|
||||
st.equal(qs.stringify({}, { addQueryPrefix: true }), '');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a nested object', function (st) {
|
||||
st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
|
||||
st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a nested object with dots notation', function (st) {
|
||||
st.equal(qs.stringify({ a: { b: 'c' } }, { allowDots: true }), 'a.b=c');
|
||||
st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }, { allowDots: true }), 'a.b.c.d=e');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an array value', function (st) {
|
||||
st.equal(
|
||||
qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'indices' }),
|
||||
'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d',
|
||||
'indices => indices'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'brackets' }),
|
||||
'a%5B%5D=b&a%5B%5D=c&a%5B%5D=d',
|
||||
'brackets => brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify({ a: ['b', 'c', 'd'] }),
|
||||
'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d',
|
||||
'default => indices'
|
||||
);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('omits nulls when asked', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b', c: null }, { skipNulls: true }), 'a=b');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('omits nested nulls when asked', function (st) {
|
||||
st.equal(qs.stringify({ a: { b: 'c', d: null } }, { skipNulls: true }), 'a%5Bb%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('omits array indices when asked', function (st) {
|
||||
st.equal(qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }), 'a=b&a=c&a=d');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a nested array value', function (st) {
|
||||
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { arrayFormat: 'indices' }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d');
|
||||
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { arrayFormat: 'brackets' }), 'a%5Bb%5D%5B%5D=c&a%5Bb%5D%5B%5D=d');
|
||||
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a nested array value with dots notation', function (st) {
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: { b: ['c', 'd'] } },
|
||||
{ allowDots: true, encode: false, arrayFormat: 'indices' }
|
||||
),
|
||||
'a.b[0]=c&a.b[1]=d',
|
||||
'indices: stringifies with dots + indices'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: { b: ['c', 'd'] } },
|
||||
{ allowDots: true, encode: false, arrayFormat: 'brackets' }
|
||||
),
|
||||
'a.b[]=c&a.b[]=d',
|
||||
'brackets: stringifies with dots + brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: { b: ['c', 'd'] } },
|
||||
{ allowDots: true, encode: false }
|
||||
),
|
||||
'a.b[0]=c&a.b[1]=d',
|
||||
'default: stringifies with dots + indices'
|
||||
);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an object inside an array', function (st) {
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'indices' }),
|
||||
'a%5B0%5D%5Bb%5D=c',
|
||||
'indices => brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'brackets' }),
|
||||
'a%5B%5D%5Bb%5D=c',
|
||||
'brackets => brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: 'c' }] }),
|
||||
'a%5B0%5D%5Bb%5D=c',
|
||||
'default => indices'
|
||||
);
|
||||
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: { c: [1] } }] }, { arrayFormat: 'indices' }),
|
||||
'a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1',
|
||||
'indices => indices'
|
||||
);
|
||||
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: { c: [1] } }] }, { arrayFormat: 'brackets' }),
|
||||
'a%5B%5D%5Bb%5D%5Bc%5D%5B%5D=1',
|
||||
'brackets => brackets'
|
||||
);
|
||||
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: { c: [1] } }] }),
|
||||
'a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1',
|
||||
'default => indices'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an array with mixed objects and primitives', function (st) {
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encode: false, arrayFormat: 'indices' }),
|
||||
'a[0][b]=1&a[1]=2&a[2]=3',
|
||||
'indices => indices'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encode: false, arrayFormat: 'brackets' }),
|
||||
'a[][b]=1&a[]=2&a[]=3',
|
||||
'brackets => brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encode: false }),
|
||||
'a[0][b]=1&a[1]=2&a[2]=3',
|
||||
'default => indices'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an object inside an array with dots notation', function (st) {
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: [{ b: 'c' }] },
|
||||
{ allowDots: true, encode: false, arrayFormat: 'indices' }
|
||||
),
|
||||
'a[0].b=c',
|
||||
'indices => indices'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: [{ b: 'c' }] },
|
||||
{ allowDots: true, encode: false, arrayFormat: 'brackets' }
|
||||
),
|
||||
'a[].b=c',
|
||||
'brackets => brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: [{ b: 'c' }] },
|
||||
{ allowDots: true, encode: false }
|
||||
),
|
||||
'a[0].b=c',
|
||||
'default => indices'
|
||||
);
|
||||
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: [{ b: { c: [1] } }] },
|
||||
{ allowDots: true, encode: false, arrayFormat: 'indices' }
|
||||
),
|
||||
'a[0].b.c[0]=1',
|
||||
'indices => indices'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: [{ b: { c: [1] } }] },
|
||||
{ allowDots: true, encode: false, arrayFormat: 'brackets' }
|
||||
),
|
||||
'a[].b.c[]=1',
|
||||
'brackets => brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: [{ b: { c: [1] } }] },
|
||||
{ allowDots: true, encode: false }
|
||||
),
|
||||
'a[0].b.c[0]=1',
|
||||
'default => indices'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not omit object keys when indices = false', function (st) {
|
||||
st.equal(qs.stringify({ a: [{ b: 'c' }] }, { indices: false }), 'a%5Bb%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('uses indices notation for arrays when indices=true', function (st) {
|
||||
st.equal(qs.stringify({ a: ['b', 'c'] }, { indices: true }), 'a%5B0%5D=b&a%5B1%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('uses indices notation for arrays when no arrayFormat is specified', function (st) {
|
||||
st.equal(qs.stringify({ a: ['b', 'c'] }), 'a%5B0%5D=b&a%5B1%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('uses indices notation for arrays when no arrayFormat=indices', function (st) {
|
||||
st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }), 'a%5B0%5D=b&a%5B1%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('uses repeat notation for arrays when no arrayFormat=repeat', function (st) {
|
||||
st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }), 'a=b&a=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('uses brackets notation for arrays when no arrayFormat=brackets', function (st) {
|
||||
st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }), 'a%5B%5D=b&a%5B%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a complicated object', function (st) {
|
||||
st.equal(qs.stringify({ a: { b: 'c', d: 'e' } }), 'a%5Bb%5D=c&a%5Bd%5D=e');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an empty value', function (st) {
|
||||
st.equal(qs.stringify({ a: '' }), 'a=');
|
||||
st.equal(qs.stringify({ a: null }, { strictNullHandling: true }), 'a');
|
||||
|
||||
st.equal(qs.stringify({ a: '', b: '' }), 'a=&b=');
|
||||
st.equal(qs.stringify({ a: null, b: '' }, { strictNullHandling: true }), 'a&b=');
|
||||
|
||||
st.equal(qs.stringify({ a: { b: '' } }), 'a%5Bb%5D=');
|
||||
st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: true }), 'a%5Bb%5D');
|
||||
st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: false }), 'a%5Bb%5D=');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a null object', { skip: !Object.create }, function (st) {
|
||||
var obj = Object.create(null);
|
||||
obj.a = 'b';
|
||||
st.equal(qs.stringify(obj), 'a=b');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('returns an empty string for invalid input', function (st) {
|
||||
st.equal(qs.stringify(undefined), '');
|
||||
st.equal(qs.stringify(false), '');
|
||||
st.equal(qs.stringify(null), '');
|
||||
st.equal(qs.stringify(''), '');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an object with a null object as a child', { skip: !Object.create }, function (st) {
|
||||
var obj = { a: Object.create(null) };
|
||||
|
||||
obj.a.b = 'c';
|
||||
st.equal(qs.stringify(obj), 'a%5Bb%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('drops keys with a value of undefined', function (st) {
|
||||
st.equal(qs.stringify({ a: undefined }), '');
|
||||
|
||||
st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: true }), 'a%5Bc%5D');
|
||||
st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: false }), 'a%5Bc%5D=');
|
||||
st.equal(qs.stringify({ a: { b: undefined, c: '' } }), 'a%5Bc%5D=');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('url encodes values', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b c' }), 'a=b%20c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a date', function (st) {
|
||||
var now = new Date();
|
||||
var str = 'a=' + encodeURIComponent(now.toISOString());
|
||||
st.equal(qs.stringify({ a: now }), str);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies the weird object from qs', function (st) {
|
||||
st.equal(qs.stringify({ 'my weird field': '~q1!2"\'w$5&7/z8)?' }), 'my%20weird%20field=~q1%212%22%27w%245%267%2Fz8%29%3F');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('skips properties that are part of the object prototype', function (st) {
|
||||
Object.prototype.crash = 'test';
|
||||
st.equal(qs.stringify({ a: 'b' }), 'a=b');
|
||||
st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
|
||||
delete Object.prototype.crash;
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies boolean values', function (st) {
|
||||
st.equal(qs.stringify({ a: true }), 'a=true');
|
||||
st.equal(qs.stringify({ a: { b: true } }), 'a%5Bb%5D=true');
|
||||
st.equal(qs.stringify({ b: false }), 'b=false');
|
||||
st.equal(qs.stringify({ b: { c: false } }), 'b%5Bc%5D=false');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies buffer values', function (st) {
|
||||
st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test');
|
||||
st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an object using an alternative delimiter', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('doesn\'t blow up when Buffer global is missing', function (st) {
|
||||
var tempBuffer = global.Buffer;
|
||||
delete global.Buffer;
|
||||
var result = qs.stringify({ a: 'b', c: 'd' });
|
||||
global.Buffer = tempBuffer;
|
||||
st.equal(result, 'a=b&c=d');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('selects properties when filter=array', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b' }, { filter: ['a'] }), 'a=b');
|
||||
st.equal(qs.stringify({ a: 1 }, { filter: [] }), '');
|
||||
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' },
|
||||
{ filter: ['a', 'b', 0, 2], arrayFormat: 'indices' }
|
||||
),
|
||||
'a%5Bb%5D%5B0%5D=1&a%5Bb%5D%5B2%5D=3',
|
||||
'indices => indices'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' },
|
||||
{ filter: ['a', 'b', 0, 2], arrayFormat: 'brackets' }
|
||||
),
|
||||
'a%5Bb%5D%5B%5D=1&a%5Bb%5D%5B%5D=3',
|
||||
'brackets => brackets'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' },
|
||||
{ filter: ['a', 'b', 0, 2] }
|
||||
),
|
||||
'a%5Bb%5D%5B0%5D=1&a%5Bb%5D%5B2%5D=3',
|
||||
'default => indices'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('supports custom representations when filter=function', function (st) {
|
||||
var calls = 0;
|
||||
var obj = { a: 'b', c: 'd', e: { f: new Date(1257894000000) } };
|
||||
var filterFunc = function (prefix, value) {
|
||||
calls += 1;
|
||||
if (calls === 1) {
|
||||
st.equal(prefix, '', 'prefix is empty');
|
||||
st.equal(value, obj);
|
||||
} else if (prefix === 'c') {
|
||||
return void 0;
|
||||
} else if (value instanceof Date) {
|
||||
st.equal(prefix, 'e[f]');
|
||||
return value.getTime();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
st.equal(qs.stringify(obj, { filter: filterFunc }), 'a=b&e%5Bf%5D=1257894000000');
|
||||
st.equal(calls, 5);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can disable uri encoding', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b' }, { encode: false }), 'a=b');
|
||||
st.equal(qs.stringify({ a: { b: 'c' } }, { encode: false }), 'a[b]=c');
|
||||
st.equal(qs.stringify({ a: 'b', c: null }, { strictNullHandling: true, encode: false }), 'a=b&c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can sort the keys', function (st) {
|
||||
var sort = function (a, b) {
|
||||
return a.localeCompare(b);
|
||||
};
|
||||
st.equal(qs.stringify({ a: 'c', z: 'y', b: 'f' }, { sort: sort }), 'a=c&b=f&z=y');
|
||||
st.equal(qs.stringify({ a: 'c', z: { j: 'a', i: 'b' }, b: 'f' }, { sort: sort }), 'a=c&b=f&z%5Bi%5D=b&z%5Bj%5D=a');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can sort the keys at depth 3 or more too', function (st) {
|
||||
var sort = function (a, b) {
|
||||
return a.localeCompare(b);
|
||||
};
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: 'a', z: { zj: { zjb: 'zjb', zja: 'zja' }, zi: { zib: 'zib', zia: 'zia' } }, b: 'b' },
|
||||
{ sort: sort, encode: false }
|
||||
),
|
||||
'a=a&b=b&z[zi][zia]=zia&z[zi][zib]=zib&z[zj][zja]=zja&z[zj][zjb]=zjb'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: 'a', z: { zj: { zjb: 'zjb', zja: 'zja' }, zi: { zib: 'zib', zia: 'zia' } }, b: 'b' },
|
||||
{ sort: null, encode: false }
|
||||
),
|
||||
'a=a&z[zj][zjb]=zjb&z[zj][zja]=zja&z[zi][zib]=zib&z[zi][zia]=zia&b=b'
|
||||
);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can stringify with custom encoding', function (st) {
|
||||
st.equal(qs.stringify({ 県: '大阪府', '': '' }, {
|
||||
encoder: function (str) {
|
||||
if (str.length === 0) {
|
||||
return '';
|
||||
}
|
||||
var buf = iconv.encode(str, 'shiftjis');
|
||||
var result = [];
|
||||
for (var i = 0; i < buf.length; ++i) {
|
||||
result.push(buf.readUInt8(i).toString(16));
|
||||
}
|
||||
return '%' + result.join('%');
|
||||
}
|
||||
}), '%8c%a7=%91%e5%8d%e3%95%7b&=');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('receives the default encoder as a second argument', function (st) {
|
||||
st.plan(2);
|
||||
qs.stringify({ a: 1 }, {
|
||||
encoder: function (str, defaultEncoder) {
|
||||
st.equal(defaultEncoder, utils.encode);
|
||||
}
|
||||
});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('throws error with wrong encoder', function (st) {
|
||||
st.throws(function () {
|
||||
qs.stringify({}, { encoder: 'string' });
|
||||
}, new TypeError('Encoder has to be a function.'));
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('can use custom encoder for a buffer object', { skip: typeof Buffer === 'undefined' }, function (st) {
|
||||
st.equal(qs.stringify({ a: new Buffer([1]) }, {
|
||||
encoder: function (buffer) {
|
||||
if (typeof buffer === 'string') {
|
||||
return buffer;
|
||||
}
|
||||
return String.fromCharCode(buffer.readUInt8(0) + 97);
|
||||
}
|
||||
}), 'a=b');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('serializeDate option', function (st) {
|
||||
var date = new Date();
|
||||
st.equal(
|
||||
qs.stringify({ a: date }),
|
||||
'a=' + date.toISOString().replace(/:/g, '%3A'),
|
||||
'default is toISOString'
|
||||
);
|
||||
|
||||
var mutatedDate = new Date();
|
||||
mutatedDate.toISOString = function () {
|
||||
throw new SyntaxError();
|
||||
};
|
||||
st.throws(function () {
|
||||
mutatedDate.toISOString();
|
||||
}, SyntaxError);
|
||||
st.equal(
|
||||
qs.stringify({ a: mutatedDate }),
|
||||
'a=' + Date.prototype.toISOString.call(mutatedDate).replace(/:/g, '%3A'),
|
||||
'toISOString works even when method is not locally present'
|
||||
);
|
||||
|
||||
var specificDate = new Date(6);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: specificDate },
|
||||
{ serializeDate: function (d) { return d.getTime() * 7; } }
|
||||
),
|
||||
'a=42',
|
||||
'custom serializeDate function called'
|
||||
);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('RFC 1738 spaces serialization', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b c' }, { format: qs.formats.RFC1738 }), 'a=b+c');
|
||||
st.equal(qs.stringify({ 'a b': 'c d' }, { format: qs.formats.RFC1738 }), 'a+b=c+d');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('RFC 3986 spaces serialization', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b c' }, { format: qs.formats.RFC3986 }), 'a=b%20c');
|
||||
st.equal(qs.stringify({ 'a b': 'c d' }, { format: qs.formats.RFC3986 }), 'a%20b=c%20d');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('Backward compatibility to RFC 3986', function (st) {
|
||||
st.equal(qs.stringify({ a: 'b c' }), 'a=b%20c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('Edge cases and unknown formats', function (st) {
|
||||
['UFO1234', false, 1234, null, {}, []].forEach(
|
||||
function (format) {
|
||||
st.throws(
|
||||
function () {
|
||||
qs.stringify({ a: 'b c' }, { format: format });
|
||||
},
|
||||
new TypeError('Unknown format option provided.')
|
||||
);
|
||||
}
|
||||
);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('encodeValuesOnly', function (st) {
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
|
||||
{ encodeValuesOnly: true }
|
||||
),
|
||||
'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h'
|
||||
);
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: 'b', c: ['d', 'e'], f: [['g'], ['h']] }
|
||||
),
|
||||
'a=b&c%5B0%5D=d&c%5B1%5D=e&f%5B0%5D%5B0%5D=g&f%5B1%5D%5B0%5D=h'
|
||||
);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('encodeValuesOnly - strictNullHandling', function (st) {
|
||||
st.equal(
|
||||
qs.stringify(
|
||||
{ a: { b: null } },
|
||||
{ encodeValuesOnly: true, strictNullHandling: true }
|
||||
),
|
||||
'a[b]'
|
||||
);
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not mutate the options argument', function (st) {
|
||||
var options = {};
|
||||
qs.stringify({}, options);
|
||||
st.deepEqual(options, {});
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
34
express-server/node_modules/express/node_modules/qs/test/utils.js
generated
vendored
Normal file
34
express-server/node_modules/express/node_modules/qs/test/utils.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var utils = require('../lib/utils');
|
||||
|
||||
test('merge()', function (t) {
|
||||
t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key');
|
||||
|
||||
var oneMerged = utils.merge({ foo: 'bar' }, { foo: { first: '123' } });
|
||||
t.deepEqual(oneMerged, { foo: ['bar', { first: '123' }] }, 'merges a standalone and an object into an array');
|
||||
|
||||
var twoMerged = utils.merge({ foo: ['bar', { first: '123' }] }, { foo: { second: '456' } });
|
||||
t.deepEqual(twoMerged, { foo: { 0: 'bar', 1: { first: '123' }, second: '456' } }, 'merges a standalone and two objects into an array');
|
||||
|
||||
var sandwiched = utils.merge({ foo: ['bar', { first: '123', second: '456' }] }, { foo: 'baz' });
|
||||
t.deepEqual(sandwiched, { foo: ['bar', { first: '123', second: '456' }, 'baz'] }, 'merges an object sandwiched by two standalones into an array');
|
||||
|
||||
var nestedArrays = utils.merge({ foo: ['baz'] }, { foo: ['bar', 'xyzzy'] });
|
||||
t.deepEqual(nestedArrays, { foo: ['baz', 'bar', 'xyzzy'] });
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('assign()', function (t) {
|
||||
var target = { a: 1, b: 2 };
|
||||
var source = { b: 3, c: 4 };
|
||||
var result = utils.assign(target, source);
|
||||
|
||||
t.equal(result, target, 'returns the target');
|
||||
t.deepEqual(target, { a: 1, b: 3, c: 4 }, 'target and source are merged');
|
||||
t.deepEqual(source, { b: 3, c: 4 }, 'source is untouched');
|
||||
|
||||
t.end();
|
||||
});
|
13
express-server/node_modules/express/node_modules/setprototypeof/LICENSE
generated
vendored
Normal file
13
express-server/node_modules/express/node_modules/setprototypeof/LICENSE
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright (c) 2015, Wes Todd
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
21
express-server/node_modules/express/node_modules/setprototypeof/README.md
generated
vendored
Normal file
21
express-server/node_modules/express/node_modules/setprototypeof/README.md
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Polyfill for `Object.setPrototypeOf`
|
||||
|
||||
A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
|
||||
|
||||
## Usage:
|
||||
|
||||
```
|
||||
$ npm install --save setprototypeof
|
||||
```
|
||||
|
||||
```javascript
|
||||
var setPrototypeOf = require('setprototypeof');
|
||||
|
||||
var obj = {};
|
||||
setPrototypeOf(obj, {
|
||||
foo: function() {
|
||||
return 'bar';
|
||||
}
|
||||
});
|
||||
obj.foo(); // bar
|
||||
```
|
15
express-server/node_modules/express/node_modules/setprototypeof/index.js
generated
vendored
Normal file
15
express-server/node_modules/express/node_modules/setprototypeof/index.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
module.exports = Object.setPrototypeOf || ({__proto__:[]} instanceof Array ? setProtoOf : mixinProperties);
|
||||
|
||||
function setProtoOf(obj, proto) {
|
||||
obj.__proto__ = proto;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function mixinProperties(obj, proto) {
|
||||
for (var prop in proto) {
|
||||
if (!obj.hasOwnProperty(prop)) {
|
||||
obj[prop] = proto[prop];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
51
express-server/node_modules/express/node_modules/setprototypeof/package.json
generated
vendored
Normal file
51
express-server/node_modules/express/node_modules/setprototypeof/package.json
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"_from": "setprototypeof@1.0.3",
|
||||
"_id": "setprototypeof@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=",
|
||||
"_location": "/express/setprototypeof",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "setprototypeof@1.0.3",
|
||||
"name": "setprototypeof",
|
||||
"escapedName": "setprototypeof",
|
||||
"rawSpec": "1.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz",
|
||||
"_shasum": "66567e37043eeb4f04d91bd658c0cbefb55b8e04",
|
||||
"_spec": "setprototypeof@1.0.3",
|
||||
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\express-server\\node_modules\\express",
|
||||
"author": {
|
||||
"name": "Wes Todd"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/wesleytodd/setprototypeof/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "A small polyfill for Object.setprototypeof",
|
||||
"homepage": "https://github.com/wesleytodd/setprototypeof",
|
||||
"keywords": [
|
||||
"polyfill",
|
||||
"object",
|
||||
"setprototypeof"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "setprototypeof",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/wesleytodd/setprototypeof.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
55
express-server/node_modules/express/node_modules/statuses/HISTORY.md
generated
vendored
Normal file
55
express-server/node_modules/express/node_modules/statuses/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
1.3.1 / 2016-11-11
|
||||
==================
|
||||
|
||||
* Fix return type in JSDoc
|
||||
|
||||
1.3.0 / 2016-05-17
|
||||
==================
|
||||
|
||||
* Add `421 Misdirected Request`
|
||||
* perf: enable strict mode
|
||||
|
||||
1.2.1 / 2015-02-01
|
||||
==================
|
||||
|
||||
* Fix message for status 451
|
||||
- `451 Unavailable For Legal Reasons`
|
||||
|
||||
1.2.0 / 2014-09-28
|
||||
==================
|
||||
|
||||
* Add `208 Already Repored`
|
||||
* Add `226 IM Used`
|
||||
* Add `306 (Unused)`
|
||||
* Add `415 Unable For Legal Reasons`
|
||||
* Add `508 Loop Detected`
|
||||
|
||||
1.1.1 / 2014-09-24
|
||||
==================
|
||||
|
||||
* Add missing 308 to `codes.json`
|
||||
|
||||
1.1.0 / 2014-09-21
|
||||
==================
|
||||
|
||||
* Add `codes.json` for universal support
|
||||
|
||||
1.0.4 / 2014-08-20
|
||||
==================
|
||||
|
||||
* Package cleanup
|
||||
|
||||
1.0.3 / 2014-06-08
|
||||
==================
|
||||
|
||||
* Add 308 to `.redirect` category
|
||||
|
||||
1.0.2 / 2014-03-13
|
||||
==================
|
||||
|
||||
* Add `.retry` category
|
||||
|
||||
1.0.1 / 2014-03-12
|
||||
==================
|
||||
|
||||
* Initial release
|
23
express-server/node_modules/express/node_modules/statuses/LICENSE
generated
vendored
Normal file
23
express-server/node_modules/express/node_modules/statuses/LICENSE
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
||||
Copyright (c) 2016 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.
|
103
express-server/node_modules/express/node_modules/statuses/README.md
generated
vendored
Normal file
103
express-server/node_modules/express/node_modules/statuses/README.md
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
# Statuses
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
HTTP status utility for node.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var status = require('statuses')
|
||||
```
|
||||
|
||||
### var code = status(Integer || String)
|
||||
|
||||
If `Integer` or `String` is a valid HTTP code or status message, then the appropriate `code` will be returned. Otherwise, an error will be thrown.
|
||||
|
||||
```js
|
||||
status(403) // => 403
|
||||
status('403') // => 403
|
||||
status('forbidden') // => 403
|
||||
status('Forbidden') // => 403
|
||||
status(306) // throws, as it's not supported by node.js
|
||||
```
|
||||
|
||||
### status.codes
|
||||
|
||||
Returns an array of all the status codes as `Integer`s.
|
||||
|
||||
### var msg = status[code]
|
||||
|
||||
Map of `code` to `status message`. `undefined` for invalid `code`s.
|
||||
|
||||
```js
|
||||
status[404] // => 'Not Found'
|
||||
```
|
||||
|
||||
### var code = status[msg]
|
||||
|
||||
Map of `status message` to `code`. `msg` can either be title-cased or lower-cased. `undefined` for invalid `status message`s.
|
||||
|
||||
```js
|
||||
status['not found'] // => 404
|
||||
status['Not Found'] // => 404
|
||||
```
|
||||
|
||||
### status.redirect[code]
|
||||
|
||||
Returns `true` if a status code is a valid redirect status.
|
||||
|
||||
```js
|
||||
status.redirect[200] // => undefined
|
||||
status.redirect[301] // => true
|
||||
```
|
||||
|
||||
### status.empty[code]
|
||||
|
||||
Returns `true` if a status code expects an empty body.
|
||||
|
||||
```js
|
||||
status.empty[200] // => undefined
|
||||
status.empty[204] // => true
|
||||
status.empty[304] // => true
|
||||
```
|
||||
|
||||
### status.retry[code]
|
||||
|
||||
Returns `true` if you should retry the rest.
|
||||
|
||||
```js
|
||||
status.retry[501] // => undefined
|
||||
status.retry[503] // => true
|
||||
```
|
||||
|
||||
## Adding Status Codes
|
||||
|
||||
The status codes are primarily sourced from http://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv.
|
||||
Additionally, custom codes are added from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes.
|
||||
These are added manually in the `lib/*.json` files.
|
||||
If you would like to add a status code, add it to the appropriate JSON file.
|
||||
|
||||
To rebuild `codes.json`, run the following:
|
||||
|
||||
```bash
|
||||
# update src/iana.json
|
||||
npm run fetch
|
||||
# build codes.json
|
||||
npm run build
|
||||
```
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/statuses.svg
|
||||
[npm-url]: https://npmjs.org/package/statuses
|
||||
[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/statuses.svg
|
||||
[travis-url]: https://travis-ci.org/jshttp/statuses
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/statuses.svg
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/statuses.svg
|
||||
[downloads-url]: https://npmjs.org/package/statuses
|
65
express-server/node_modules/express/node_modules/statuses/codes.json
generated
vendored
Normal file
65
express-server/node_modules/express/node_modules/statuses/codes.json
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"100": "Continue",
|
||||
"101": "Switching Protocols",
|
||||
"102": "Processing",
|
||||
"200": "OK",
|
||||
"201": "Created",
|
||||
"202": "Accepted",
|
||||
"203": "Non-Authoritative Information",
|
||||
"204": "No Content",
|
||||
"205": "Reset Content",
|
||||
"206": "Partial Content",
|
||||
"207": "Multi-Status",
|
||||
"208": "Already Reported",
|
||||
"226": "IM Used",
|
||||
"300": "Multiple Choices",
|
||||
"301": "Moved Permanently",
|
||||
"302": "Found",
|
||||
"303": "See Other",
|
||||
"304": "Not Modified",
|
||||
"305": "Use Proxy",
|
||||
"306": "(Unused)",
|
||||
"307": "Temporary Redirect",
|
||||
"308": "Permanent Redirect",
|
||||
"400": "Bad Request",
|
||||
"401": "Unauthorized",
|
||||
"402": "Payment Required",
|
||||
"403": "Forbidden",
|
||||
"404": "Not Found",
|
||||
"405": "Method Not Allowed",
|
||||
"406": "Not Acceptable",
|
||||
"407": "Proxy Authentication Required",
|
||||
"408": "Request Timeout",
|
||||
"409": "Conflict",
|
||||
"410": "Gone",
|
||||
"411": "Length Required",
|
||||
"412": "Precondition Failed",
|
||||
"413": "Payload Too Large",
|
||||
"414": "URI Too Long",
|
||||
"415": "Unsupported Media Type",
|
||||
"416": "Range Not Satisfiable",
|
||||
"417": "Expectation Failed",
|
||||
"418": "I'm a teapot",
|
||||
"421": "Misdirected Request",
|
||||
"422": "Unprocessable Entity",
|
||||
"423": "Locked",
|
||||
"424": "Failed Dependency",
|
||||
"425": "Unordered Collection",
|
||||
"426": "Upgrade Required",
|
||||
"428": "Precondition Required",
|
||||
"429": "Too Many Requests",
|
||||
"431": "Request Header Fields Too Large",
|
||||
"451": "Unavailable For Legal Reasons",
|
||||
"500": "Internal Server Error",
|
||||
"501": "Not Implemented",
|
||||
"502": "Bad Gateway",
|
||||
"503": "Service Unavailable",
|
||||
"504": "Gateway Timeout",
|
||||
"505": "HTTP Version Not Supported",
|
||||
"506": "Variant Also Negotiates",
|
||||
"507": "Insufficient Storage",
|
||||
"508": "Loop Detected",
|
||||
"509": "Bandwidth Limit Exceeded",
|
||||
"510": "Not Extended",
|
||||
"511": "Network Authentication Required"
|
||||
}
|
110
express-server/node_modules/express/node_modules/statuses/index.js
generated
vendored
Normal file
110
express-server/node_modules/express/node_modules/statuses/index.js
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
/*!
|
||||
* statuses
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2016 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var codes = require('./codes.json')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = status
|
||||
|
||||
// array of status codes
|
||||
status.codes = populateStatusesMap(status, codes)
|
||||
|
||||
// status codes for redirects
|
||||
status.redirect = {
|
||||
300: true,
|
||||
301: true,
|
||||
302: true,
|
||||
303: true,
|
||||
305: true,
|
||||
307: true,
|
||||
308: true
|
||||
}
|
||||
|
||||
// status codes for empty bodies
|
||||
status.empty = {
|
||||
204: true,
|
||||
205: true,
|
||||
304: true
|
||||
}
|
||||
|
||||
// status codes for when you should retry the request
|
||||
status.retry = {
|
||||
502: true,
|
||||
503: true,
|
||||
504: true
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the statuses map for given codes.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function populateStatusesMap (statuses, codes) {
|
||||
var arr = []
|
||||
|
||||
Object.keys(codes).forEach(function forEachCode (code) {
|
||||
var message = codes[code]
|
||||
var status = Number(code)
|
||||
|
||||
// Populate properties
|
||||
statuses[status] = message
|
||||
statuses[message] = status
|
||||
statuses[message.toLowerCase()] = status
|
||||
|
||||
// Add to array
|
||||
arr.push(status)
|
||||
})
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status code.
|
||||
*
|
||||
* Given a number, this will throw if it is not a known status
|
||||
* code, otherwise the code will be returned. Given a string,
|
||||
* the string will be parsed for a number and return the code
|
||||
* if valid, otherwise will lookup the code assuming this is
|
||||
* the status message.
|
||||
*
|
||||
* @param {string|number} code
|
||||
* @returns {number}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function status (code) {
|
||||
if (typeof code === 'number') {
|
||||
if (!status[code]) throw new Error('invalid status code: ' + code)
|
||||
return code
|
||||
}
|
||||
|
||||
if (typeof code !== 'string') {
|
||||
throw new TypeError('code must be a number or string')
|
||||
}
|
||||
|
||||
// '403'
|
||||
var n = parseInt(code, 10)
|
||||
if (!isNaN(n)) {
|
||||
if (!status[n]) throw new Error('invalid status code: ' + n)
|
||||
return n
|
||||
}
|
||||
|
||||
n = status[code.toLowerCase()]
|
||||
if (!n) throw new Error('invalid status message: "' + code + '"')
|
||||
return n
|
||||
}
|
83
express-server/node_modules/express/node_modules/statuses/package.json
generated
vendored
Normal file
83
express-server/node_modules/express/node_modules/statuses/package.json
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
{
|
||||
"_from": "statuses@~1.3.1",
|
||||
"_id": "statuses@1.3.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=",
|
||||
"_location": "/express/statuses",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "statuses@~1.3.1",
|
||||
"name": "statuses",
|
||||
"escapedName": "statuses",
|
||||
"rawSpec": "~1.3.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.3.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/express"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",
|
||||
"_shasum": "faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e",
|
||||
"_spec": "statuses@~1.3.1",
|
||||
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\express-server\\node_modules\\express",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/statuses/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"description": "HTTP status utility",
|
||||
"devDependencies": {
|
||||
"csv-parse": "1.1.7",
|
||||
"eslint": "3.10.0",
|
||||
"eslint-config-standard": "6.2.1",
|
||||
"eslint-plugin-promise": "3.3.2",
|
||||
"eslint-plugin-standard": "2.0.1",
|
||||
"istanbul": "0.4.5",
|
||||
"mocha": "1.21.5",
|
||||
"stream-to-array": "2.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"index.js",
|
||||
"codes.json",
|
||||
"LICENSE"
|
||||
],
|
||||
"homepage": "https://github.com/jshttp/statuses#readme",
|
||||
"keywords": [
|
||||
"http",
|
||||
"status",
|
||||
"code"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "statuses",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jshttp/statuses.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js",
|
||||
"fetch": "node scripts/fetch.js",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
||||
"update": "npm run fetch && npm run build"
|
||||
},
|
||||
"version": "1.3.1"
|
||||
}
|
152
express-server/node_modules/express/package.json
generated
vendored
Normal file
152
express-server/node_modules/express/package.json
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
{
|
||||
"_from": "express@~4.15.5",
|
||||
"_id": "express@4.15.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ZwI1ypWYiQpa6BcLg9tyK4Qu2Sc=",
|
||||
"_location": "/express",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "express@~4.15.5",
|
||||
"name": "express",
|
||||
"escapedName": "express",
|
||||
"rawSpec": "~4.15.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~4.15.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/express/-/express-4.15.5.tgz",
|
||||
"_shasum": "670235ca9598890a5ae8170b83db722b842ed927",
|
||||
"_spec": "express@~4.15.5",
|
||||
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\express-server",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/expressjs/express/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Aaron Heckmann",
|
||||
"email": "aaron.heckmann+github@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Ciaran Jessup",
|
||||
"email": "ciaranj@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "Guillermo Rauch",
|
||||
"email": "rauchg@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Shtylman",
|
||||
"email": "shtylman+expressjs@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Young Jae Sim",
|
||||
"email": "hanul@hanul.me"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.3",
|
||||
"array-flatten": "1.1.1",
|
||||
"content-disposition": "0.5.2",
|
||||
"content-type": "~1.0.2",
|
||||
"cookie": "0.3.1",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.1",
|
||||
"encodeurl": "~1.0.1",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.0",
|
||||
"finalhandler": "~1.0.6",
|
||||
"fresh": "0.5.2",
|
||||
"merge-descriptors": "1.0.1",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.3.0",
|
||||
"parseurl": "~1.3.1",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"proxy-addr": "~1.1.5",
|
||||
"qs": "6.5.0",
|
||||
"range-parser": "~1.2.0",
|
||||
"send": "0.15.6",
|
||||
"serve-static": "1.12.6",
|
||||
"setprototypeof": "1.0.3",
|
||||
"statuses": "~1.3.1",
|
||||
"type-is": "~1.6.15",
|
||||
"utils-merge": "1.0.0",
|
||||
"vary": "~1.1.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Fast, unopinionated, minimalist web framework",
|
||||
"devDependencies": {
|
||||
"after": "0.8.2",
|
||||
"body-parser": "1.18.1",
|
||||
"connect-redis": "~2.4.1",
|
||||
"cookie-parser": "~1.4.3",
|
||||
"cookie-session": "1.3.1",
|
||||
"ejs": "2.5.7",
|
||||
"eslint": "2.13.1",
|
||||
"express-session": "1.15.5",
|
||||
"hbs": "4.0.1",
|
||||
"istanbul": "0.4.5",
|
||||
"marked": "0.3.6",
|
||||
"method-override": "2.3.9",
|
||||
"mocha": "3.5.3",
|
||||
"morgan": "1.8.2",
|
||||
"multiparty": "4.1.3",
|
||||
"pbkdf2-password": "1.2.1",
|
||||
"should": "13.1.0",
|
||||
"supertest": "1.2.0",
|
||||
"vhost": "~3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"History.md",
|
||||
"Readme.md",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"homepage": "http://expressjs.com/",
|
||||
"keywords": [
|
||||
"express",
|
||||
"framework",
|
||||
"sinatra",
|
||||
"web",
|
||||
"rest",
|
||||
"restful",
|
||||
"router",
|
||||
"app",
|
||||
"api"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "express",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/expressjs/express.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",
|
||||
"test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
|
||||
},
|
||||
"version": "4.15.5"
|
||||
}
|
Reference in New Issue
Block a user