Skip to content

Commit

Permalink
createServer() should accept middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephank committed Mar 28, 2012
1 parent 2be1587 commit 4ca1292
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/connect.js
Expand Up @@ -61,7 +61,10 @@ function createServer() {
utils.merge(app, proto);
utils.merge(app, EventEmitter.prototype);
app.route = '/';
app.stack = [].slice.apply(arguments);
app.stack = [];
[].forEach.call(arguments, function(fn) {
app.use(fn);
});
return app;
};

Expand Down
12 changes: 12 additions & 0 deletions test/mounting.js
Expand Up @@ -2,6 +2,18 @@
var connect = require('../')
, http = require('http');

describe('createServer()', function(){
it('should accept middleware', function(done){
var app = connect(function(req, res, next) {
res.end('blog');
});

app.request()
.get('/')
.expect('blog', done);
});
});

describe('app.use()', function(){
var app;

Expand Down

0 comments on commit 4ca1292

Please sign in to comment.