From 9db1367c2da82a7103151df2bd1f11ad0301e10f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 19 Jun 2014 22:55:21 -0400 Subject: [PATCH 1/7] deps: buffer-crc32@0.2.3 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 8ce41d22..54af7d7a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +unreleased +========== + + * deps: buffer-crc32@0.2.3 + 3.10.5 / 2014-06-11 =================== diff --git a/package.json b/package.json index 81b6f801..1306d918 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "repository": "visionmedia/express", "license": "MIT", "dependencies": { - "buffer-crc32": "0.2.1", + "buffer-crc32": "0.2.3", "connect": "2.19.6", "commander": "1.3.2", "debug": "1.0.2", From 5a4e9125decbc6391fc0fa931b9a87b4930b1bab Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 19 Jun 2014 23:24:07 -0400 Subject: [PATCH 2/7] deps: connect@2.20.2 --- History.md | 16 ++++++++++++++++ examples/mvc/index.js | 2 +- package.json | 2 +- test/acceptance/mvc.js | 3 +++ test/support/env.js | 1 + 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 54af7d7a..ff5569b1 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,22 @@ unreleased ========== * deps: buffer-crc32@0.2.3 + * deps: connect@2.20.2 + - deprecate `verify` option to `json` -- use `body-parser` module directly + - deprecate `verify` option to `urlencoded` -- use `body-parser` module directly + - deprecate things with `depd` module + - use `finalhandler` for final response handling + - use `media-typer` to parse `content-type` for charset + - deps: body-parser@1.4.3 + - deps: connect-timeout@1.1.1 + - deps: cookie-parser@1.3.1 + - deps: csurf@1.2.2 + - deps: errorhandler@1.1.0 + - deps: express-session@1.4.0 + - deps: multiparty@3.2.9 + - deps: serve-index@1.1.2 + - deps: type-is@1.3.1 + - deps: vhost@2.0.0 3.10.5 / 2014-06-11 =================== diff --git a/examples/mvc/index.js b/examples/mvc/index.js index ee60525c..ca9f3cc4 100644 --- a/examples/mvc/index.js +++ b/examples/mvc/index.js @@ -35,7 +35,7 @@ app.use(express.cookieParser('some secret here')); app.use(express.session()); // parse request bodies (req.body) -app.use(express.bodyParser()); +app.use(express.urlencoded({ extended: true })); // support _method (PUT in forms etc) app.use(express.methodOverride()); diff --git a/package.json b/package.json index 1306d918..bba7c1ab 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "license": "MIT", "dependencies": { "buffer-crc32": "0.2.3", - "connect": "2.19.6", + "connect": "2.20.2", "commander": "1.3.2", "debug": "1.0.2", "escape-html": "1.0.1", diff --git a/test/acceptance/mvc.js b/test/acceptance/mvc.js index 3de481c6..df0ce7d9 100644 --- a/test/acceptance/mvc.js +++ b/test/acceptance/mvc.js @@ -33,6 +33,7 @@ describe('mvc', function(){ it('should update the pet', function(done){ request(app) .put('/pet/3') + .set('Content-Type', 'application/x-www-form-urlencoded') .send({ pet: { name: 'Boots' } }) .end(function(err, res){ if (err) return done(err); @@ -95,6 +96,7 @@ describe('mvc', function(){ it('should update the user', function(done){ request(app) .put('/user/1') + .set('Content-Type', 'application/x-www-form-urlencoded') .send({ user: { name: 'Tobo' }}) .end(function(err, res){ if (err) return done(err); @@ -109,6 +111,7 @@ describe('mvc', function(){ it('should create a pet for user', function(done){ request(app) .post('/user/2/pet') + .set('Content-Type', 'application/x-www-form-urlencoded') .send({ pet: { name: 'Snickers' }}) .expect('Location', '/user/2') .expect(302, function(err, res){ diff --git a/test/support/env.js b/test/support/env.js index eb938f3b..7dbdffef 100644 --- a/test/support/env.js +++ b/test/support/env.js @@ -1,2 +1,3 @@ process.env.NODE_ENV = 'test'; +process.env.NO_DEPRECATION = 'connect'; From 9c731f1883a837ca2f46ddcf476bfdce60e82fb3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 19 Jun 2014 23:33:56 -0400 Subject: [PATCH 3/7] deprecate things with depd module --- History.md | 1 + lib/application.js | 4 ++-- lib/express.js | 4 ++-- lib/response.js | 30 +++++++++++------------------- lib/utils.js | 25 ------------------------- package.json | 1 + test/support/env.js | 2 +- test/utils.js | 22 ---------------------- 8 files changed, 18 insertions(+), 71 deletions(-) diff --git a/History.md b/History.md index ff5569b1..7f8b1689 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * deprecate things with `depd` module * deps: buffer-crc32@0.2.3 * deps: connect@2.20.2 - deprecate `verify` option to `json` -- use `body-parser` module directly diff --git a/lib/application.js b/lib/application.js index 8efed1e6..e4618fbd 100644 --- a/lib/application.js +++ b/lib/application.js @@ -12,8 +12,8 @@ var connect = require('connect') , compileTrust = require('./utils').compileTrust , View = require('./view') , utils = connect.utils - , deprecate = require('./utils').deprecate , http = require('http'); +var deprecate = require('depd')('express'); /** * Application prototype. @@ -448,7 +448,7 @@ app.all = function(path){ // del -> delete alias -app.del = deprecate(app.delete, 'app.del: Use app.delete instead'); +app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead'); /** * Render the given view `name` name with `options` diff --git a/lib/express.js b/lib/express.js index fdad6821..8a976daa 100644 --- a/lib/express.js +++ b/lib/express.js @@ -2,6 +2,7 @@ * Module dependencies. */ +var deprecate = require('depd')('express'); var merge = require('merge-descriptors'); var connect = require('connect') , proto = require('./application') @@ -9,7 +10,6 @@ var connect = require('connect') , Router = require('./router') , req = require('./request') , res = require('./response') - , deprecate = require('./utils').deprecate , utils = connect.utils; /** @@ -51,7 +51,7 @@ merge(exports, connect.middleware); * Deprecated createServer(). */ -exports.createServer = deprecate(createApplication, +exports.createServer = deprecate.function(createApplication, 'createServer() is deprecated\n' + 'express applications no longer inherit from http.Server\n' + 'please use:\n' + diff --git a/lib/response.js b/lib/response.js index 094e35c9..339bf0c4 100644 --- a/lib/response.js +++ b/lib/response.js @@ -2,6 +2,7 @@ * Module dependencies. */ +var deprecate = require('depd')('express'); var escapeHtml = require('escape-html'); var vary = require('vary'); var http = require('http') @@ -12,7 +13,6 @@ var http = require('http') , normalizeType = require('./utils').normalizeType , normalizeTypes = require('./utils').normalizeTypes , setCharset = require('./utils').setCharset - , deprecate = require('./utils').deprecate , statusCodes = http.STATUS_CODES , cookie = require('cookie') , send = require('send') @@ -196,9 +196,11 @@ res.json = function(obj){ // res.json(body, status) backwards compat if ('number' == typeof arguments[1]) { this.statusCode = arguments[1]; - return 'number' === typeof obj - ? jsonNumDeprecated.call(this, obj) - : jsonDeprecated.call(this, obj); + if (typeof obj === 'number') { + deprecate('res.json(obj, status): Use res.json(status, obj) instead'); + } else { + deprecate('res.json(num, status): Use res.status(status).json(num) instead'); + } } else { this.statusCode = obj; obj = arguments[1]; @@ -218,12 +220,6 @@ res.json = function(obj){ return this.send(body); }; -var jsonDeprecated = deprecate(res.json, - 'res.json(obj, status): Use res.json(status, obj) instead'); - -var jsonNumDeprecated = deprecate(res.json, - 'res.json(num, status): Use res.status(status).json(num) instead'); - /** * Send JSON response with JSONP callback support. * @@ -246,9 +242,11 @@ res.jsonp = function(obj){ // res.json(body, status) backwards compat if ('number' == typeof arguments[1]) { this.statusCode = arguments[1]; - return 'number' === typeof obj - ? jsonpNumDeprecated.call(this, obj) - : jsonpDeprecated.call(this, obj); + if (typeof obj === 'number') { + deprecate('res.jsonp(obj, status): Use res.jsonp(status, obj) instead'); + } else { + deprecate('res.jsonp(num, status): Use res.status(status).jsonp(num) instead'); + } } else { this.statusCode = obj; obj = arguments[1]; @@ -283,12 +281,6 @@ res.jsonp = function(obj){ return this.send(body); }; -var jsonpDeprecated = deprecate(res.json, - 'res.jsonp(obj, status): Use res.jsonp(status, obj) instead'); - -var jsonpNumDeprecated = deprecate(res.json, - 'res.jsonp(num, status): Use res.status(status).jsonp(num) instead'); - /** * Transfer the file at the given `path`. * diff --git a/lib/utils.js b/lib/utils.js index 7cae6278..5f3a98b0 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -4,7 +4,6 @@ */ var mime = require('connect').mime - , deprecate = require('util').deprecate , proxyaddr = require('proxy-addr') , crc32 = require('buffer-crc32') , crypto = require('crypto'); @@ -20,30 +19,6 @@ var toString = {}.toString; */ var charsetRegExp = /;\s*charset\s*=/; -/** - * Deprecate function, like core `util.deprecate`, - * but with NODE_ENV and color support. - * - * @param {Function} fn - * @param {String} msg - * @return {Function} - * @api private - */ - -exports.deprecate = function(fn, msg){ - if (process.env.NODE_ENV === 'test') return fn; - - // prepend module name - msg = 'express: ' + msg; - - if (process.stderr.isTTY) { - // colorize - msg = '\x1b[31;1m' + msg + '\x1b[0m'; - } - - return deprecate(fn, msg); -}; - /** * Return strong ETag for `body`. * diff --git a/package.json b/package.json index bba7c1ab..f0660e43 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "connect": "2.20.2", "commander": "1.3.2", "debug": "1.0.2", + "depd": "0.3.0", "escape-html": "1.0.1", "methods": "1.0.1", "mkdirp": "0.5.0", diff --git a/test/support/env.js b/test/support/env.js index 7dbdffef..ee4396dc 100644 --- a/test/support/env.js +++ b/test/support/env.js @@ -1,3 +1,3 @@ process.env.NODE_ENV = 'test'; -process.env.NO_DEPRECATION = 'connect'; +process.env.NO_DEPRECATION = 'connect,express'; diff --git a/test/utils.js b/test/utils.js index 155a1292..21594c40 100644 --- a/test/utils.js +++ b/test/utils.js @@ -2,28 +2,6 @@ var utils = require('../lib/utils') , assert = require('assert'); -describe('utils.deprecate(fn, msg)', function(){ - var env - before(function(){ - env = process.env.NODE_ENV - }) - after(function(){ - process.env.NODE_ENV = env - }) - - it('should pass-through fn in test environment', function(){ - var fn = function(){} - process.env.NODE_ENV = 'test' - utils.deprecate(fn).should.equal(fn) - }) - - it('should return new fn in other environment', function(){ - var fn = function(){} - process.env.NODE_ENV = '' - utils.deprecate(fn).should.not.equal(fn) - }) -}) - describe('utils.etag(body, encoding)', function(){ it('should support strings', function(){ utils.etag('express!') From 2a105df9f2bae5d2b0e5af64fc0367a159fe42f2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 19 Jun 2014 23:36:00 -0400 Subject: [PATCH 4/7] 3.11.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 7f8b1689..cf6a8f4f 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +3.11.0 / 2014-06-19 +=================== * deprecate things with `depd` module * deps: buffer-crc32@0.2.3 diff --git a/package.json b/package.json index f0660e43..826287bc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.10.5", + "version": "3.11.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ", From 7d6208e0afd638c9003e8037ce9438de9d0a9cfb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jun 2014 17:25:50 -0400 Subject: [PATCH 5/7] deps: connect@2.21.0 --- History.md | 12 ++++++++++++ bin/express | 2 +- examples/auth/app.js | 5 ++--- examples/mvc/index.js | 3 +-- examples/session/index.js | 7 +------ examples/session/redis.js | 7 +------ package.json | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/History.md b/History.md index cf6a8f4f..9fb5d00d 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,15 @@ +unreleased +========== + + * deps: connect@2.21.0 + - deprecate `connect(middleware)` -- use `app.use(middleware)` instead + - deprecate `connect.createServer()` -- use `connect()` instead + - fix `res.setHeader()` patch to work with with get -> append -> set pattern + - deps: compression@~1.0.8 + - deps: errorhandler@~1.1.1 + - deps: express-session@~1.5.0 + - deps: serve-index@~1.1.3 + 3.11.0 / 2014-06-19 =================== diff --git a/bin/express b/bin/express index ad0d64a8..a95df728 100755 --- a/bin/express +++ b/bin/express @@ -335,7 +335,7 @@ function createApplicationAt(path) { // Session support app = app.replace('{sess}', program.sessions - ? eol + 'app.use(express.cookieParser(\'your secret here\'));' + eol + 'app.use(express.session());' + ? eol + 'app.use(express.session({ secret: \'your secret here\' }));' : ''); // Template support diff --git a/examples/auth/app.js b/examples/auth/app.js index 5bca6326..4fcab9f1 100644 --- a/examples/auth/app.js +++ b/examples/auth/app.js @@ -14,9 +14,8 @@ app.set('views', __dirname + '/views'); // middleware -app.use(express.bodyParser()); -app.use(express.cookieParser('shhhh, very secret')); -app.use(express.session()); +app.use(express.urlencoded({ extended: false })); +app.use(express.session({ secret: 'shhhh, very secret' })); // Session-persisted message middleware diff --git a/examples/mvc/index.js b/examples/mvc/index.js index ca9f3cc4..b24d4663 100644 --- a/examples/mvc/index.js +++ b/examples/mvc/index.js @@ -31,8 +31,7 @@ if (!module.parent) app.use(express.logger('dev')); app.use(express.static(__dirname + '/public')); // session support -app.use(express.cookieParser('some secret here')); -app.use(express.session()); +app.use(express.session({ secret: 'some secret here' })); // parse request bodies (req.body) app.use(express.urlencoded({ extended: true })); diff --git a/examples/session/index.js b/examples/session/index.js index f4e72054..06a76fc6 100644 --- a/examples/session/index.js +++ b/examples/session/index.js @@ -9,13 +9,8 @@ var app = express(); app.use(express.logger('dev')); -// Required by session() middleware -// pass the secret for signed cookies -// (required by session()) -app.use(express.cookieParser('keyboard cat')); - // Populates req.session -app.use(express.session()); +app.use(express.session({ secret: 'keyboard cat' })); app.get('/', function(req, res){ var body = ''; diff --git a/examples/session/redis.js b/examples/session/redis.js index 5ba3671b..b85365c1 100644 --- a/examples/session/redis.js +++ b/examples/session/redis.js @@ -10,13 +10,8 @@ var app = express(); app.use(express.logger('dev')); -// Required by session() middleware -// pass the secret for signed cookies -// (required by session()) -app.use(express.cookieParser('keyboard cat')); - // Populates req.session -app.use(express.session({ store: new RedisStore })); +app.use(express.session({ store: new RedisStore, secret: 'keyboard cat' })); app.get('/', function(req, res){ var body = ''; diff --git a/package.json b/package.json index 826287bc..a31f8af2 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "license": "MIT", "dependencies": { "buffer-crc32": "0.2.3", - "connect": "2.20.2", + "connect": "2.21.0", "commander": "1.3.2", "debug": "1.0.2", "depd": "0.3.0", From e66667e465aff68273890349158b382404b6932f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jun 2014 19:32:18 -0400 Subject: [PATCH 6/7] Use media-typer to alter content-type charset --- History.md | 1 + lib/utils.js | 27 +++++++-------------------- package.json | 1 + 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/History.md b/History.md index 9fb5d00d..c45dd08f 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ unreleased ========== + * use `media-typer` to alter content-type charset * deps: connect@2.21.0 - deprecate `connect(middleware)` -- use `app.use(middleware)` instead - deprecate `connect.createServer()` -- use `connect()` instead diff --git a/lib/utils.js b/lib/utils.js index 5f3a98b0..2d5bfbb3 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -7,6 +7,7 @@ var mime = require('connect').mime , proxyaddr = require('proxy-addr') , crc32 = require('buffer-crc32') , crypto = require('crypto'); +var typer = require('media-typer'); /** * toString ref. @@ -14,11 +15,6 @@ var mime = require('connect').mime var toString = {}.toString; -/** - * Simple detection of charset parameter in content-type - */ -var charsetRegExp = /;\s*charset\s*=/; - /** * Return strong ETag for `body`. * @@ -411,21 +407,12 @@ exports.compileTrust = function(val) { exports.setCharset = function(type, charset){ if (!type || !charset) return type; - var exists = charsetRegExp.test(type); + // parse type + var parsed = typer.parse(type); - // removing existing charset - if (exists) { - var parts = type.split(';'); + // set charset + parsed.parameters.charset = charset; - for (var i = 1; i < parts.length; i++) { - if (charsetRegExp.test(';' + parts[i])) { - parts.splice(i, 1); - break; - } - } - - type = parts.join(';'); - } - - return type + '; charset=' + charset; + // format type + return typer.format(parsed); }; diff --git a/package.json b/package.json index a31f8af2..d6b9a240 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "debug": "1.0.2", "depd": "0.3.0", "escape-html": "1.0.1", + "media-typer": "0.2.0", "methods": "1.0.1", "mkdirp": "0.5.0", "parseurl": "1.0.1", From 75422c16bfcd0d9e1ea23f92b77099430cdea65e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 21 Jun 2014 21:57:02 -0400 Subject: [PATCH 7/7] 3.12.0 --- History.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index c45dd08f..7a72df67 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,5 @@ -unreleased -========== +3.12.0 / 2014-06-21 +=================== * use `media-typer` to alter content-type charset * deps: connect@2.21.0 diff --git a/package.json b/package.json index d6b9a240..5c2e0cbb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "express", "description": "Sinatra inspired web development framework", - "version": "3.11.0", + "version": "3.12.0", "author": "TJ Holowaychuk ", "contributors": [ "Aaron Heckmann ",