Skip to content

Add Support for Express 5 and Remove Support for Express 4 - #77

Open
Megapixel99 wants to merge 8 commits into
mainfrom
express-5
Open

Megapixel99 wants to merge 8 commits into
mainfrom
express-5

Conversation

@Megapixel99

@Megapixel99 Megapixel99 commented Aug 29, 2025 •

Copy link
Copy Markdown
Collaborator

Despite the initial hope of this being a small pull request, there were a lot of required changes to improve the readability of the code and support Express 5. I tried to comment the code as best I could but if something looks off, please add a comment in the PR.

Breaking Changes:

  • Removed support for Express 4
    • We can continue supporting Express 4 on a different branch, if desired

Major Changes:

  • Revamped tests for regex routes to align with Express 5's regex requirements
  • Added a couple more tests to ensure sub routes (routes within routes) worked properly
  • Rewrote lib/generate-doc.js
  • Updated the versions of NodeJS which the tests are running against
  • Removed tests for Express 4
  • Updated express to the latest version
    • Made express a peer dependency
  • Updated router to feat: add listRoutes method to list registered routes pillarjs/router#174 (so we can access getRoutes())

Minor Changes:

@Megapixel99
Megapixel99 requested a review from enov August 29, 2025 18:29
@Megapixel99

Copy link
Copy Markdown
Collaborator Author

This PR is dependent on getRoutes() and should not be merged until getRoutes() is officially released.

@Megapixel99
Megapixel99 force-pushed the express-5 branch 4 times, most recently from 3759e8c to ef0a065 Compare September 2, 2025 17:34
Replace the getRoutes() call from the bjohansebas/router fork with the
listRoutes() API merged in pillarjs/router#174, and depend on the released
router ^2.2.0. When the installed router has no listRoutes(), record mount
paths on use() layers so nested routers keep their prefixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Megapixel99

Copy link
Copy Markdown
Collaborator Author

This PR now uses the listRoutes() method that was merged into pillarjs/router in pillarjs/router#174, replacing the getRoutes() method from the earlier fork, and depends on the released router ^2.2.0 instead of a git branch. Until a router release includes listRoutes(), the library falls back to recording mount paths when routers are mounted with use(), so nested routers keep their prefixes on router 2.2.0. Once a release ships, Express 5 installs will use the official API automatically with no further changes. Route handlers are still read from each route’s stack, because listRoutes() exposes paths, methods and mounted routers but not handlers. All 38 tests pass against both router 2.2.0 and the current router main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant