source: trip-planner-front/node_modules/express/lib/middleware/init.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 853 bytes
Line 
1/*!
2 * express
3 * Copyright(c) 2009-2013 TJ Holowaychuk
4 * Copyright(c) 2013 Roman Shtylman
5 * Copyright(c) 2014-2015 Douglas Christopher Wilson
6 * MIT Licensed
7 */
8
9'use strict';
10
11/**
12 * Module dependencies.
13 * @private
14 */
15
16var setPrototypeOf = require('setprototypeof')
17
18/**
19 * Initialization middleware, exposing the
20 * request and response to each other, as well
21 * as defaulting the X-Powered-By header field.
22 *
23 * @param {Function} app
24 * @return {Function}
25 * @api private
26 */
27
28exports.init = function(app){
29 return function expressInit(req, res, next){
30 if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
31 req.res = res;
32 res.req = req;
33 req.next = next;
34
35 setPrototypeOf(req, app.request)
36 setPrototypeOf(res, app.response)
37
38 res.locals = res.locals || Object.create(null);
39
40 next();
41 };
42};
43
Note: See TracBrowser for help on using the repository browser.