Skip to content
Myr

Remove res.jsonp(obj, status) signature

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 164638b · Browse files · 3 files+5 added−38 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+5 added−38 removed

  • tests:+0 added−28 removed
  • other:+5 added−10 removed

3 files+5 added−38 removed

modified:lib/response.js+4 added-10 removed
236 unmodified lines
237238res.jsonp = function jsonp(obj) {239 var val = obj;240241 // allow status / body241 // support res.jsonp(status, obj)242 if (arguments.length === 2) {243 // res.json(body, status) backwards compat244 if (typeof arguments[1] === 'number') {245 deprecate('res.jsonp(obj, status): Use res.status(status).json(obj) instead');246 this.statusCode = arguments[1];247 } else {248 deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead');249 this.statusCode = arguments[0];250 val = arguments[1];243 deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead');244 this.statusCode = arguments[0];245 val = arguments[1];251 }246 }247248 // settings249 var app = this.app;
704 unmodified lines
modified:test/res.jsonp.js-28 removed
301 unmodified lines
302 .expect(201, '{"id":1}', done)303 })304 })305306 describe('.jsonp(object, status)', function(){307 it('should respond with json and set the .statusCode for backwards compat', function(done){308 var app = express();309310 app.use(function(req, res){311 res.jsonp({ id: 1 }, 201);312 });313314 request(app)315 .get('/')316 .expect('Content-Type', 'application/json; charset=utf-8')317 .expect(201, '{"id":1}', done)318 })319320 it('should use status as second number for backwards compat', function(done){321 var app = express();322323 app.use(function(req, res){324 res.jsonp(200, 201);325 });326327 request(app)328 .get('/')329 .expect('Content-Type', 'application/json; charset=utf-8')330 .expect(201, '200', done)331 })332 })333306 it('should not override previous Content-Types', function(done){307 var app = express();308309 app.get('/', function(req, res){
10 unmodified lines
modified:History.md+1 added
1 unmodified line
2===34 * remove:5 - `res.json(obj, status)` signature - use `res.json(status, obj)`6 - `res.jsonp(obj, status)` signature - use `res.jsonp(status, obj)`7 - `res.send(body, status)` signature - use `res.send(status, body)`8 * change:9 - `req.host` now returns host (`hostname:port`) - use `req.hostname` for only hostname10
2450 unmodified lines