mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 00:19:48 +01:00
fix(refactor): prefix built-in node module imports
Since v5 relies on node >= 18, this is now possible (since v16, v14.18.0 [^1][^2]). It's functionally irrelevant: 1. It's not required for CJS nor ESM (with a few exceptions [^3]) 2. It has no performance promises However, there are upsides to this approach: 1. It brings clear boundaries to what's a built-in and what's an external dependency 2. It reduces the risk of importing unwanted deps where a built-in is expected 3. It's slightly more interoperable with other JS runtimes that provide node compatibility[^4], albeit only during development. Once imported from npm, built-ins are assumed. [^1]:https://nodejs.org/docs/latest-v22.x/api/modules.html#built-in-modules [^2]:https://github.com/nodejs/node/pull/37246 [^3]:https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix [^4]:https://docs.deno.com/runtime/fundamentals/node/#using-node's-built-in-modules
This commit is contained in:
parent
6a40af8293
commit
41113599af
|
|
@ -7,6 +7,7 @@ unreleased
|
|||
* cleanup: remove unnecessary require for global Buffer
|
||||
* perf: use loop for acceptParams
|
||||
* Replace `methods` dependency with standard library
|
||||
* refactor: prefix built-in node module imports
|
||||
|
||||
5.0.1 / 2024-10-08
|
||||
==========
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
var express = require('../..');
|
||||
var hash = require('pbkdf2-password')()
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var session = require('express-session');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
var express = require('../../');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
var express = require('../../');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
var express = require('../../');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var app = module.exports = express();
|
||||
var logger = require('morgan');
|
||||
var silent = process.env.NODE_ENV === 'test'
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
var escapeHtml = require('escape-html');
|
||||
var express = require('../..');
|
||||
var fs = require('fs');
|
||||
var fs = require('node:fs');
|
||||
var marked = require('marked');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
var express = require('../..');
|
||||
var logger = require('morgan');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var session = require('express-session');
|
||||
var methodOverride = require('method-override');
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
var express = require('../../..');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var fs = require('node:fs');
|
||||
var path = require('node:path');
|
||||
|
||||
module.exports = function(parent, options){
|
||||
var dir = path.join(__dirname, '..', 'controllers');
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
var express = require('../..');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var app = express();
|
||||
var logger = require('morgan');
|
||||
var cookieParser = require('cookie-parser');
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
var express = require('../..');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var redis = require('redis');
|
||||
|
||||
var db = redis.createClient();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
var express = require('../..');
|
||||
var logger = require('morgan');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var app = express();
|
||||
|
||||
// log requests
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var https = require('https');
|
||||
var path = require('path');
|
||||
var https = require('node:https');
|
||||
var path = require('node:path');
|
||||
var extname = path.extname;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
var express = require('../..');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var User = require('./user');
|
||||
var app = express();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@
|
|||
var finalhandler = require('finalhandler');
|
||||
var debug = require('debug')('express:application');
|
||||
var View = require('./view');
|
||||
var http = require('http');
|
||||
var http = require('node:http');
|
||||
var methods = require('./utils').methods;
|
||||
var compileETag = require('./utils').compileETag;
|
||||
var compileQueryParser = require('./utils').compileQueryParser;
|
||||
var compileTrust = require('./utils').compileTrust;
|
||||
var resolve = require('path').resolve;
|
||||
var resolve = require('node:path').resolve;
|
||||
var once = require('once')
|
||||
var Router = require('router');
|
||||
|
||||
|
|
@ -468,8 +468,8 @@ app.disable = function disable(setting) {
|
|||
* Delegate `.VERB(...)` calls to `router.VERB(...)`.
|
||||
*/
|
||||
|
||||
methods.forEach(function(method){
|
||||
app[method] = function(path){
|
||||
methods.forEach(function (method) {
|
||||
app[method] = function (path) {
|
||||
if (method === 'get' && arguments.length === 1) {
|
||||
// app.get(setting)
|
||||
return this.set(path);
|
||||
|
|
@ -583,8 +583,8 @@ app.render = function render(name, options, callback) {
|
|||
* and HTTPS server you may do so with the "http"
|
||||
* and "https" modules as shown here:
|
||||
*
|
||||
* var http = require('http')
|
||||
* , https = require('https')
|
||||
* var http = require('node:http')
|
||||
* , https = require('node:https')
|
||||
* , express = require('express')
|
||||
* , app = express();
|
||||
*
|
||||
|
|
@ -595,7 +595,7 @@ app.render = function render(name, options, callback) {
|
|||
* @public
|
||||
*/
|
||||
|
||||
app.listen = function listen () {
|
||||
app.listen = function listen() {
|
||||
var server = http.createServer(this)
|
||||
var args = Array.prototype.slice.call(arguments)
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
|
||||
var bodyParser = require('body-parser')
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var EventEmitter = require('node:events').EventEmitter;
|
||||
var mixin = require('merge-descriptors');
|
||||
var proto = require('./application');
|
||||
var Router = require('router');
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
*/
|
||||
|
||||
var accepts = require('accepts');
|
||||
var isIP = require('net').isIP;
|
||||
var isIP = require('node:net').isIP;
|
||||
var typeis = require('type-is');
|
||||
var http = require('http');
|
||||
var http = require('node:http');
|
||||
var fresh = require('fresh');
|
||||
var parseRange = require('range-parser');
|
||||
var parse = require('parseurl');
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ var contentDisposition = require('content-disposition');
|
|||
var createError = require('http-errors')
|
||||
var encodeUrl = require('encodeurl');
|
||||
var escapeHtml = require('escape-html');
|
||||
var http = require('http');
|
||||
var http = require('node:http');
|
||||
var onFinished = require('on-finished');
|
||||
var mime = require('mime-types')
|
||||
var path = require('path');
|
||||
var pathIsAbsolute = require('path').isAbsolute;
|
||||
var path = require('node:path');
|
||||
var pathIsAbsolute = require('node:path').isAbsolute;
|
||||
var statuses = require('statuses')
|
||||
var sign = require('cookie-signature').sign;
|
||||
var normalizeType = require('./utils').normalizeType;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
var debug = require('debug')('express:view');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var path = require('node:path');
|
||||
var fs = require('node:fs');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, Route = express.Route
|
||||
, methods = require('../lib/utils').methods
|
||||
|
|
|
|||
152
test/Router.js
152
test/Router.js
|
|
@ -4,10 +4,10 @@ var after = require('after');
|
|||
var express = require('../')
|
||||
, Router = express.Router
|
||||
, methods = require('../lib/utils').methods
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
|
||||
describe('Router', function(){
|
||||
it('should return a function with router methods', function() {
|
||||
describe('Router', function () {
|
||||
it('should return a function with router methods', function () {
|
||||
var router = new Router();
|
||||
assert(typeof router === 'function')
|
||||
|
||||
|
|
@ -16,32 +16,32 @@ describe('Router', function(){
|
|||
assert(typeof router.use === 'function')
|
||||
});
|
||||
|
||||
it('should support .use of other routers', function(done){
|
||||
it('should support .use of other routers', function (done) {
|
||||
var router = new Router();
|
||||
var another = new Router();
|
||||
|
||||
another.get('/bar', function(req, res){
|
||||
another.get('/bar', function (req, res) {
|
||||
res.end();
|
||||
});
|
||||
router.use('/foo', another);
|
||||
|
||||
router.handle({ url: '/foo/bar', method: 'GET' }, { end: done }, function(){});
|
||||
router.handle({ url: '/foo/bar', method: 'GET' }, { end: done }, function () { });
|
||||
});
|
||||
|
||||
it('should support dynamic routes', function(done){
|
||||
it('should support dynamic routes', function (done) {
|
||||
var router = new Router();
|
||||
var another = new Router();
|
||||
|
||||
another.get('/:bar', function(req, res){
|
||||
another.get('/:bar', function (req, res) {
|
||||
assert.strictEqual(req.params.bar, 'route')
|
||||
res.end();
|
||||
});
|
||||
router.use('/:foo', another);
|
||||
|
||||
router.handle({ url: '/test/route', method: 'GET' }, { end: done }, function(){});
|
||||
router.handle({ url: '/test/route', method: 'GET' }, { end: done }, function () { });
|
||||
});
|
||||
|
||||
it('should handle blank URL', function(done){
|
||||
it('should handle blank URL', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.use(function (req, res) {
|
||||
|
|
@ -88,10 +88,10 @@ describe('Router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
it('should not stack overflow with many registered routes', function(done){
|
||||
it('should not stack overflow with many registered routes', function (done) {
|
||||
this.timeout(5000) // long-running test
|
||||
|
||||
var handler = function(req, res){ res.end(new Error('wrong handler')) };
|
||||
var handler = function (req, res) { res.end(new Error('wrong handler')) };
|
||||
var router = new Router();
|
||||
|
||||
for (var i = 0; i < 6000; i++) {
|
||||
|
|
@ -102,7 +102,7 @@ describe('Router', function(){
|
|||
res.end();
|
||||
});
|
||||
|
||||
router.handle({ url: '/', method: 'GET' }, { end: done }, function(){});
|
||||
router.handle({ url: '/', method: 'GET' }, { end: done }, function () { });
|
||||
});
|
||||
|
||||
it('should not stack overflow with a large sync route stack', function (done) {
|
||||
|
|
@ -159,69 +159,69 @@ describe('Router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('.handle', function(){
|
||||
it('should dispatch', function(done){
|
||||
describe('.handle', function () {
|
||||
it('should dispatch', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.route('/foo').get(function(req, res){
|
||||
router.route('/foo').get(function (req, res) {
|
||||
res.send('foo');
|
||||
});
|
||||
|
||||
var res = {
|
||||
send: function(val) {
|
||||
send: function (val) {
|
||||
assert.strictEqual(val, 'foo')
|
||||
done();
|
||||
}
|
||||
}
|
||||
router.handle({ url: '/foo', method: 'GET' }, res, function(){});
|
||||
router.handle({ url: '/foo', method: 'GET' }, res, function () { });
|
||||
})
|
||||
})
|
||||
|
||||
describe('.multiple callbacks', function(){
|
||||
it('should throw if a callback is null', function(){
|
||||
describe('.multiple callbacks', function () {
|
||||
it('should throw if a callback is null', function () {
|
||||
assert.throws(function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all(null);
|
||||
})
|
||||
})
|
||||
|
||||
it('should throw if a callback is undefined', function(){
|
||||
it('should throw if a callback is undefined', function () {
|
||||
assert.throws(function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all(undefined);
|
||||
})
|
||||
})
|
||||
|
||||
it('should throw if a callback is not a function', function(){
|
||||
it('should throw if a callback is not a function', function () {
|
||||
assert.throws(function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all('not a function');
|
||||
})
|
||||
})
|
||||
|
||||
it('should not throw if all callbacks are functions', function(){
|
||||
it('should not throw if all callbacks are functions', function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all(function(){}).all(function(){});
|
||||
router.route('/foo').all(function () { }).all(function () { });
|
||||
})
|
||||
})
|
||||
|
||||
describe('error', function(){
|
||||
it('should skip non error middleware', function(done){
|
||||
describe('error', function () {
|
||||
it('should skip non error middleware', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.get('/foo', function(req, res, next){
|
||||
router.get('/foo', function (req, res, next) {
|
||||
next(new Error('foo'));
|
||||
});
|
||||
|
||||
router.get('/bar', function(req, res, next){
|
||||
router.get('/bar', function (req, res, next) {
|
||||
next(new Error('bar'));
|
||||
});
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
assert(false);
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'foo');
|
||||
done();
|
||||
});
|
||||
|
|
@ -229,59 +229,59 @@ describe('Router', function(){
|
|||
router.handle({ url: '/foo', method: 'GET' }, {}, done);
|
||||
});
|
||||
|
||||
it('should handle throwing inside routes with params', function(done) {
|
||||
it('should handle throwing inside routes with params', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.get('/foo/:id', function () {
|
||||
throw new Error('foo');
|
||||
});
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
assert(false);
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'foo');
|
||||
done();
|
||||
});
|
||||
|
||||
router.handle({ url: '/foo/2', method: 'GET' }, {}, function() {});
|
||||
router.handle({ url: '/foo/2', method: 'GET' }, {}, function () { });
|
||||
});
|
||||
|
||||
it('should handle throwing in handler after async param', function(done) {
|
||||
it('should handle throwing in handler after async param', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.param('user', function(req, res, next, val){
|
||||
process.nextTick(function(){
|
||||
router.param('user', function (req, res, next, val) {
|
||||
process.nextTick(function () {
|
||||
req.user = val;
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
router.use('/:user', function(req, res, next){
|
||||
router.use('/:user', function (req, res, next) {
|
||||
throw new Error('oh no!');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'oh no!');
|
||||
done();
|
||||
});
|
||||
|
||||
router.handle({ url: '/bob', method: 'GET' }, {}, function() {});
|
||||
router.handle({ url: '/bob', method: 'GET' }, {}, function () { });
|
||||
});
|
||||
|
||||
it('should handle throwing inside error handlers', function(done) {
|
||||
it('should handle throwing inside error handlers', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
throw new Error('boom!');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
throw new Error('oops');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'oops');
|
||||
done();
|
||||
});
|
||||
|
|
@ -412,17 +412,17 @@ describe('Router', function(){
|
|||
});
|
||||
})
|
||||
|
||||
describe('.all', function() {
|
||||
it('should support using .all to capture all http verbs', function(done){
|
||||
describe('.all', function () {
|
||||
it('should support using .all to capture all http verbs', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
var count = 0;
|
||||
router.all('/foo', function(){ count++; });
|
||||
router.all('/foo', function () { count++; });
|
||||
|
||||
var url = '/foo?bar=baz';
|
||||
|
||||
methods.forEach(function testMethod(method) {
|
||||
router.handle({ url: url, method: method }, {}, function() {});
|
||||
router.handle({ url: url, method: method }, {}, function () { });
|
||||
});
|
||||
|
||||
assert.equal(count, methods.length);
|
||||
|
|
@ -430,7 +430,7 @@ describe('Router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('.use', function() {
|
||||
describe('.use', function () {
|
||||
it('should require middleware', function () {
|
||||
var router = new Router()
|
||||
assert.throws(function () { router.use('/') }, /argument handler is required/)
|
||||
|
|
@ -460,7 +460,7 @@ describe('Router', function(){
|
|||
var cb = after(4, done)
|
||||
var router = new Router()
|
||||
|
||||
function no () {
|
||||
function no() {
|
||||
throw new Error('should not be called')
|
||||
}
|
||||
|
||||
|
|
@ -474,30 +474,30 @@ describe('Router', function(){
|
|||
router.handle({ url: '*', method: 'GET' }, { end: cb }, no)
|
||||
})
|
||||
|
||||
it('should accept array of middleware', function(done){
|
||||
it('should accept array of middleware', function (done) {
|
||||
var count = 0;
|
||||
var router = new Router();
|
||||
|
||||
function fn1(req, res, next){
|
||||
function fn1(req, res, next) {
|
||||
assert.equal(++count, 1);
|
||||
next();
|
||||
}
|
||||
|
||||
function fn2(req, res, next){
|
||||
function fn2(req, res, next) {
|
||||
assert.equal(++count, 2);
|
||||
next();
|
||||
}
|
||||
|
||||
router.use([fn1, fn2], function(req, res){
|
||||
router.use([fn1, fn2], function (req, res) {
|
||||
assert.equal(++count, 3);
|
||||
done();
|
||||
});
|
||||
|
||||
router.handle({ url: '/foo', method: 'GET' }, {}, function(){});
|
||||
router.handle({ url: '/foo', method: 'GET' }, {}, function () { });
|
||||
})
|
||||
})
|
||||
|
||||
describe('.param', function() {
|
||||
describe('.param', function () {
|
||||
it('should require function', function () {
|
||||
var router = new Router();
|
||||
assert.throws(router.param.bind(router, 'id'), /argument fn is required/);
|
||||
|
|
@ -508,15 +508,15 @@ describe('Router', function(){
|
|||
assert.throws(router.param.bind(router, 'id', 42), /argument fn must be a function/);
|
||||
});
|
||||
|
||||
it('should call param function when routing VERBS', function(done) {
|
||||
it('should call param function when routing VERBS', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.param('id', function(req, res, next, id) {
|
||||
router.param('id', function (req, res, next, id) {
|
||||
assert.equal(id, '123');
|
||||
next();
|
||||
});
|
||||
|
||||
router.get('/foo/:id/bar', function(req, res, next) {
|
||||
router.get('/foo/:id/bar', function (req, res, next) {
|
||||
assert.equal(req.params.id, '123');
|
||||
next();
|
||||
});
|
||||
|
|
@ -524,15 +524,15 @@ describe('Router', function(){
|
|||
router.handle({ url: '/foo/123/bar', method: 'get' }, {}, done);
|
||||
});
|
||||
|
||||
it('should call param function when routing middleware', function(done) {
|
||||
it('should call param function when routing middleware', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.param('id', function(req, res, next, id) {
|
||||
router.param('id', function (req, res, next, id) {
|
||||
assert.equal(id, '123');
|
||||
next();
|
||||
});
|
||||
|
||||
router.use('/foo/:id/bar', function(req, res, next) {
|
||||
router.use('/foo/:id/bar', function (req, res, next) {
|
||||
assert.equal(req.params.id, '123');
|
||||
assert.equal(req.url, '/baz');
|
||||
next();
|
||||
|
|
@ -541,17 +541,17 @@ describe('Router', function(){
|
|||
router.handle({ url: '/foo/123/bar/baz', method: 'get' }, {}, done);
|
||||
});
|
||||
|
||||
it('should only call once per request', function(done) {
|
||||
it('should only call once per request', function (done) {
|
||||
var count = 0;
|
||||
var req = { url: '/foo/bob/bar', method: 'get' };
|
||||
var router = new Router();
|
||||
var sub = new Router();
|
||||
|
||||
sub.get('/bar', function(req, res, next) {
|
||||
sub.get('/bar', function (req, res, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
router.param('user', function(req, res, next, user) {
|
||||
router.param('user', function (req, res, next, user) {
|
||||
count++;
|
||||
req.user = user;
|
||||
next();
|
||||
|
|
@ -560,7 +560,7 @@ describe('Router', function(){
|
|||
router.use('/foo/:user/', new Router());
|
||||
router.use('/foo/:user/', sub);
|
||||
|
||||
router.handle(req, {}, function(err) {
|
||||
router.handle(req, {}, function (err) {
|
||||
if (err) return done(err);
|
||||
assert.equal(count, 1);
|
||||
assert.equal(req.user, 'bob');
|
||||
|
|
@ -568,17 +568,17 @@ describe('Router', function(){
|
|||
});
|
||||
});
|
||||
|
||||
it('should call when values differ', function(done) {
|
||||
it('should call when values differ', function (done) {
|
||||
var count = 0;
|
||||
var req = { url: '/foo/bob/bar', method: 'get' };
|
||||
var router = new Router();
|
||||
var sub = new Router();
|
||||
|
||||
sub.get('/bar', function(req, res, next) {
|
||||
sub.get('/bar', function (req, res, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
router.param('user', function(req, res, next, user) {
|
||||
router.param('user', function (req, res, next, user) {
|
||||
count++;
|
||||
req.user = user;
|
||||
next();
|
||||
|
|
@ -587,7 +587,7 @@ describe('Router', function(){
|
|||
router.use('/foo/:user/', new Router());
|
||||
router.use('/:user/bob/', sub);
|
||||
|
||||
router.handle(req, {}, function(err) {
|
||||
router.handle(req, {}, function (err) {
|
||||
if (err) return done(err);
|
||||
assert.equal(count, 2);
|
||||
assert.equal(req.user, 'foo');
|
||||
|
|
@ -596,8 +596,8 @@ describe('Router', function(){
|
|||
});
|
||||
});
|
||||
|
||||
describe('parallel requests', function() {
|
||||
it('should not mix requests', function(done) {
|
||||
describe('parallel requests', function () {
|
||||
it('should not mix requests', function (done) {
|
||||
var req1 = { url: '/foo/50/bar', method: 'get' };
|
||||
var req2 = { url: '/foo/10/bar', method: 'get' };
|
||||
var router = new Router();
|
||||
|
|
@ -605,11 +605,11 @@ describe('Router', function(){
|
|||
var cb = after(2, done)
|
||||
|
||||
|
||||
sub.get('/bar', function(req, res, next) {
|
||||
sub.get('/bar', function (req, res, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
router.param('ms', function(req, res, next, ms) {
|
||||
router.param('ms', function (req, res, next, ms) {
|
||||
ms = parseInt(ms, 10);
|
||||
req.ms = ms;
|
||||
setTimeout(next, ms);
|
||||
|
|
@ -618,14 +618,14 @@ describe('Router', function(){
|
|||
router.use('/foo/:ms/', new Router());
|
||||
router.use('/foo/:ms/', sub);
|
||||
|
||||
router.handle(req1, {}, function(err) {
|
||||
router.handle(req1, {}, function (err) {
|
||||
assert.ifError(err);
|
||||
assert.equal(req1.ms, 50);
|
||||
assert.equal(req1.originalUrl, '/foo/50/bar');
|
||||
cb()
|
||||
});
|
||||
|
||||
router.handle(req2, {}, function(err) {
|
||||
router.handle(req2, {}, function (err) {
|
||||
assert.ifError(err);
|
||||
assert.equal(req2.ms, 10);
|
||||
assert.equal(req2.originalUrl, '/foo/10/bar');
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, fs = require('fs');
|
||||
var path = require('path')
|
||||
, fs = require('node:fs');
|
||||
var path = require('node:path')
|
||||
|
||||
function render(path, options, fn) {
|
||||
fs.readFile(path, 'utf8', function(err, str){
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var express = require('../');
|
||||
var request = require('supertest');
|
||||
var assert = require('assert');
|
||||
var assert = require('node:assert');
|
||||
|
||||
describe('HEAD', function(){
|
||||
it('should default to GET', function(done){
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var express = require('../')
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
|
||||
describe('app.listen()', function(){
|
||||
it('should wrap with an HTTP server', function(done){
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
|
||||
describe('app', function(){
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..');
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
var tmpl = require('./support/tmpl');
|
||||
|
||||
describe('app', function(){
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe('app', function(){
|
|||
var app = express();
|
||||
|
||||
app.request.querystring = function(){
|
||||
return require('url').parse(this.url).query;
|
||||
return require('node:url').parse(this.url).query;
|
||||
};
|
||||
|
||||
app.use(function(req, res){
|
||||
|
|
|
|||
|
|
@ -3,26 +3,26 @@
|
|||
var after = require('after');
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert')
|
||||
, assert = require('node:assert')
|
||||
, methods = require('../lib/utils').methods;
|
||||
|
||||
var shouldSkipQuery = require('./support/utils').shouldSkipQuery
|
||||
|
||||
describe('app.router', function(){
|
||||
it('should restore req.params after leaving router', function(done){
|
||||
describe('app.router', function () {
|
||||
it('should restore req.params after leaving router', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router();
|
||||
|
||||
function handler1(req, res, next){
|
||||
function handler1(req, res, next) {
|
||||
res.setHeader('x-user-id', String(req.params.id));
|
||||
next()
|
||||
}
|
||||
|
||||
function handler2(req, res){
|
||||
function handler2(req, res) {
|
||||
res.send(req.params.id);
|
||||
}
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
res.setHeader('x-router', String(req.params.id));
|
||||
next();
|
||||
});
|
||||
|
|
@ -36,17 +36,17 @@ describe('app.router', function(){
|
|||
.expect(200, '1', done);
|
||||
})
|
||||
|
||||
describe('methods', function(){
|
||||
methods.forEach(function(method){
|
||||
describe('methods', function () {
|
||||
methods.forEach(function (method) {
|
||||
if (method === 'connect') return;
|
||||
|
||||
it('should include ' + method.toUpperCase(), function(done){
|
||||
it('should include ' + method.toUpperCase(), function (done) {
|
||||
if (method === 'query' && shouldSkipQuery(process.versions.node)) {
|
||||
this.skip()
|
||||
}
|
||||
var app = express();
|
||||
|
||||
app[method]('/foo', function(req, res){
|
||||
app[method]('/foo', function (req, res) {
|
||||
res.send(method)
|
||||
});
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ describe('app.router', function(){
|
|||
.expect(200, done)
|
||||
})
|
||||
|
||||
it('should reject numbers for app.' + method, function(){
|
||||
it('should reject numbers for app.' + method, function () {
|
||||
var app = express();
|
||||
assert.throws(app[method].bind(app, '/', 3), /argument handler must be a function/);
|
||||
})
|
||||
|
|
@ -92,7 +92,7 @@ describe('app.router', function(){
|
|||
})
|
||||
|
||||
describe('decode params', function () {
|
||||
it('should decode correct params', function(done){
|
||||
it('should decode correct params', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/:name', function (req, res) {
|
||||
|
|
@ -104,7 +104,7 @@ describe('app.router', function(){
|
|||
.expect('foo/bar', done);
|
||||
})
|
||||
|
||||
it('should not accept params in malformed paths', function(done) {
|
||||
it('should not accept params in malformed paths', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/:name', function (req, res) {
|
||||
|
|
@ -116,7 +116,7 @@ describe('app.router', function(){
|
|||
.expect(400, done);
|
||||
})
|
||||
|
||||
it('should not decode spaces', function(done) {
|
||||
it('should not decode spaces', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/:name', function (req, res) {
|
||||
|
|
@ -128,7 +128,7 @@ describe('app.router', function(){
|
|||
.expect('foo+bar', done);
|
||||
})
|
||||
|
||||
it('should work with unicode', function(done) {
|
||||
it('should work with unicode', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/:name', function (req, res) {
|
||||
|
|
@ -141,22 +141,22 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
it('should be .use()able', function(done){
|
||||
it('should be .use()able', function (done) {
|
||||
var app = express();
|
||||
|
||||
var calls = [];
|
||||
|
||||
app.use(function(req, res, next){
|
||||
app.use(function (req, res, next) {
|
||||
calls.push('before');
|
||||
next();
|
||||
});
|
||||
|
||||
app.get('/', function(req, res, next){
|
||||
app.get('/', function (req, res, next) {
|
||||
calls.push('GET /')
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function(req, res, next){
|
||||
app.use(function (req, res, next) {
|
||||
calls.push('after');
|
||||
res.json(calls)
|
||||
});
|
||||
|
|
@ -166,11 +166,11 @@ describe('app.router', function(){
|
|||
.expect(200, ['before', 'GET /', 'after'], done)
|
||||
})
|
||||
|
||||
describe('when given a regexp', function(){
|
||||
it('should match the pathname only', function(done){
|
||||
describe('when given a regexp', function () {
|
||||
it('should match the pathname only', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get(/^\/user\/[0-9]+$/, function(req, res){
|
||||
app.get(/^\/user\/[0-9]+$/, function (req, res) {
|
||||
res.end('user');
|
||||
});
|
||||
|
||||
|
|
@ -179,10 +179,10 @@ describe('app.router', function(){
|
|||
.expect('user', done);
|
||||
})
|
||||
|
||||
it('should populate req.params with the captures', function(done){
|
||||
it('should populate req.params with the captures', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get(/^\/user\/([0-9]+)\/(view|edit)?$/, function(req, res){
|
||||
app.get(/^\/user\/([0-9]+)\/(view|edit)?$/, function (req, res) {
|
||||
var id = req.params[0]
|
||||
, op = req.params[1];
|
||||
res.end(op + 'ing user ' + id);
|
||||
|
|
@ -194,11 +194,11 @@ describe('app.router', function(){
|
|||
})
|
||||
|
||||
if (supportsRegexp('(?<foo>.*)')) {
|
||||
it('should populate req.params with named captures', function(done){
|
||||
it('should populate req.params with named captures', function (done) {
|
||||
var app = express();
|
||||
var re = new RegExp('^/user/(?<userId>[0-9]+)/(view|edit)?$');
|
||||
|
||||
app.get(re, function(req, res){
|
||||
app.get(re, function (req, res) {
|
||||
var id = req.params.userId
|
||||
, op = req.params[0];
|
||||
res.end(op + 'ing user ' + id);
|
||||
|
|
@ -240,11 +240,11 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('case sensitivity', function(){
|
||||
it('should be disabled by default', function(done){
|
||||
describe('case sensitivity', function () {
|
||||
it('should be disabled by default', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/user', function(req, res){
|
||||
app.get('/user', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -253,13 +253,13 @@ describe('app.router', function(){
|
|||
.expect('tj', done);
|
||||
})
|
||||
|
||||
describe('when "case sensitive routing" is enabled', function(){
|
||||
it('should match identical casing', function(done){
|
||||
describe('when "case sensitive routing" is enabled', function () {
|
||||
it('should match identical casing', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('case sensitive routing');
|
||||
|
||||
app.get('/uSer', function(req, res){
|
||||
app.get('/uSer', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -268,12 +268,12 @@ describe('app.router', function(){
|
|||
.expect('tj', done);
|
||||
})
|
||||
|
||||
it('should not match otherwise', function(done){
|
||||
it('should not match otherwise', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('case sensitive routing');
|
||||
|
||||
app.get('/uSer', function(req, res){
|
||||
app.get('/uSer', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -284,12 +284,12 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('params', function(){
|
||||
it('should overwrite existing req.params by default', function(done){
|
||||
describe('params', function () {
|
||||
it('should overwrite existing req.params by default', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router();
|
||||
|
||||
router.get('/:action', function(req, res){
|
||||
router.get('/:action', function (req, res) {
|
||||
res.send(req.params);
|
||||
});
|
||||
|
||||
|
|
@ -300,13 +300,13 @@ describe('app.router', function(){
|
|||
.expect(200, '{"action":"get"}', done);
|
||||
})
|
||||
|
||||
it('should allow merging existing req.params', function(done){
|
||||
it('should allow merging existing req.params', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router({ mergeParams: true });
|
||||
|
||||
router.get('/:action', function(req, res){
|
||||
router.get('/:action', function (req, res) {
|
||||
var keys = Object.keys(req.params).sort();
|
||||
res.send(keys.map(function(k){ return [k, req.params[k]] }));
|
||||
res.send(keys.map(function (k) { return [k, req.params[k]] }));
|
||||
});
|
||||
|
||||
app.use('/user/:user', router);
|
||||
|
|
@ -316,13 +316,13 @@ describe('app.router', function(){
|
|||
.expect(200, '[["action","get"],["user","tj"]]', done);
|
||||
})
|
||||
|
||||
it('should use params from router', function(done){
|
||||
it('should use params from router', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router({ mergeParams: true });
|
||||
|
||||
router.get('/:thing', function(req, res){
|
||||
router.get('/:thing', function (req, res) {
|
||||
var keys = Object.keys(req.params).sort();
|
||||
res.send(keys.map(function(k){ return [k, req.params[k]] }));
|
||||
res.send(keys.map(function (k) { return [k, req.params[k]] }));
|
||||
});
|
||||
|
||||
app.use('/user/:thing', router);
|
||||
|
|
@ -332,13 +332,13 @@ describe('app.router', function(){
|
|||
.expect(200, '[["thing","get"]]', done);
|
||||
})
|
||||
|
||||
it('should merge numeric indices req.params', function(done){
|
||||
it('should merge numeric indices req.params', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router({ mergeParams: true });
|
||||
|
||||
router.get(/^\/(.*)\.(.*)/, function (req, res) {
|
||||
var keys = Object.keys(req.params).sort();
|
||||
res.send(keys.map(function(k){ return [k, req.params[k]] }));
|
||||
res.send(keys.map(function (k) { return [k, req.params[k]] }));
|
||||
});
|
||||
|
||||
app.use(/^\/user\/id:(\d+)/, router);
|
||||
|
|
@ -348,13 +348,13 @@ describe('app.router', function(){
|
|||
.expect(200, '[["0","10"],["1","profile"],["2","json"]]', done);
|
||||
})
|
||||
|
||||
it('should merge numeric indices req.params when more in parent', function(done){
|
||||
it('should merge numeric indices req.params when more in parent', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router({ mergeParams: true });
|
||||
|
||||
router.get(/\/(.*)/, function (req, res) {
|
||||
var keys = Object.keys(req.params).sort();
|
||||
res.send(keys.map(function(k){ return [k, req.params[k]] }));
|
||||
res.send(keys.map(function (k) { return [k, req.params[k]] }));
|
||||
});
|
||||
|
||||
app.use(/^\/user\/id:(\d+)\/name:(\w+)/, router);
|
||||
|
|
@ -364,13 +364,13 @@ describe('app.router', function(){
|
|||
.expect(200, '[["0","10"],["1","tj"],["2","profile"]]', done);
|
||||
})
|
||||
|
||||
it('should merge numeric indices req.params when parent has same number', function(done){
|
||||
it('should merge numeric indices req.params when parent has same number', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router({ mergeParams: true });
|
||||
|
||||
router.get(/\/name:(\w+)/, function(req, res){
|
||||
router.get(/\/name:(\w+)/, function (req, res) {
|
||||
var keys = Object.keys(req.params).sort();
|
||||
res.send(keys.map(function(k){ return [k, req.params[k]] }));
|
||||
res.send(keys.map(function (k) { return [k, req.params[k]] }));
|
||||
});
|
||||
|
||||
app.use(/\/user\/id:(\d+)/, router);
|
||||
|
|
@ -380,13 +380,13 @@ describe('app.router', function(){
|
|||
.expect(200, '[["0","10"],["1","tj"]]', done);
|
||||
})
|
||||
|
||||
it('should ignore invalid incoming req.params', function(done){
|
||||
it('should ignore invalid incoming req.params', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router({ mergeParams: true });
|
||||
|
||||
router.get('/:name', function(req, res){
|
||||
router.get('/:name', function (req, res) {
|
||||
var keys = Object.keys(req.params).sort();
|
||||
res.send(keys.map(function(k){ return [k, req.params[k]] }));
|
||||
res.send(keys.map(function (k) { return [k, req.params[k]] }));
|
||||
});
|
||||
|
||||
app.use('/user/', function (req, res, next) {
|
||||
|
|
@ -399,7 +399,7 @@ describe('app.router', function(){
|
|||
.expect(200, '[["name","tj"]]', done);
|
||||
})
|
||||
|
||||
it('should restore req.params', function(done){
|
||||
it('should restore req.params', function (done) {
|
||||
var app = express();
|
||||
var router = new express.Router({ mergeParams: true });
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ describe('app.router', function(){
|
|||
app.use(/\/user\/id:(\d+)/, function (req, res, next) {
|
||||
router(req, res, function (err) {
|
||||
var keys = Object.keys(req.params).sort();
|
||||
res.send(keys.map(function(k){ return [k, req.params[k]] }));
|
||||
res.send(keys.map(function (k) { return [k, req.params[k]] }));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -420,11 +420,11 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('trailing slashes', function(){
|
||||
it('should be optional by default', function(done){
|
||||
describe('trailing slashes', function () {
|
||||
it('should be optional by default', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/user', function(req, res){
|
||||
app.get('/user', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -433,13 +433,13 @@ describe('app.router', function(){
|
|||
.expect('tj', done);
|
||||
})
|
||||
|
||||
describe('when "strict routing" is enabled', function(){
|
||||
it('should match trailing slashes', function(done){
|
||||
describe('when "strict routing" is enabled', function () {
|
||||
it('should match trailing slashes', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
||||
app.get('/user/', function(req, res){
|
||||
app.get('/user/', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -448,7 +448,7 @@ describe('app.router', function(){
|
|||
.expect('tj', done);
|
||||
})
|
||||
|
||||
it('should pass-though middleware', function(done){
|
||||
it('should pass-though middleware', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
|
@ -458,7 +458,7 @@ describe('app.router', function(){
|
|||
next();
|
||||
});
|
||||
|
||||
app.get('/user/', function(req, res){
|
||||
app.get('/user/', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -468,7 +468,7 @@ describe('app.router', function(){
|
|||
.expect(200, 'tj', done);
|
||||
})
|
||||
|
||||
it('should pass-though mounted middleware', function(done){
|
||||
it('should pass-though mounted middleware', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
|
@ -478,7 +478,7 @@ describe('app.router', function(){
|
|||
next();
|
||||
});
|
||||
|
||||
app.get('/user/test/', function(req, res){
|
||||
app.get('/user/test/', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -488,12 +488,12 @@ describe('app.router', function(){
|
|||
.expect(200, 'tj', done);
|
||||
})
|
||||
|
||||
it('should match no slashes', function(done){
|
||||
it('should match no slashes', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
||||
app.get('/user', function(req, res){
|
||||
app.get('/user', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -502,12 +502,12 @@ describe('app.router', function(){
|
|||
.expect('tj', done);
|
||||
})
|
||||
|
||||
it('should match middleware when omitting the trailing slash', function(done){
|
||||
it('should match middleware when omitting the trailing slash', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
||||
app.use('/user/', function(req, res){
|
||||
app.use('/user/', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -516,12 +516,12 @@ describe('app.router', function(){
|
|||
.expect(200, 'tj', done);
|
||||
})
|
||||
|
||||
it('should match middleware', function(done){
|
||||
it('should match middleware', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
||||
app.use('/user', function(req, res){
|
||||
app.use('/user', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -530,12 +530,12 @@ describe('app.router', function(){
|
|||
.expect(200, 'tj', done);
|
||||
})
|
||||
|
||||
it('should match middleware when adding the trailing slash', function(done){
|
||||
it('should match middleware when adding the trailing slash', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
||||
app.use('/user', function(req, res){
|
||||
app.use('/user', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -544,12 +544,12 @@ describe('app.router', function(){
|
|||
.expect(200, 'tj', done);
|
||||
})
|
||||
|
||||
it('should fail when omitting the trailing slash', function(done){
|
||||
it('should fail when omitting the trailing slash', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
||||
app.get('/user/', function(req, res){
|
||||
app.get('/user/', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -558,12 +558,12 @@ describe('app.router', function(){
|
|||
.expect(404, done);
|
||||
})
|
||||
|
||||
it('should fail when adding the trailing slash', function(done){
|
||||
it('should fail when adding the trailing slash', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.enable('strict routing');
|
||||
|
||||
app.get('/user', function(req, res){
|
||||
app.get('/user', function (req, res) {
|
||||
res.end('tj');
|
||||
});
|
||||
|
||||
|
|
@ -574,10 +574,10 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
it('should allow literal "."', function(done){
|
||||
it('should allow literal "."', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/api/users/:from..:to', function(req, res){
|
||||
app.get('/api/users/:from..:to', function (req, res) {
|
||||
var from = req.params.from
|
||||
, to = req.params.to;
|
||||
|
||||
|
|
@ -589,11 +589,11 @@ describe('app.router', function(){
|
|||
.expect('users from 1 to 50', done);
|
||||
})
|
||||
|
||||
describe(':name', function(){
|
||||
it('should denote a capture group', function(done){
|
||||
describe(':name', function () {
|
||||
it('should denote a capture group', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/user/:user', function(req, res){
|
||||
app.get('/user/:user', function (req, res) {
|
||||
res.end(req.params.user);
|
||||
});
|
||||
|
||||
|
|
@ -602,10 +602,10 @@ describe('app.router', function(){
|
|||
.expect('tj', done);
|
||||
})
|
||||
|
||||
it('should match a single segment only', function(done){
|
||||
it('should match a single segment only', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/user/:user', function(req, res){
|
||||
app.get('/user/:user', function (req, res) {
|
||||
res.end(req.params.user);
|
||||
});
|
||||
|
||||
|
|
@ -614,10 +614,10 @@ describe('app.router', function(){
|
|||
.expect(404, done);
|
||||
})
|
||||
|
||||
it('should allow several capture groups', function(done){
|
||||
it('should allow several capture groups', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/user/:user/:op', function(req, res){
|
||||
app.get('/user/:user/:op', function (req, res) {
|
||||
res.end(req.params.op + 'ing ' + req.params.user);
|
||||
});
|
||||
|
||||
|
|
@ -626,11 +626,11 @@ describe('app.router', function(){
|
|||
.expect('editing tj', done);
|
||||
})
|
||||
|
||||
it('should work following a partial capture group', function(done){
|
||||
it('should work following a partial capture group', function (done) {
|
||||
var app = express();
|
||||
var cb = after(2, done);
|
||||
|
||||
app.get('/user{s}/:user/:op', function(req, res){
|
||||
app.get('/user{s}/:user/:op', function (req, res) {
|
||||
res.end(req.params.op + 'ing ' + req.params.user + (req.url.startsWith('/users') ? ' (old)' : ''));
|
||||
});
|
||||
|
||||
|
|
@ -643,10 +643,10 @@ describe('app.router', function(){
|
|||
.expect('editing tj (old)', cb);
|
||||
})
|
||||
|
||||
it('should work inside literal parenthesis', function(done){
|
||||
it('should work inside literal parenthesis', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/:user\\(:op\\)', function(req, res){
|
||||
app.get('/:user\\(:op\\)', function (req, res) {
|
||||
res.end(req.params.op + 'ing ' + req.params.user);
|
||||
});
|
||||
|
||||
|
|
@ -655,11 +655,11 @@ describe('app.router', function(){
|
|||
.expect('editing tj', done);
|
||||
})
|
||||
|
||||
it('should work in array of paths', function(done){
|
||||
it('should work in array of paths', function (done) {
|
||||
var app = express();
|
||||
var cb = after(2, done);
|
||||
|
||||
app.get(['/user/:user/poke', '/user/:user/pokes'], function(req, res){
|
||||
app.get(['/user/:user/poke', '/user/:user/pokes'], function (req, res) {
|
||||
res.end('poking ' + req.params.user);
|
||||
});
|
||||
|
||||
|
|
@ -673,11 +673,11 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe(':name?', function(){
|
||||
it('should denote an optional capture group', function(done){
|
||||
describe(':name?', function () {
|
||||
it('should denote an optional capture group', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/user/:user{/:op}', function(req, res){
|
||||
app.get('/user/:user{/:op}', function (req, res) {
|
||||
var op = req.params.op || 'view';
|
||||
res.end(op + 'ing ' + req.params.user);
|
||||
});
|
||||
|
|
@ -687,10 +687,10 @@ describe('app.router', function(){
|
|||
.expect('viewing tj', done);
|
||||
})
|
||||
|
||||
it('should populate the capture group', function(done){
|
||||
it('should populate the capture group', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/user/:user{/:op}', function(req, res){
|
||||
app.get('/user/:user{/:op}', function (req, res) {
|
||||
var op = req.params.op || 'view';
|
||||
res.end(op + 'ing ' + req.params.user);
|
||||
});
|
||||
|
|
@ -777,12 +777,12 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('.:name', function(){
|
||||
it('should denote a format', function(done){
|
||||
describe('.:name', function () {
|
||||
it('should denote a format', function (done) {
|
||||
var app = express();
|
||||
var cb = after(2, done)
|
||||
|
||||
app.get('/:name.:format', function(req, res){
|
||||
app.get('/:name.:format', function (req, res) {
|
||||
res.end(req.params.name + ' as ' + req.params.format);
|
||||
});
|
||||
|
||||
|
|
@ -796,12 +796,12 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('.:name?', function(){
|
||||
it('should denote an optional format', function(done){
|
||||
describe('.:name?', function () {
|
||||
it('should denote an optional format', function (done) {
|
||||
var app = express();
|
||||
var cb = after(2, done)
|
||||
|
||||
app.get('/:name{.:format}', function(req, res){
|
||||
app.get('/:name{.:format}', function (req, res) {
|
||||
res.end(req.params.name + ' as ' + (req.params.format || 'html'));
|
||||
});
|
||||
|
||||
|
|
@ -815,12 +815,12 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('when next() is called', function(){
|
||||
it('should continue lookup', function(done){
|
||||
describe('when next() is called', function () {
|
||||
it('should continue lookup', function (done) {
|
||||
var app = express()
|
||||
, calls = [];
|
||||
|
||||
app.get('/foo{/:bar}', function(req, res, next){
|
||||
app.get('/foo{/:bar}', function (req, res, next) {
|
||||
calls.push('/foo/:bar?');
|
||||
next();
|
||||
});
|
||||
|
|
@ -829,7 +829,7 @@ describe('app.router', function(){
|
|||
assert(0);
|
||||
});
|
||||
|
||||
app.get('/foo', function(req, res, next){
|
||||
app.get('/foo', function (req, res, next) {
|
||||
calls.push('/foo');
|
||||
next();
|
||||
});
|
||||
|
|
@ -845,11 +845,11 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('when next("route") is called', function(){
|
||||
it('should jump to next route', function(done){
|
||||
describe('when next("route") is called', function () {
|
||||
it('should jump to next route', function (done) {
|
||||
var app = express()
|
||||
|
||||
function fn(req, res, next){
|
||||
function fn(req, res, next) {
|
||||
res.set('X-Hit', '1')
|
||||
next('route')
|
||||
}
|
||||
|
|
@ -858,7 +858,7 @@ describe('app.router', function(){
|
|||
res.end('failure')
|
||||
});
|
||||
|
||||
app.get('/foo', function(req, res){
|
||||
app.get('/foo', function (req, res) {
|
||||
res.end('success')
|
||||
})
|
||||
|
||||
|
|
@ -874,7 +874,7 @@ describe('app.router', function(){
|
|||
var app = express()
|
||||
var router = express.Router()
|
||||
|
||||
function fn (req, res, next) {
|
||||
function fn(req, res, next) {
|
||||
res.set('X-Hit', '1')
|
||||
next('router')
|
||||
}
|
||||
|
|
@ -900,12 +900,12 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('when next(err) is called', function(){
|
||||
it('should break out of app.router', function(done){
|
||||
describe('when next(err) is called', function () {
|
||||
it('should break out of app.router', function (done) {
|
||||
var app = express()
|
||||
, calls = [];
|
||||
|
||||
app.get('/foo{/:bar}', function(req, res, next){
|
||||
app.get('/foo{/:bar}', function (req, res, next) {
|
||||
calls.push('/foo/:bar?');
|
||||
next();
|
||||
});
|
||||
|
|
@ -914,7 +914,7 @@ describe('app.router', function(){
|
|||
assert(0);
|
||||
});
|
||||
|
||||
app.get('/foo', function(req, res, next){
|
||||
app.get('/foo', function (req, res, next) {
|
||||
calls.push('/foo');
|
||||
next(new Error('fail'));
|
||||
});
|
||||
|
|
@ -923,7 +923,7 @@ describe('app.router', function(){
|
|||
assert(0);
|
||||
});
|
||||
|
||||
app.use(function(err, req, res, next){
|
||||
app.use(function (err, req, res, next) {
|
||||
res.json({
|
||||
calls: calls,
|
||||
error: err.message
|
||||
|
|
@ -935,7 +935,7 @@ describe('app.router', function(){
|
|||
.expect(200, { calls: ['/foo/:bar?', '/foo'], error: 'fail' }, done)
|
||||
})
|
||||
|
||||
it('should call handler in same route, if exists', function(done){
|
||||
it('should call handler in same route, if exists', function (done) {
|
||||
var app = express();
|
||||
|
||||
function fn1(req, res, next) {
|
||||
|
|
@ -967,11 +967,11 @@ describe('app.router', function(){
|
|||
var app = express()
|
||||
var router = new express.Router()
|
||||
|
||||
router.use(function createError (req, res, next) {
|
||||
router.use(function createError(req, res, next) {
|
||||
return Promise.reject(new Error('boom!'))
|
||||
})
|
||||
|
||||
router.use(function sawError (err, req, res, next) {
|
||||
router.use(function sawError(err, req, res, next) {
|
||||
res.send('saw ' + err.name + ': ' + err.message)
|
||||
})
|
||||
|
||||
|
|
@ -986,11 +986,11 @@ describe('app.router', function(){
|
|||
var app = express()
|
||||
var router = new express.Router()
|
||||
|
||||
router.use(function createError (req, res, next) {
|
||||
router.use(function createError(req, res, next) {
|
||||
return Promise.reject()
|
||||
})
|
||||
|
||||
router.use(function sawError (err, req, res, next) {
|
||||
router.use(function sawError(err, req, res, next) {
|
||||
res.send('saw ' + err.name + ': ' + err.message)
|
||||
})
|
||||
|
||||
|
|
@ -1005,7 +1005,7 @@ describe('app.router', function(){
|
|||
var app = express()
|
||||
var router = new express.Router()
|
||||
|
||||
router.use(function createError (req, res, next) {
|
||||
router.use(function createError(req, res, next) {
|
||||
res.send('saw GET /foo')
|
||||
return Promise.resolve('foo')
|
||||
})
|
||||
|
|
@ -1026,15 +1026,15 @@ describe('app.router', function(){
|
|||
var app = express()
|
||||
var router = new express.Router()
|
||||
|
||||
router.use(function createError (req, res, next) {
|
||||
router.use(function createError(req, res, next) {
|
||||
return Promise.reject(new Error('boom!'))
|
||||
})
|
||||
|
||||
router.use(function handleError (err, req, res, next) {
|
||||
router.use(function handleError(err, req, res, next) {
|
||||
return Promise.reject(new Error('caught: ' + err.message))
|
||||
})
|
||||
|
||||
router.use(function sawError (err, req, res, next) {
|
||||
router.use(function sawError(err, req, res, next) {
|
||||
res.send('saw ' + err.name + ': ' + err.message)
|
||||
})
|
||||
|
||||
|
|
@ -1049,15 +1049,15 @@ describe('app.router', function(){
|
|||
var app = express()
|
||||
var router = new express.Router()
|
||||
|
||||
router.use(function createError (req, res, next) {
|
||||
router.use(function createError(req, res, next) {
|
||||
return Promise.reject()
|
||||
})
|
||||
|
||||
router.use(function handleError (err, req, res, next) {
|
||||
router.use(function handleError(err, req, res, next) {
|
||||
return Promise.reject(new Error('caught: ' + err.message))
|
||||
})
|
||||
|
||||
router.use(function sawError (err, req, res, next) {
|
||||
router.use(function sawError(err, req, res, next) {
|
||||
res.send('saw ' + err.name + ': ' + err.message)
|
||||
})
|
||||
|
||||
|
|
@ -1072,11 +1072,11 @@ describe('app.router', function(){
|
|||
var app = express()
|
||||
var router = new express.Router()
|
||||
|
||||
router.use(function createError (req, res, next) {
|
||||
router.use(function createError(req, res, next) {
|
||||
return Promise.reject(new Error('boom!'))
|
||||
})
|
||||
|
||||
router.use(function handleError (err, req, res, next) {
|
||||
router.use(function handleError(err, req, res, next) {
|
||||
res.send('saw ' + err.name + ': ' + err.message)
|
||||
return Promise.resolve('foo')
|
||||
})
|
||||
|
|
@ -1094,16 +1094,16 @@ describe('app.router', function(){
|
|||
})
|
||||
})
|
||||
|
||||
it('should allow rewriting of the url', function(done){
|
||||
it('should allow rewriting of the url', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.get('/account/edit', function(req, res, next){
|
||||
app.get('/account/edit', function (req, res, next) {
|
||||
req.user = { id: 12 }; // faux authenticated user
|
||||
req.url = '/user/' + req.user.id + '/edit';
|
||||
next();
|
||||
});
|
||||
|
||||
app.get('/user/:id/edit', function(req, res){
|
||||
app.get('/user/:id/edit', function (req, res) {
|
||||
res.send('editing user ' + req.params.id);
|
||||
});
|
||||
|
||||
|
|
@ -1112,7 +1112,7 @@ describe('app.router', function(){
|
|||
.expect('editing user 12', done);
|
||||
})
|
||||
|
||||
it('should run in order added', function(done){
|
||||
it('should run in order added', function (done) {
|
||||
var app = express();
|
||||
var path = [];
|
||||
|
||||
|
|
@ -1121,17 +1121,17 @@ describe('app.router', function(){
|
|||
next();
|
||||
});
|
||||
|
||||
app.get('/user/:id', function(req, res, next){
|
||||
app.get('/user/:id', function (req, res, next) {
|
||||
path.push(1);
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function(req, res, next){
|
||||
app.use(function (req, res, next) {
|
||||
path.push(2);
|
||||
next();
|
||||
});
|
||||
|
||||
app.all('/user/:id', function(req, res, next){
|
||||
app.all('/user/:id', function (req, res, next) {
|
||||
path.push(3);
|
||||
next();
|
||||
});
|
||||
|
|
@ -1141,7 +1141,7 @@ describe('app.router', function(){
|
|||
next();
|
||||
});
|
||||
|
||||
app.use(function(req, res, next){
|
||||
app.use(function (req, res, next) {
|
||||
path.push(5);
|
||||
res.end(path.join(','))
|
||||
});
|
||||
|
|
@ -1151,18 +1151,18 @@ describe('app.router', function(){
|
|||
.expect(200, '0,1,2,3,4,5', done);
|
||||
})
|
||||
|
||||
it('should be chainable', function(){
|
||||
it('should be chainable', function () {
|
||||
var app = express();
|
||||
assert.strictEqual(app.get('/', function () {}), app)
|
||||
assert.strictEqual(app.get('/', function () { }), app)
|
||||
})
|
||||
|
||||
it('should should not use disposed router/middleware', function(done){
|
||||
it('should should not use disposed router/middleware', function (done) {
|
||||
// more context: https://github.com/expressjs/express/issues/5743#issuecomment-2277148412
|
||||
|
||||
var app = express();
|
||||
var router = new express.Router();
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
res.setHeader('old', 'foo');
|
||||
next();
|
||||
});
|
||||
|
|
@ -1171,7 +1171,7 @@ describe('app.router', function(){
|
|||
return router.handle(req, res, next);
|
||||
});
|
||||
|
||||
app.get('/', function(req, res, next){
|
||||
app.get('/', function (req, res, next) {
|
||||
res.send('yee');
|
||||
next();
|
||||
});
|
||||
|
|
@ -1179,17 +1179,17 @@ describe('app.router', function(){
|
|||
request(app)
|
||||
.get('/')
|
||||
.expect('old', 'foo')
|
||||
.expect(function(res) {
|
||||
.expect(function (res) {
|
||||
if (typeof res.headers['new'] !== 'undefined') {
|
||||
throw new Error('`new` header should not be present');
|
||||
}
|
||||
})
|
||||
.expect(200, 'yee', function(err, res) {
|
||||
.expect(200, 'yee', function (err, res) {
|
||||
if (err) return done(err);
|
||||
|
||||
router = new express.Router();
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
res.setHeader('new', 'bar');
|
||||
next();
|
||||
});
|
||||
|
|
@ -1197,7 +1197,7 @@ describe('app.router', function(){
|
|||
request(app)
|
||||
.get('/')
|
||||
.expect('new', 'bar')
|
||||
.expect(function(res) {
|
||||
.expect(function (res) {
|
||||
if (typeof res.headers['old'] !== 'undefined') {
|
||||
throw new Error('`old` header should not be present');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, request = require('supertest');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..');
|
||||
var request = require('supertest');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert');
|
||||
var assert = require('node:assert');
|
||||
var express = require('..');
|
||||
|
||||
describe('config', function () {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../');
|
||||
var request = require('supertest');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..')
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
var request = require('supertest')
|
||||
var utils = require('./support/utils')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../');
|
||||
var request = require('supertest');
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
|
||||
describe('req', function(){
|
||||
describe('.get(field)', function(){
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, request = require('supertest');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
|
||||
var express = require('..');
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
var request = require('supertest');
|
||||
var utils = require('./support/utils')
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
var after = require('after')
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
|
||||
var app1 = express();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
|
||||
describe('res', function(){
|
||||
describe('.json(object)', function(){
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
var utils = require('./support/utils');
|
||||
|
||||
describe('res', function(){
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert')
|
||||
, url = require('url');
|
||||
, assert = require('node:assert')
|
||||
, url = require('node:url');
|
||||
|
||||
describe('res', function(){
|
||||
describe('.location(url)', function(){
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
var express = require('..');
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
var request = require('supertest');
|
||||
var tmpl = require('./support/tmpl');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..');
|
||||
var methods = require('../lib/utils').methods;
|
||||
var request = require('supertest');
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
var onFinished = require('on-finished');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var fixtures = path.join(__dirname, 'fixtures');
|
||||
var utils = require('./support/utils');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var fs = require('fs');
|
||||
var fs = require('node:fs');
|
||||
|
||||
var variableRegExp = /\$([0-9a-zA-Z\.]+)/g;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* @private
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
var assert = require('node:assert');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var assert = require('assert');
|
||||
var assert = require('node:assert');
|
||||
var utils = require('../lib/utils');
|
||||
|
||||
describe('utils.etag(body, encoding)', function(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user