Skip to content
Myr

Merge tag '3.6.0'

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 · parents bc9bcb0, f7be983 · Browse files · 13 files+242 added−18 removed
This commit

State

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

Diff stats

13 files+242 added−18 removed

  • tests:+144 added−7 removed
  • other:+98 added−11 removed

13 files+242 added−18 removed

modified:examples/resource/app.js+1 added-1 removed
modified:examples/route-map/index.js+4 added-4 removed
modified:examples/route-middleware/index.js+1 added-1 removed
75 unmodified lines
76app.get('/user/:id/edit', loadUser, andRestrictToSelf, function(req, res){77 res.send('Editing user ' + req.user.name);78});7980app.del('/user/:id', loadUser, andRestrictTo('admin'), function(req, res){80app.delete('/user/:id', loadUser, andRestrictTo('admin'), function(req, res){81 res.send('Deleted user ' + req.user.name);82});8384app.listen(3000);
1 unmodified line
modified:lib/application.js+2 added-1 removed
9 unmodified lines
10var query = require('./middleware/query');11var debug = require('debug')('express:application');12var View = require('./view');13var http = require('http');14var deprecate = require('./utils').deprecate;1516/**17 * Application prototype.18 */
413 unmodified lines
432};433434// del -> delete alias435435app.del = app.delete;436app.del = deprecate(app.delete, 'app.del: Use app.delete instead');437438/**439 * Render the given view `name` name with `options`440 * and a callback accepting an error and the
93 unmodified lines
modified:lib/response.js+19 added
8 unmodified lines
9var sign = require('cookie-signature').sign;10var normalizeType = require('./utils').normalizeType;11var normalizeTypes = require('./utils').normalizeTypes;12var contentDisposition = require('./utils').contentDisposition;13var deprecate = require('./utils').deprecate;14var etag = require('./utils').etag;15var statusCodes = http.STATUS_CODES;16var cookie = require('cookie');17var send = require('send');
156 unmodified lines
174 if (2 == arguments.length) {175 // res.json(body, status) backwards compat176 if ('number' == typeof arguments[1]) {177 this.statusCode = arguments[1];178 return 'number' === typeof obj179 ? jsonNumDeprecated.call(this, obj)180 : jsonDeprecated.call(this, obj);181 } else {182 this.statusCode = obj;183 obj = arguments[1];184 }
10 unmodified lines
195196 return this.send(body);197};198199var jsonDeprecated = deprecate(res.json,200 'res.json(obj, status): Use res.json(status, obj) instead');201202var jsonNumDeprecated = deprecate(res.json,203 'res.json(num, status): Use res.status(status).json(num) instead');204205/**206 * Send JSON response with JSONP callback support.207 *208 * Examples:
14 unmodified lines
223 if (2 == arguments.length) {224 // res.json(body, status) backwards compat225 if ('number' == typeof arguments[1]) {226 this.statusCode = arguments[1];227 return 'number' === typeof obj228 ? jsonpNumDeprecated.call(this, obj)229 : jsonpDeprecated.call(this, obj);230 } else {231 this.statusCode = obj;232 obj = arguments[1];233 }
25 unmodified lines
259260 return this.send(body);261};262263var jsonpDeprecated = deprecate(res.json,264 'res.jsonp(obj, status): Use res.jsonp(status, obj) instead');265266var jsonpNumDeprecated = deprecate(res.json,267 'res.jsonp(num, status): Use res.status(status).jsonp(num) instead');268269/**270 * Transfer the file at the given `path`.271 *272 * Automatically sets the _Content-Type_ response header field.
531 unmodified lines
modified:lib/utils.js+16 added
3 unmodified lines
45var mime = require('send').mime;6var crc32 = require('buffer-crc32');7var basename = require('path').basename;8var deprecate = require('util').deprecate;910/**11 * Deprecate function, like core `util.deprecate`12 *13 * @param {Function} fn14 * @param {String} msg15 * @return {Function}16 * @api private17 */1819exports.deprecate = function(fn, msg){20 return 'test' !== process.env.NODE_ENV21 ? deprecate(fn, 'express: ' + msg)22 : fn;23};2425/**26 * Return ETag for `body`.27 *28 * @param {String|Buffer} body29 * @return {String}
121 unmodified lines
modified:test/app.router.js+1 added-2 removed
4 unmodified lines
5 , methods = require('methods');67describe('app.router', function(){8 describe('methods supported', function(){9 methods.forEach(function(method){9 methods.concat('del').forEach(function(method){10 if (method === 'connect') return;1112 it('should include ' + method.toUpperCase(), function(done){13 if (method == 'delete') method = 'del';13 var app = express();14 var calls = [];1516 app[method]('/foo', function(req, res){
579 unmodified lines
modified:test/res.format.js+22 added-4 removed
2 unmodified lines
3 , request = require('supertest')4 , utils = require('../lib/utils')5 , assert = require('assert');67var app = express();7var app1 = express();89app.use(function(req, res, next){9app1.use(function(req, res, next){10 res.format({11 'text/plain': function(){12 res.send('hey');13 },
10 unmodified lines
24 }25 });26});2728app.use(function(err, req, res, next){28app1.use(function(err, req, res, next){29 if (!err.types) throw err;30 res.send(err.status, 'Supports: ' + err.types.join(', '));31})32
19 unmodified lines
52 default: function(){ res.send('default') }53 })54});5556var app4 = express();5758app4.get('/', function(req, res, next){59 res.format({60 text: function(){ res.send('hey') },61 html: function(){ res.send('<p>hey</p>') },62 json: function(){ res.send({ message: 'hey' }) }63 });64});6566app4.use(function(err, req, res, next){67 res.send(err.status, 'Supports: ' + err.types.join(', '));68})6970describe('res', function(){71 describe('.format(obj)', function(){72 describe('with canonicalized mime types', function(){59 test(app);73 test(app1);74 })7576 describe('with extnames', function(){77 test(app2);
8 unmodified lines
86 })87 })8889 describe('in router', function(){90 test(app4);91 })9293 describe('in router', function(){94 var app = express();95 var router = express.Router();9697 router.get('/', function(req, res, next){
83 unmodified lines
modified:test/res.json.js+52 added-1 removed
30 unmodified lines
31 .expect(200, '{"hello":"world"}', done);32 })3334 describe('when given primitives', function(){35 it('should respond with json', function(done){35 it('should respond with json for null', function(done){36 var app = express();3738 app.use(function(req, res){39 res.json(null);
6 unmodified lines
46 res.text.should.equal('null');47 done();48 })49 })5051 it('should respond with json for Number', function(done){52 var app = express();5354 app.use(function(req, res){55 res.json(300);56 });5758 request(app)59 .get('/')60 .end(function(err, res){61 res.statusCode.should.equal(200);62 res.headers.should.have.property('content-type', 'application/json');63 res.text.should.equal('300');64 done();65 })66 })6768 it('should respond with json for String', function(done){69 var app = express();7071 app.use(function(req, res){72 res.json('str');73 });7475 request(app)76 .get('/')77 .end(function(err, res){78 res.statusCode.should.equal(200);79 res.headers.should.have.property('content-type', 'application/json');80 res.text.should.equal('"str"');81 done();82 })83 })84 })8586 describe('when given an array', function(){87 it('should respond with json', function(done){
114 unmodified lines
202 res.text.should.equal('{"id":1}');203 done();204 })205 })206207 it('should use status as second number for backwards compat', function(done){208 var app = express();209210 app.use(function(req, res){211 res.json(200, 201);212 });213214 request(app)215 .get('/')216 .end(function(err, res){217 res.statusCode.should.equal(201);218 res.headers.should.have.property('content-type', 'application/json');219 res.text.should.equal('200');220 done();221 })222 })223 })224})
modified:test/res.jsonp.js+69 added
199 unmodified lines
200 })201 })202 })203204 describe('when given primitives', function(){205 it('should respond with json for null', function(done){206 var app = express();207208 app.use(function(req, res){209 res.jsonp(null);210 });211212 request(app)213 .get('/')214 .end(function(err, res){215 res.headers.should.have.property('content-type', 'application/json');216 res.text.should.equal('null');217 done();218 })219 })220221 it('should respond with json for Number', function(done){222 var app = express();223224 app.use(function(req, res){225 res.jsonp(300);226 });227228 request(app)229 .get('/')230 .end(function(err, res){231 res.statusCode.should.equal(200);232 res.headers.should.have.property('content-type', 'application/json');233 res.text.should.equal('300');234 done();235 })236 })237238 it('should respond with json for String', function(done){239 var app = express();240241 app.use(function(req, res){242 res.jsonp('str');243 });244245 request(app)246 .get('/')247 .end(function(err, res){248 res.statusCode.should.equal(200);249 res.headers.should.have.property('content-type', 'application/json');250 res.text.should.equal('"str"');251 done();252 })253 })254 })255256 describe('"json replacer" setting', function(){257 it('should be passed to JSON.stringify()', function(done){258 var app = express();259
76 unmodified lines
336 res.text.should.equal('{"id":1}');337 done();338 })339 })340341 it('should use status as second number for backwards compat', function(done){342 var app = express();343344 app.use(function(req, res){345 res.jsonp(200, 201);346 });347348 request(app)349 .get('/')350 .end(function(err, res){351 res.statusCode.should.equal(201);352 res.headers.should.have.property('content-type', 'application/json');353 res.text.should.equal('200');354 done();355 })356 })357 })358})
modified:History.md+47 added
14.2.x2=====34 * deprecate `app.del()` -- use `app.delete()` instead5 * deprecate `res.json(obj, status)` -- use `res.json(status, obj)` instead6 - the edge-case `res.json(status, num)` requires `res.status(status).json(num)`7 * deprecate `res.jsonp(obj, status)` -- use `res.jsonp(status, obj)` instead8 - the edge-case `res.jsonp(status, num)` requires `res.status(status).jsonp(num)`9 * fix `req.next` when inside router instance10 * include `ETag` header in `HEAD` requests11 * keep previous `Content-Type` for `res.jsonp`12 * support PURGE method13 - add `app.purge`14 - add `router.purge`15 - include PURGE in `app.all`16 * update debug to 0.8.017 - add `enable()` method18 - change from stderr to stdout19 * update methods to 1.0.020 - add PURGE21224.1.2 / 2014-05-0823==================24
68 unmodified lines
93 - `app.router()` - returns the app Router instance94 - `app.route()` - Proxy to the app's `Router#route()` method to create a new route95 - Router & Route - public API96973.6.0 / 2014-05-0998==================99100 * deprecate `app.del()` -- use `app.delete()` instead101 * deprecate `res.json(obj, status)` -- use `res.json(status, obj)` instead102 - the edge-case `res.json(status, num)` requires `res.status(status).json(num)`103 * deprecate `res.jsonp(obj, status)` -- use `res.jsonp(status, obj)` instead104 - the edge-case `res.jsonp(status, num)` requires `res.status(status).jsonp(num)`105 * support PURGE method106 - add `app.purge`107 - add `router.purge`108 - include PURGE in `app.all`109 * update connect to 2.15.0110 * Add `res.appendHeader`111 * Call error stack even when response has been sent112 * Patch `res.headerSent` to return Boolean113 * Patch `res.headersSent` for node.js 0.8114 * Prevent default 404 handler after response sent115 * dep: compression@1.0.2116 * dep: connect-timeout@1.1.0117 * dep: debug@^0.8.0118 * dep: errorhandler@1.0.1119 * dep: express-session@1.0.4120 * dep: morgan@1.0.1121 * dep: serve-favicon@2.0.0122 * dep: serve-index@1.0.2123 * update debug to 0.8.0124 * add `enable()` method125 * change from stderr to stdout126 * update methods to 1.0.0127 - add PURGE128 * update mkdirp to 0.5.01291303.5.3 / 2014-05-08131==================132133 * fix `req.host` for IPv6 literals
1279 unmodified lines
modified:package.json+7 added-3 removed
15 unmodified lines
16 "name": "Ciaran Jessup",17 "email": "ciaranj@gmail.com"18 },19 {20 "name": "Douglas Christopher Wilson",21 "email": "doug@somethingdoug.com"22 },23 {24 "name": "Guillermo Rauch",25 "email": "rauchg@gmail.com"26 },27 {
12 unmodified lines
40 "range-parser": "1.0.0",41 "cookie": "0.1.2",42 "buffer-crc32": "0.2.1",43 "fresh": "0.2.2",40 "methods": "0.1.0",44 "methods": "1.0.0",45 "send": "0.3.0",46 "cookie-signature": "1.0.3",47 "merge-descriptors": "0.0.2",48 "utils-merge": "1.0.0",49 "escape-html": "1.0.1",50 "qs": "0.6.6",51 "serve-static": "1.1.0",52 "path-to-regexp": "0.1.2",49 "debug": ">= 0.7.3 < 1"53 "debug": ">= 0.8.0 < 1"54 },55 "devDependencies": {56 "mocha": "~1.18.2",57 "body-parser": "1.0.2",
3 unmodified lines
61 "marked": "0.3.2",62 "multiparty": "~3.2.4",63 "hjs": "~0.0.6",64 "should": "~3.3.1",61 "supertest": "~0.11.0",65 "supertest": "~0.12.0",66 "method-override": "1.0.0",67 "cookie-parser": "1.0.1",68 "express-session": "1.0.4",69 "morgan": "1.0.1",
23 unmodified lines
modified:Readme.md+1 added-1 removed
1[![express logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/)23 Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).45 [![Build Status](https://travis-ci.org/visionmedia/express.svg?branch=master)](https://travis-ci.org/visionmedia/express) [![Gittip](https://img.shields.io/gittip/visionmedia.svg)](https://www.gittip.com/visionmedia/)5 [![Build Status](https://travis-ci.org/visionmedia/express.svg?branch=master)](https://travis-ci.org/visionmedia/express) [![Gittip](http://img.shields.io/gittip/visionmedia.svg)](https://www.gittip.com/visionmedia/) [![NPM version](https://badge.fury.io/js/express.svg)](http://badge.fury.io/js/express)67```js8var express = require('express');9var app = express();
99 unmodified lines