Skip to content

Remove res.send(status, body) signature #2942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

This incorporates all changes after 4.13.1 up to 4.14.0.

* remove:
- `res.send(status, body)` signature - use `res.status(status).send(body)`

5.0.0-alpha.2 / 2015-07-06
==========================

Expand Down
7 changes: 0 additions & 7 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ res.send = function send(body) {
// settings
var app = this.app;

// support res.send(status, body)
if (arguments.length === 2) {
deprecate('res.send(status, body): Use res.status(status).send(body) instead');
this.statusCode = arguments[0];
chunk = arguments[1];
}

switch (typeof chunk) {
// string defaulting to html
case 'string':
Expand Down
10 changes: 5 additions & 5 deletions test/res.format.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ app1.use(function(req, res, next){

app1.use(function(err, req, res, next){
if (!err.types) throw err;
res.send(err.status, 'Supports: ' + err.types.join(', '));
res.status(err.status).send('Supports: ' + err.types.join(', '));
})

var app2 = express();
Expand All @@ -41,7 +41,7 @@ app2.use(function(req, res, next){
});

app2.use(function(err, req, res, next){
res.send(err.status, 'Supports: ' + err.types.join(', '));
res.status(err.status).send('Supports: ' + err.types.join(', '));
})

var app3 = express();
Expand All @@ -64,7 +64,7 @@ app4.get('/', function(req, res, next){
});

app4.use(function(err, req, res, next){
res.send(err.status, 'Supports: ' + err.types.join(', '));
res.status(err.status).send('Supports: ' + err.types.join(', '));
})

var app5 = express();
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('res', function(){
});

app.use(function(err, req, res, next){
res.send(err.status, 'Supports: ' + err.types.join(', '));
res.status(err.status).send('Supports: ' + err.types.join(', '));
});

test(app);
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('res', function(){
});

router.use(function(err, req, res, next){
res.send(err.status, 'Supports: ' + err.types.join(', '));
res.status(err.status).send('Supports: ' + err.types.join(', '));
})

app.use(router)
Expand Down
30 changes: 0 additions & 30 deletions test/res.send.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,6 @@ describe('res', function(){
})
})

describe('.send(code, body)', function(){
it('should set .statusCode and body', function(done){
var app = express();

app.use(function(req, res){
res.send(201, 'Created :)');
});

request(app)
.get('/')
.expect('Created :)')
.expect(201, done);
})
})

describe('.send(code, number)', function(){
it('should send number as json', function(done){
var app = express();

app.use(function(req, res){
res.send(200, 0.123);
});

request(app)
.get('/')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200, '0.123', done);
})
})

describe('.send(Number)', function(){
it('should send as application/json', function(done){
var app = express();
Expand Down