Skip to content

Commit e3bd14d

Browse files
tunniclmdougwilson
authored andcommitted
Remove res.send(status, body) signature
closes #2942
1 parent c319fe2 commit e3bd14d

File tree

4 files changed

+12
-42
lines changed

4 files changed

+12
-42
lines changed

History.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
This incorporates all changes after 4.15.2 up to 4.15.4.
55

6+
* remove:
7+
- `res.send(status, body)` signature - use `res.status(status).send(body)`
68
* deps: router@~1.3.1
79
810

lib/response.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ res.send = function send(body) {
113113
// settings
114114
var app = this.app;
115115

116-
// support res.send(status, body)
117-
if (arguments.length === 2) {
118-
deprecate('res.send(status, body): Use res.status(status).send(body) instead');
119-
this.statusCode = arguments[0];
120-
chunk = arguments[1];
121-
}
122-
123116
switch (typeof chunk) {
124117
// string defaulting to html
125118
case 'string':

test/res.format.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ app1.use(function(req, res, next){
2626

2727
app1.use(function(err, req, res, next){
2828
if (!err.types) throw err;
29-
res.send(err.status, 'Supports: ' + err.types.join(', '));
29+
res.status(err.status)
30+
res.send('Supports: ' + err.types.join(', '))
3031
})
3132

3233
var app2 = express();
@@ -40,7 +41,8 @@ app2.use(function(req, res, next){
4041
});
4142

4243
app2.use(function(err, req, res, next){
43-
res.send(err.status, 'Supports: ' + err.types.join(', '));
44+
res.status(err.status)
45+
res.send('Supports: ' + err.types.join(', '))
4446
})
4547

4648
var app3 = express();
@@ -63,7 +65,8 @@ app4.get('/', function(req, res, next){
6365
});
6466

6567
app4.use(function(err, req, res, next){
66-
res.send(err.status, 'Supports: ' + err.types.join(', '));
68+
res.status(err.status)
69+
res.send('Supports: ' + err.types.join(', '))
6770
})
6871

6972
var app5 = express();
@@ -96,7 +99,8 @@ describe('res', function(){
9699
});
97100

98101
app.use(function(err, req, res, next){
99-
res.send(err.status, 'Supports: ' + err.types.join(', '));
102+
res.status(err.status)
103+
res.send('Supports: ' + err.types.join(', '))
100104
});
101105

102106
test(app);
@@ -135,7 +139,8 @@ describe('res', function(){
135139
});
136140

137141
router.use(function(err, req, res, next){
138-
res.send(err.status, 'Supports: ' + err.types.join(', '));
142+
res.status(err.status)
143+
res.send('Supports: ' + err.types.join(', '))
139144
})
140145

141146
app.use(router)

test/res.send.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,6 @@ describe('res', function(){
4848
})
4949
})
5050

51-
describe('.send(code, body)', function(){
52-
it('should set .statusCode and body', function(done){
53-
var app = express();
54-
55-
app.use(function(req, res){
56-
res.send(201, 'Created :)');
57-
});
58-
59-
request(app)
60-
.get('/')
61-
.expect('Created :)')
62-
.expect(201, done);
63-
})
64-
})
65-
66-
describe('.send(code, number)', function(){
67-
it('should send number as json', function(done){
68-
var app = express();
69-
70-
app.use(function(req, res){
71-
res.send(200, 0.123);
72-
});
73-
74-
request(app)
75-
.get('/')
76-
.expect('Content-Type', 'application/json; charset=utf-8')
77-
.expect(200, '0.123', done);
78-
})
79-
})
80-
8151
describe('.send(Number)', function(){
8252
it('should send as application/json', function(done){
8353
var app = express();

0 commit comments

Comments
 (0)