You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
570 B

7 years ago
  1. /**
  2. * Initialization middleware, exposing the
  3. * request and response to eachother, as well
  4. * as defaulting the X-Powered-By header field.
  5. *
  6. * @param {Function} app
  7. * @return {Function}
  8. * @api private
  9. */
  10. exports.init = function(app){
  11. return function expressInit(req, res, next){
  12. if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
  13. req.res = res;
  14. res.req = req;
  15. req.next = next;
  16. req.__proto__ = app.request;
  17. res.__proto__ = app.response;
  18. res.locals = res.locals || Object.create(null);
  19. next();
  20. };
  21. };