Permalink
Browse files

make sure req/res protos are app-specific

  • Loading branch information...
1 parent 4f087df commit e27b2249334f5d8ce3a4781f834b63673ded9aa4 @tj tj committed Nov 10, 2011
Showing with 7 additions and 17 deletions.
  1. +2 −4 lib/application.js
  2. +4 −12 lib/express.js
  3. +1 −1 test/app.response.js
View
6 lib/application.js
@@ -13,8 +13,6 @@ var connect = require('connect')
, Router = require('./router')
, toArray = require('./utils').toArray
, methods = Router.methods.concat('del', 'all')
- , request = require('./request')
- , response = require('./response')
, View = require('./view')
, url = require('url')
, utils = connect.utils
@@ -112,8 +110,8 @@ app.defaultConfiguration = function(){
res.req = req;
req.next = next;
- req.__proto__ = request;
- res.__proto__ = response;
+ req.__proto__ = self.request;
+ res.__proto__ = self.response;
res.locals = function(obj){
for (var key in obj) res.locals[key] = obj[key];
View
16 lib/express.js
@@ -13,6 +13,8 @@ var http = require('http')
, connect = require('connect')
, proto = require('./application')
, Route = require('./router/route')
+ , req = require('./request')
+ , res = require('./response')
, utils = connect.utils;
/**
@@ -37,6 +39,8 @@ exports.version = '3.0.0alpha1-pre';
function createApplication() {
var app = connect();
utils.merge(app, proto);
+ app.request = { __proto__: req };
+ app.response = { __proto__: res };
@TooTallNate
TooTallNate added a line comment Nov 10, 2011

'le Object.create()

@tj
expressjs member
tj added a line comment Nov 10, 2011

neva!!!

@TooTallNate
TooTallNate added a line comment Nov 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
app.init();
return app;
}
@@ -71,18 +75,6 @@ exports.Route = Route;
exports.methods = require('./router/methods');
-/**
- * Response prototype.
- */
-
-proto.response = require('./response');
-
-/**
- * Request prototype.
- */
-
-proto.request = require('./request');
-
// Error handler title
exports.errorHandler.title = 'Express';
View
2 test/app.response.js
@@ -23,7 +23,7 @@ describe('app', function(){
});
})
- it('should not be influenced by other app protos', function(){
+ it('should not be influenced by other app protos', function(done){
var app = express()
, app2 = express();

0 comments on commit e27b224

Please sign in to comment.