aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/express/lib/middleware
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/express/lib/middleware')
-rw-r--r--node_modules/express/lib/middleware/init.js43
-rw-r--r--node_modules/express/lib/middleware/query.js47
2 files changed, 90 insertions, 0 deletions
diff --git a/node_modules/express/lib/middleware/init.js b/node_modules/express/lib/middleware/init.js
new file mode 100644
index 0000000..dfd0427
--- /dev/null
+++ b/node_modules/express/lib/middleware/init.js
@@ -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();
+ };
+};
+
diff --git a/node_modules/express/lib/middleware/query.js b/node_modules/express/lib/middleware/query.js
new file mode 100644
index 0000000..7e91669
--- /dev/null
+++ b/node_modules/express/lib/middleware/query.js
@@ -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();
+ };
+};