Skip to content
Myr

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

8 files+18 added−71 removed

modified:lib/application.js+2 added-2 removed
10 unmodified lines
11 , compileETag = require('./utils').compileETag12 , compileTrust = require('./utils').compileTrust13 , View = require('./view')14 , utils = connect.utils15 , deprecate = require('./utils').deprecate15 , http = require('http');16var deprecate = require('depd')('express');1718/**19 * Application prototype.20 */
426 unmodified lines
447};448449// del -> delete alias450451app.del = deprecate(app.delete, 'app.del: Use app.delete instead');451app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead');452453/**454 * Render the given view `name` name with `options`455 * and a callback accepting an error and the
93 unmodified lines
modified:lib/express.js+2 added-2 removed
modified:lib/response.js+11 added-19 removed
1/**2 * Module dependencies.3 */45var deprecate = require('depd')('express');6var escapeHtml = require('escape-html');7var vary = require('vary');8var http = require('http')9 , path = require('path')
2 unmodified lines
12 , 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.mime
175 unmodified lines
195 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 lines
219220 return this.send(body);221};222221var jsonDeprecated = deprecate(res.json,222 'res.json(obj, status): Use res.json(status, obj) instead');223224var jsonNumDeprecated = deprecate(res.json,225 'res.json(num, status): Use res.status(status).json(num) instead');226223/**224 * Send JSON response with JSONP callback support.225 *226 * Examples:
14 unmodified lines
241 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 lines
280281 return this.send(body);282};283286var jsonpDeprecated = deprecate(res.json,287 'res.jsonp(obj, status): Use res.jsonp(status, obj) instead');288289var jsonpNumDeprecated = deprecate(res.json,290 'res.jsonp(num, status): Use res.status(status).jsonp(num) instead');291284/**285 * Transfer the file at the given `path`.286 *287 * Automatically sets the _Content-Type_ response header field.
526 unmodified lines
modified:lib/utils.js-25 removed
2 unmodified lines
3 * Module dependencies.4 */56var mime = require('connect').mime7 , deprecate = require('util').deprecate7 , proxyaddr = require('proxy-addr')8 , crc32 = require('buffer-crc32')9 , crypto = require('crypto');10
8 unmodified lines
19 */20var charsetRegExp = /;\s*charset\s*=/;2122/**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 */3233exports.deprecate = function(fn, msg){34 if (process.env.NODE_ENV === 'test') return fn;3536 // prepend module name37 msg = 'express: ' + msg;3839 if (process.stderr.isTTY) {40 // colorize41 msg = '\x1b[31;1m' + msg + '\x1b[0m';42 }4344 return deprecate(fn, msg);45};4647/**23 * Return strong ETag for `body`.24 *25 * @param {String|Buffer} body26 * @param {String} [encoding]
405 unmodified lines
modified:test/support/env.js+1 added-1 removed
modified:test/utils.js-22 removed
12var utils = require('../lib/utils')3 , assert = require('assert');45describe('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 })1314 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 })1920 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})265describe('utils.etag(body, encoding)', function(){6 it('should support strings', function(){7 utils.etag('express!')8 .should.eql('"zZdv4imtWD49AHEviejT6A=="')
242 unmodified lines
modified:History.md+1 added
1unreleased2==========34 * 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 directly
1461 unmodified lines
modified:package.json+1 added