55 Commits
Author SHA1 Message Date
Szymon ŁągiewkaandWes Todd 4199d3218f 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
2025-01-10 11:53:44 -06:00
Jon KoopsandGitHub 713c2a6709 chore: replace methods dependency with standard library (#6196) 2025-01-02 08:00:30 +01:00
Wes Todd 408d869385 Merge tag '4.19.0' into 5.x
4.19.0
2024-03-20 21:14:00 -05:00
christof louwandDouglas Christopher Wilson 2a89eb5c74 tests: fix handling multiple callbacks
closes #5233
2024-02-19 08:20:39 -05:00
Douglas Christopher Wilson 74beeac071 Fix routing requests without method 2023-02-23 17:23:22 -05:00
Rakesh BishtandDouglas Christopher Wilson c6ee8d6e7f lint: remove unused function arguments in tests
closes #5124
2023-02-20 22:57:13 -05:00
Douglas Christopher Wilson 97f0a518d8 tests: verify all handlers called in stack tests 2022-05-20 11:54:35 -04:00
Douglas Christopher Wilson 631ada0c64 Fix hanging on large stack of sync routes
fixes #4899
2022-04-29 13:34:47 -04:00
phoenixandDouglas Christopher Wilson fd8e45c344 tests: mark stack overflow as long running
closes #4887
2022-04-20 19:52:20 -04:00
Douglas Christopher Wilson 708ac4cdf5 Fix handling very large stacks of sync middleware
closes #4891
2022-04-13 23:29:25 -04:00
Douglas Christopher Wilson 318fd4b543 Merge tag '4.17.3' 2022-02-17 00:27:11 -05:00
Douglas Christopher Wilson a65913776d tests: use strict mode 2022-02-09 01:07:08 -05:00
Douglas Christopher Wilson 1574925cad deps: [email protected]
closes #4321
2021-12-16 23:05:41 -05:00
Douglas Christopher Wilson c7d528cdc0 Merge tag '4.17.2' 2021-12-16 23:01:28 -05:00
Douglas Christopher Wilson 8e4add7f74 tests: remove should usage from Router tests
fixes #4635
2021-07-30 16:19:55 -04:00
Douglas Christopher Wilson 302a6152b4 Merge tag '4.16.4' 2018-10-23 20:38:42 -04:00
Alejandro EstradaandDouglas Christopher Wilson 40e04ec7a6 lint: remove usages of "=="
closes #3540
2018-02-13 19:30:57 -05:00
Douglas Christopher Wilson 972ada9079 tests: remove duplicate block in router test 2018-02-13 17:14:48 -05:00
Douglas Christopher Wilson 62e12fe710 Merge tag '4.16.2' 2017-10-13 22:27:30 -04:00
Hrvoje ŠimićandDouglas Christopher Wilson 2df1ad26a5 Improve error messages when non-function provided as middleware
closes #3426
2017-09-28 09:20:37 -04:00
Douglas Christopher Wilson c319fe260a Merge tag '4.15.4' 2017-08-07 19:33:00 -04:00
Daniel WalasekandDouglas Christopher Wilson 713d2aed93 tests: fix incorrect should usage
closes #3387
2017-08-05 20:10:35 -04:00
Douglas Christopher Wilson 501e24e0a9 Merge tag '4.15.0' 2017-03-01 18:17:04 -05:00
Douglas Christopher Wilson 51f52901eb Fix case where router.use skipped requests routes did not
fixes #3037
2017-02-26 13:59:47 -05:00
Douglas Christopher Wilson 668f545fd4 Skip routing when req.url is not set 2017-02-22 23:42:57 -05:00
Douglas Christopher Wilson cec5780db4 Use router module for routing
closes #2411
2015-07-06 23:46:00 -04:00
Douglas Christopher Wilson 1e2951a832 Remove app.param(fn) signature 2015-07-06 16:45:09 -04:00
Douglas Christopher Wilson ec8daf0e7b Match routes iteratively to prevent stack overflows
fixes #2412
2015-01-13 15:33:54 -05:00
Aria StewartandDouglas Christopher Wilson eabd4564aa Fix handling of URLs containing :// in the path
fixes #2421
2014-10-29 00:33:02 -04:00
Douglas Christopher Wilson 68290ee87a Fix handling of invalid empty URLs
fixes #2399
2014-10-23 21:33:38 -04:00
Douglas Christopher Wilson 728917164c Fix router.use to accept array of middleware without path 2014-09-17 19:18:13 -07:00
Douglas Christopher Wilson bf1980f1b4 Improve error message for bad app.use arguments 2014-09-17 19:18:10 -07:00
Douglas Christopher Wilson 1ca01c0c47 tests: add router.use validation tests
closes #2299
2014-08-15 00:22:54 -04:00
Douglas Christopher Wilson 968b00c3d7 tests: add missing FQDN router URL tests 2014-07-08 19:40:22 -04:00
Douglas Christopher Wilson 4d3e0d88a2 Fix catching errors from top-level handlers 2014-06-09 09:44:37 -04:00
Douglas Christopher Wilson 21393c244c tests: add more route tests 2014-06-06 11:12:52 -04:00
Douglas Christopher Wilson 23ff74bb3f tests: flow control with after 2014-05-18 16:33:11 -04:00
Douglas Christopher Wilson 98d17e2293 invoke router.param() only when necessary
fixes #2121
2014-05-18 16:21:01 -04:00
Douglas Christopher Wilson ababa6ae5b fix issue routing requests among sub routers
fixes #2121
2014-05-18 15:27:28 -04:00
Roman Shtylman cb1fbce46b don't call done twice for thrown errors inside parameterized routes
fixes #1995
2014-03-23 14:42:46 -04:00
Blake Embrey efbe1779e3 Override params every layer. 2014-03-17 15:16:26 -03:00
Blake Embrey c7e84d8044 Clean up code and syntax issues. 2014-03-10 13:19:03 -04:00
Blake Embrey 51e80ffd48 Add tests for dynamic mounting. 2014-03-10 13:16:39 -04:00
Roman Shtylman f8b954bcd9 make express.Router() return a Router function instance
Similar to how express() returns an express `app` instance which is also
a function, express.Router() returns the Router instance which is also a
function and can be easily used via another router or the app.

app.use(express.Router());
2014-02-26 20:22:11 -05:00
Roman Shtylman 6911815171 Router: add parameter handling to middleware
Middleware (.use) can now specify parameter arguments to trigger
Router.param loading. This is handy if you want to `.use` additional
routers but need to load certain objects before the mounted middleware
runs.
2014-02-23 19:21:13 -05:00
Roman Shtylman f41d09a3cf remove app.router and refactor middleware processing
This is an overhaul of middleware processing, Router and Route. Connect is no
longer used to process the middleware stack. This functionality has been
split into two parts: middleware stack and default error response.

The entry point for request processing is the `app.handle` method. It
sets up the default error response handle (to run in the event of no
other error handler) and then triggers the app router (instance of
Router) to handle the request.

The app router `handle` function contains the middleware dispatch layer
previously in the connect codebase. This layer handle the logic for
dispatching `.use` calls (stripping paths if needed). The app contains a
base router `app._router`. New routes can be created and `.use`d on this
router to organize routes into files.

Routers now have the following methods `.use`, `.all`, `.param` which
are all public.

Additionally, Routers have a `.route(path)` method which returns a new
instance of Route for the requested path. Route(s) are isolated
middleware stacks and contain methods for the HTTP verbs as well as an
`.all` method to act similar to middleware. These methods are chainable
to easily describe requirements for a route.

  var route = Router.route('/foo'); // or 'app.route('/foo')'

  route
  .all(auth)
  .get(function(...) {})
  .all(more_checks)
  .post(function(...) {})

Any Route and Router methods which accept handlers also accept error
(arity 4) handlers which will also behave as expected.

Finally, the `app.router` getter has been removed. Middleware and
handlers are run IN THE ORDER they are seen in the file. This means that
code which injected the `app.router` and then added error handlers (or
other middleware) will need to be updated to move those handlers after
any requests added on the app object. The examples have been updated
accordingly. This is the largest breaking change to codebases in this
commit.
2014-02-03 15:59:52 -05:00
Roman Shtylman f47c0d9774 add Router.all() method
Similar to app.all() but specifically for attaching handlers to all
methods under a standalone router. This is useful for isolating routers
that require "middleware" like features for all routes managed by the
router.
2013-11-19 18:52:04 -05:00
Thorsten LorenzandTJ Holowaychuk ce7d7bfd8d add throwing when a non-function is passed to a route 2012-12-14 15:06:17 -08:00
TJ Holowaychuk b9e32ec2c4 styling 2012-07-06 08:15:28 -07:00
TJ Holowaychuk 32b8613708 fix matchRequest tests 2012-07-06 08:14:53 -07:00