Skip to content
Myr

refactored init middleware into its own file

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent f271941 · Browse files · 2 files+40 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+40 added−20 removed

  • other:+40 added−20 removed

2 files+40 added−20 removed

modified:lib/application.js+3 added-20 removed
10 unmodified lines
1112var connect = require('connect')13 , Router = require('./router')14 , methods = Router.methods.concat('del', 'all')15 , middleware = require('./middleware')16 , View = require('./view')17 , url = require('url')18 , utils = connect.utils19 , path = require('path')
61 unmodified lines
81 // default settings82 this.set('root', '/');83 this.set('env', process.env.NODE_ENV || 'development');8484 // always parse req.query85 // implicit middleware86 this.use(connect.query());87 this.use(middleware.init(this));8889 this.locals = function(obj){90 for (var key in obj) self.locals[key] = obj[key];91 return self;
10 unmodified lines
102 }103 return this;104 };105104 // expose objects to each other105 this.use(function(req, res, next){106 var charset;107 res.setHeader('X-Powered-By', 'Express');108 req.app = res.app = self;109 req.res = res;110 res.req = req;111 req.next = next;106113 req.__proto__ = self.request;114 res.__proto__ = self.response;115116 res.locals = function(obj){117 for (var key in obj) res.locals[key] = obj[key];118 return res;119 };120121 next();122 });123107 // router108 this._router = new Router(this);109 this.routes = this._router.routes;110 this.__defineGetter__('router', function(){
479 unmodified lines
added:lib/middleware.js+37 added