diff --git a/History.md b/History.md index e2dfbc84d7..fcdfb8ea9e 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased * cleanup: remove AsyncLocalStorage check from tests * cleanup: remove unnecessary require for global Buffer * perf: use loop for acceptParams +* refactor: prefix built-in node module imports 5.0.1 / 2024-10-08 ========== diff --git a/examples/auth/index.js b/examples/auth/index.js index 2884ca4e17..40b73e6de1 100644 --- a/examples/auth/index.js +++ b/examples/auth/index.js @@ -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(); diff --git a/examples/downloads/index.js b/examples/downloads/index.js index c47dddd738..ddc549ffec 100644 --- a/examples/downloads/index.js +++ b/examples/downloads/index.js @@ -5,7 +5,7 @@ */ var express = require('../../'); -var path = require('path'); +var path = require('node:path'); var app = module.exports = express(); diff --git a/examples/ejs/index.js b/examples/ejs/index.js index a39d805a16..0940d0624f 100644 --- a/examples/ejs/index.js +++ b/examples/ejs/index.js @@ -5,7 +5,7 @@ */ var express = require('../../'); -var path = require('path'); +var path = require('node:path'); var app = module.exports = express(); diff --git a/examples/error-pages/index.js b/examples/error-pages/index.js index efa815c474..0863120bc8 100644 --- a/examples/error-pages/index.js +++ b/examples/error-pages/index.js @@ -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' diff --git a/examples/markdown/index.js b/examples/markdown/index.js index 23d645e66b..53e40ac38e 100644 --- a/examples/markdown/index.js +++ b/examples/markdown/index.js @@ -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(); diff --git a/examples/mvc/index.js b/examples/mvc/index.js index da4727b282..1d8aa0e3c3 100644 --- a/examples/mvc/index.js +++ b/examples/mvc/index.js @@ -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'); diff --git a/examples/mvc/lib/boot.js b/examples/mvc/lib/boot.js index 0216e5d76d..fc2ab0fad9 100644 --- a/examples/mvc/lib/boot.js +++ b/examples/mvc/lib/boot.js @@ -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'); diff --git a/examples/route-separation/index.js b/examples/route-separation/index.js index a471a4b091..0a29c9421a 100644 --- a/examples/route-separation/index.js +++ b/examples/route-separation/index.js @@ -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'); diff --git a/examples/search/index.js b/examples/search/index.js index 4b57168987..951e0d440a 100644 --- a/examples/search/index.js +++ b/examples/search/index.js @@ -12,7 +12,7 @@ */ var express = require('../..'); -var path = require('path'); +var path = require('node:path'); var redis = require('redis'); var db = redis.createClient(); diff --git a/examples/static-files/index.js b/examples/static-files/index.js index 609c546b47..b7c697a2f9 100644 --- a/examples/static-files/index.js +++ b/examples/static-files/index.js @@ -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 diff --git a/examples/view-constructor/github-view.js b/examples/view-constructor/github-view.js index 43d29336ca..eabfb2d0c1 100644 --- a/examples/view-constructor/github-view.js +++ b/examples/view-constructor/github-view.js @@ -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; /** diff --git a/examples/view-locals/index.js b/examples/view-locals/index.js index a2af24f355..e6355602d4 100644 --- a/examples/view-locals/index.js +++ b/examples/view-locals/index.js @@ -5,7 +5,7 @@ */ var express = require('../..'); -var path = require('path'); +var path = require('node:path'); var User = require('./user'); var app = express(); diff --git a/lib/application.js b/lib/application.js index b19055ec82..2f79da6ffb 100644 --- a/lib/application.js +++ b/lib/application.js @@ -17,12 +17,12 @@ var finalhandler = require('finalhandler'); var methods = require('methods'); var debug = require('debug')('express:application'); var View = require('./view'); -var http = require('http'); +var http = require('node:http'); var compileETag = require('./utils').compileETag; var compileQueryParser = require('./utils').compileQueryParser; var compileTrust = require('./utils').compileTrust; var merge = require('utils-merge'); -var resolve = require('path').resolve; +var resolve = require('node:path').resolve; var once = require('once') var Router = require('router'); @@ -593,8 +593,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(); * diff --git a/lib/express.js b/lib/express.js index b4ef299636..2d502eb54e 100644 --- a/lib/express.js +++ b/lib/express.js @@ -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'); diff --git a/lib/request.js b/lib/request.js index 372a9915e9..d8e5263078 100644 --- a/lib/request.js +++ b/lib/request.js @@ -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'); diff --git a/lib/response.js b/lib/response.js index e439a06ae8..dbd3a828d9 100644 --- a/lib/response.js +++ b/lib/response.js @@ -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 merge = require('utils-merge'); var sign = require('cookie-signature').sign; diff --git a/lib/view.js b/lib/view.js index 6beffca6e2..d66b4a2d89 100644 --- a/lib/view.js +++ b/lib/view.js @@ -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. diff --git a/test/Route.js b/test/Route.js index 2a37b9a483..fe6234df55 100644 --- a/test/Route.js +++ b/test/Route.js @@ -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('methods') diff --git a/test/Router.js b/test/Router.js index a1952f445a..168952a63b 100644 --- a/test/Router.js +++ b/test/Router.js @@ -4,7 +4,7 @@ var after = require('after'); var express = require('../') , Router = express.Router , methods = require('methods') - , assert = require('assert'); + , assert = require('node:assert'); describe('Router', function(){ it('should return a function with router methods', function() { diff --git a/test/app.engine.js b/test/app.engine.js index 214510a94c..b0553aa247 100644 --- a/test/app.engine.js +++ b/test/app.engine.js @@ -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){ diff --git a/test/app.head.js b/test/app.head.js index fabb98795a..0207caaeda 100644 --- a/test/app.head.js +++ b/test/app.head.js @@ -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){ diff --git a/test/app.js b/test/app.js index fe7d4c2758..c1e815a052 100644 --- a/test/app.js +++ b/test/app.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('..') var request = require('supertest') diff --git a/test/app.listen.js b/test/app.listen.js index 7e7e731a3b..180162a0fa 100644 --- a/test/app.listen.js +++ b/test/app.listen.js @@ -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){ diff --git a/test/app.locals.js b/test/app.locals.js index a4f804fe2a..3963762fe2 100644 --- a/test/app.locals.js +++ b/test/app.locals.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('../') describe('app', function(){ diff --git a/test/app.render.js b/test/app.render.js index 9d202acfdd..ca15e761d3 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -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(){ diff --git a/test/app.request.js b/test/app.request.js index 4930af84c2..b6c00f5baa 100644 --- a/test/app.request.js +++ b/test/app.request.js @@ -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){ diff --git a/test/app.router.js b/test/app.router.js index bdf4011a61..52e2f19f98 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -3,7 +3,7 @@ var after = require('after'); var express = require('../') , request = require('supertest') - , assert = require('assert') + , assert = require('node:assert') , methods = require('methods'); var shouldSkipQuery = require('./support/utils').shouldSkipQuery diff --git a/test/app.routes.error.js b/test/app.routes.error.js index efc0108b0f..ed53c7857b 100644 --- a/test/app.routes.error.js +++ b/test/app.routes.error.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('../') , request = require('supertest'); diff --git a/test/app.use.js b/test/app.use.js index a88a2f2c8e..1d56aa3b02 100644 --- a/test/app.use.js +++ b/test/app.use.js @@ -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'); diff --git a/test/config.js b/test/config.js index b04367fdbf..d004de03ea 100644 --- a/test/config.js +++ b/test/config.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert'); +var assert = require('node:assert'); var express = require('..'); describe('config', function () { diff --git a/test/exports.js b/test/exports.js index dc635d1dbc..fc7836c159 100644 --- a/test/exports.js +++ b/test/exports.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('../'); var request = require('supertest'); diff --git a/test/express.json.js b/test/express.json.js index 2c394922c8..6b91734ed3 100644 --- a/test/express.json.js +++ b/test/express.json.js @@ -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') diff --git a/test/express.raw.js b/test/express.raw.js index 53995bf829..362fccb1e3 100644 --- a/test/express.raw.js +++ b/test/express.raw.js @@ -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') diff --git a/test/express.static.js b/test/express.static.js index 65a3718a60..16a8ec0516 100644 --- a/test/express.static.js +++ b/test/express.static.js @@ -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') diff --git a/test/express.text.js b/test/express.text.js index 95fcbf8657..1d22929e3b 100644 --- a/test/express.text.js +++ b/test/express.text.js @@ -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') diff --git a/test/express.urlencoded.js b/test/express.urlencoded.js index 50c3e93bba..b2df949f9f 100644 --- a/test/express.urlencoded.js +++ b/test/express.urlencoded.js @@ -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') diff --git a/test/middleware.basic.js b/test/middleware.basic.js index 19f00d9a29..1f1ed17571 100644 --- a/test/middleware.basic.js +++ b/test/middleware.basic.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('../'); var request = require('supertest'); diff --git a/test/req.get.js b/test/req.get.js index 16589b3f05..e73d109c84 100644 --- a/test/req.get.js +++ b/test/req.get.js @@ -2,7 +2,7 @@ var express = require('../') , request = require('supertest') - , assert = require('assert'); + , assert = require('node:assert'); describe('req', function(){ describe('.get(field)', function(){ diff --git a/test/req.query.js b/test/req.query.js index bc76d4106b..c0d3c8376e 100644 --- a/test/req.query.js +++ b/test/req.query.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('../') , request = require('supertest'); diff --git a/test/res.append.js b/test/res.append.js index 8f72598bf5..325dd4d12e 100644 --- a/test/res.append.js +++ b/test/res.append.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('..') var request = require('supertest') diff --git a/test/res.download.js b/test/res.download.js index 5718ff4409..1bd7663c54 100644 --- a/test/res.download.js +++ b/test/res.download.js @@ -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') diff --git a/test/res.format.js b/test/res.format.js index 59205bfaf4..be42730957 100644 --- a/test/res.format.js +++ b/test/res.format.js @@ -3,7 +3,7 @@ var after = require('after') var express = require('../') , request = require('supertest') - , assert = require('assert'); + , assert = require('node:assert'); var app1 = express(); diff --git a/test/res.json.js b/test/res.json.js index bef8adafd5..ffd547e95b 100644 --- a/test/res.json.js +++ b/test/res.json.js @@ -2,7 +2,7 @@ var express = require('../') , request = require('supertest') - , assert = require('assert'); + , assert = require('node:assert'); describe('res', function(){ describe('.json(object)', function(){ diff --git a/test/res.jsonp.js b/test/res.jsonp.js index e9cc08bc05..c1f90f1109 100644 --- a/test/res.jsonp.js +++ b/test/res.jsonp.js @@ -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(){ diff --git a/test/res.location.js b/test/res.location.js index fb03221d7a..b81c6f07d8 100644 --- a/test/res.location.js +++ b/test/res.location.js @@ -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(){ diff --git a/test/res.render.js b/test/res.render.js index 50f0b0a742..114b398e0b 100644 --- a/test/res.render.js +++ b/test/res.render.js @@ -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'); diff --git a/test/res.send.js b/test/res.send.js index 23ffd9305c..8ec74381cd 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -1,6 +1,6 @@ 'use strict' -var assert = require('assert') +var assert = require('node:assert') var express = require('..'); var methods = require('methods'); var request = require('supertest'); diff --git a/test/res.sendFile.js b/test/res.sendFile.js index ec90adf5d3..505f8d114d 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -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'); diff --git a/test/support/tmpl.js b/test/support/tmpl.js index bab65669d3..e24b6fe773 100644 --- a/test/support/tmpl.js +++ b/test/support/tmpl.js @@ -1,4 +1,4 @@ -var fs = require('fs'); +var fs = require('node:fs'); var variableRegExp = /\$([0-9a-zA-Z\.]+)/g; diff --git a/test/support/utils.js b/test/support/utils.js index c74f8efe0c..25022528ef 100644 --- a/test/support/utils.js +++ b/test/support/utils.js @@ -4,7 +4,7 @@ * @private */ -var assert = require('assert'); +var assert = require('node:assert'); /** * Module exports. diff --git a/test/utils.js b/test/utils.js index ae73988b01..d1142266ac 100644 --- a/test/utils.js +++ b/test/utils.js @@ -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(){