github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/examples/example-nodejs-fileserver/node_modules/express/lib/middleware/init.js (about) 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 * Initialization middleware, exposing the 13 * request and response to each other, as well 14 * as defaulting the X-Powered-By header field. 15 * 16 * @param {Function} app 17 * @return {Function} 18 * @api private 19 */ 20 21 exports.init = function(app){ 22 return function expressInit(req, res, next){ 23 if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express'); 24 req.res = res; 25 res.req = req; 26 req.next = next; 27 28 req.__proto__ = app.request; 29 res.__proto__ = app.response; 30 31 res.locals = res.locals || Object.create(null); 32 33 next(); 34 }; 35 }; 36