Commit d6927361 authored by Douglas Christopher Wilson's avatar Douglas Christopher Wilson

Merge tag '2.27.3'

parents d5a5f108 7ed24242
unreleased
==========
* Correctly invoke async callback asynchronously
3.3.2 / 2014-10-28
==================
......@@ -85,6 +90,14 @@
* remove various private `connect.utils` functions
* drop node.js 0.8 support
2.27.3 / 2014-11-09
===================
* Correctly invoke async callback asynchronously
* deps: csurf@~1.6.3
- bump csrf
- bump http-errors
2.27.2 / 2014-10-28
===================
......
......@@ -22,6 +22,11 @@ var app = module.exports = {};
var env = process.env.NODE_ENV || 'development';
/* istanbul ignore next */
var defer = typeof setImmediate === 'function'
? setImmediate
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) }
/**
* Utilize the given middleware `handle` to the given `route`,
* defaulting to _/_. This "route" is the mount-point for the
......@@ -114,7 +119,7 @@ app.handle = function(req, res, out) {
// all done
if (!layer) {
done(err);
defer(done, err);
return;
}
......
......@@ -24,8 +24,8 @@
},
"devDependencies": {
"istanbul": "0.3.2",
"mocha": "~2.0.0",
"should": "~4.1.0",
"mocha": "~2.0.1",
"should": "~4.2.1",
"supertest": "~0.14.0"
},
"license": "MIT",
......
......@@ -17,6 +17,81 @@ describe('app', function(){
app.emit('foo');
});
it('should work in http.createServer', function(done){
var app = connect();
app.use(function (req, res) {
res.end('hello, world!');
});
var server = http.createServer(app);
request(server)
.get('/')
.expect(200, 'hello, world!', done);
})
it('should be a callable function', function(done){
var app = connect();
app.use(function (req, res) {
res.end('hello, world!');
});
function handler(req, res) {
res.write('oh, ');
app(req, res);
}
var server = http.createServer(handler);
request(server)
.get('/')
.expect(200, 'oh, hello, world!', done);
})
it('should invoke callback if request not handled', function(done){
var app = connect();
app.use('/foo', function (req, res) {
res.end('hello, world!');
});
function handler(req, res) {
res.write('oh, ');
app(req, res, function() {
res.end('no!');
});
}
var server = http.createServer(handler);
request(server)
.get('/')
.expect(200, 'oh, no!', done);
})
it('should invoke callback on error', function(done){
var app = connect();
app.use(function (req, res) {
throw new Error('boom!');
});
function handler(req, res) {
res.write('oh, ');
app(req, res, function(err) {
res.end(err.message);
});
}
var server = http.createServer(handler);
request(server)
.get('/')
.expect(200, 'oh, boom!', done);
})
it('should work as middleware', function(done){
// custom server handler array
var handlers = [connect(), function(req, res, next){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment