deprecate things with depd module
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 5a4e912 · Browse files · 8 files·+18 added−71 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+18 added−71 removed
- tests:+1 added−23 removed
- other:+17 added−48 removed
Provenance
- Commit
9c731f1- Tree
35a4fba- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
5a4e912
8 files changed+18 added−71 removed
modified:lib/application.js+2 added-2 removed
10 unmodified lines11 , compileETag = require('./utils').compileETag12 , compileTrust = require('./utils').compileTrust13 , View = require('./view')14 , utils = connect.utils15- , deprecate = require('./utils').deprecate15 , http = require('http');16+var deprecate = require('depd')('express');17 18 /**19 * Application prototype.20 */426 unmodified lines447 };448 449 // del -> delete alias450 451-app.del = deprecate(app.delete, 'app.del: Use app.delete instead');451+app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead');452 453 /**454 * Render the given view `name` name with `options`455 * and a callback accepting an error and the93 unmodified linesmodified:lib/express.js+2 added-2 removed
123456789101112121314151633 unmodified lines5051525354545556575824 unmodified lines/** * Module dependencies. */
var deprecate = require('depd')('express');var merge = require('merge-descriptors');var connect = require('connect') , proto = require('./application') , Route = require('./router/route') , Router = require('./router') , req = require('./request') , res = require('./response') , deprecate = require('./utils').deprecate , utils = connect.utils;
/** * Expose `createApplication()`.33 unmodified lines/** * 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' + '\n' +24 unmodified linesmodified:lib/response.js+11 added-19 removed
1 /**2 * Module dependencies.3 */4 5+var deprecate = require('depd')('express');6 var escapeHtml = require('escape-html');7 var vary = require('vary');8 var http = require('http')9 , path = require('path')2 unmodified lines12 , sign = require('cookie-signature').sign13 , normalizeType = require('./utils').normalizeType14 , normalizeTypes = require('./utils').normalizeTypes15 , setCharset = require('./utils').setCharset15- , deprecate = require('./utils').deprecate16 , statusCodes = http.STATUS_CODES17 , cookie = require('cookie')18 , send = require('send')19 , mime = connect.mime175 unmodified lines195 if (2 == arguments.length) {196 // res.json(body, status) backwards compat197 if ('number' == typeof arguments[1]) {198 this.statusCode = arguments[1];199- return 'number' === typeof obj200- ? jsonNumDeprecated.call(this, obj)201- : jsonDeprecated.call(this, obj);199+ if (typeof obj === 'number') {200+ deprecate('res.json(obj, status): Use res.json(status, obj) instead');201+ } else {202+ deprecate('res.json(num, status): Use res.status(status).json(num) instead');203+ }204 } else {205 this.statusCode = obj;206 obj = arguments[1];207 }11 unmodified lines219 220 return this.send(body);221 };222 221-var jsonDeprecated = deprecate(res.json,222- 'res.json(obj, status): Use res.json(status, obj) instead');223-224-var jsonNumDeprecated = deprecate(res.json,225- 'res.json(num, status): Use res.status(status).json(num) instead');226-223 /**224 * Send JSON response with JSONP callback support.225 *226 * Examples:14 unmodified lines241 if (2 == arguments.length) {242 // res.json(body, status) backwards compat243 if ('number' == typeof arguments[1]) {244 this.statusCode = arguments[1];249- return 'number' === typeof obj250- ? jsonpNumDeprecated.call(this, obj)251- : jsonpDeprecated.call(this, obj);245+ if (typeof obj === 'number') {246+ deprecate('res.jsonp(obj, status): Use res.jsonp(status, obj) instead');247+ } else {248+ deprecate('res.jsonp(num, status): Use res.status(status).jsonp(num) instead');249+ }250 } else {251 this.statusCode = obj;252 obj = arguments[1];253 }26 unmodified lines280 281 return this.send(body);282 };283 286-var jsonpDeprecated = deprecate(res.json,287- 'res.jsonp(obj, status): Use res.jsonp(status, obj) instead');288-289-var jsonpNumDeprecated = deprecate(res.json,290- 'res.jsonp(num, status): Use res.status(status).jsonp(num) instead');291-284 /**285 * Transfer the file at the given `path`.286 *287 * Automatically sets the _Content-Type_ response header field.526 unmodified linesmodified:lib/utils.js-25 removed
2 unmodified lines3 * Module dependencies.4 */5 6 var mime = require('connect').mime7- , deprecate = require('util').deprecate7 , proxyaddr = require('proxy-addr')8 , crc32 = require('buffer-crc32')9 , crypto = require('crypto');10 8 unmodified lines19 */20 var charsetRegExp = /;\s*charset\s*=/;21 22 /**24- * Deprecate function, like core `util.deprecate`,25- * but with NODE_ENV and color support.26- *27- * @param {Function} fn28- * @param {String} msg29- * @return {Function}30- * @api private31- */32-33-exports.deprecate = function(fn, msg){34- if (process.env.NODE_ENV === 'test') return fn;35-36- // prepend module name37- msg = 'express: ' + msg;38-39- if (process.stderr.isTTY) {40- // colorize41- msg = '\x1b[31;1m' + msg + '\x1b[0m';42- }43-44- return deprecate(fn, msg);45-};46-47-/**23 * Return strong ETag for `body`.24 *25 * @param {String|Buffer} body26 * @param {String} [encoding]405 unmodified linesmodified:test/support/env.js+1 added-1 removed
1233
process.env.NODE_ENV = 'test';process.env.NO_DEPRECATION = 'connect';process.env.NO_DEPRECATION = 'connect,express';modified:test/utils.js-22 removed
1 2 var utils = require('../lib/utils')3 , assert = require('assert');4 5-describe('utils.deprecate(fn, msg)', function(){6- var env7- before(function(){8- env = process.env.NODE_ENV9- })10- after(function(){11- process.env.NODE_ENV = env12- })13-14- it('should pass-through fn in test environment', function(){15- var fn = function(){}16- process.env.NODE_ENV = 'test'17- utils.deprecate(fn).should.equal(fn)18- })19-20- it('should return new fn in other environment', function(){21- var fn = function(){}22- process.env.NODE_ENV = ''23- utils.deprecate(fn).should.not.equal(fn)24- })25-})26-5 describe('utils.etag(body, encoding)', function(){6 it('should support strings', function(){7 utils.etag('express!')8 .should.eql('"zZdv4imtWD49AHEviejT6A=="')242 unmodified linesmodified:History.md+1 added
1 unreleased2 ==========3 4+ * deprecate things with `depd` module5 * deps: buffer-crc32@0.2.36 * deps: connect@2.20.27 - deprecate `verify` option to `json` -- use `body-parser` module directly8 - deprecate `verify` option to `urlencoded` -- use `body-parser` module directly1461 unmodified linesmodified:package.json+1 added
27 unmodified lines28293031323334353633 unmodified lines27 unmodified lines "buffer-crc32": "0.2.3", "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", "parseurl": "1.0.1",33 unmodified lines