Repository navigation
fix: enforce route access rules consistently and add CI and npm releases - #8
Merged
Merged
Conversation
Access control - apply roles and validation to method exports regardless of case - pass a real error to next when a handler throws a falsy value, 'route' or 'router' - reject roles that are not an array of role names, roles without a handler, non-boolean guestAccess/ensureAdmin, and guestAccess combined with ensureAdmin - do not return error messages and stack traces from defaultErrorHandler in production Routing - mount static routes before param routes for every segment - fix route paths for files that start with index, and the extension match - ignore declaration files, resolve relative routesPath, and do not treat the path to the routes as a glob pattern Packaging and CI - refresh the lockfile to clear known advisories, move to TypeScript 5.9 - publish only the library build, set the license to Apache-2.0 - add CI, CodeQL, dependency review, PR title check and dependabot - add release-please, publishing to npm with trusted publishing
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes several access-control and routing bugs found in an audit, clears the dependency advisories, and adds CI plus a release-please pipeline that publishes to npm.
Bug fixes
Access control
export const postwas mounted, butroles = { POST: [...] }andvalidationwere matched case-sensitively and not applied. They now apply regardless of case.throw undefined,Promise.reject()) callednext(undefined), which Express treats as success, so the request continued to the next handler. A thrown'route'/'router'had the same effect. These are now passed on as real errors.roles: { GET: 'org:admin' }(a string instead of an array) was matched by substring. This now throws at startup.guestAccesstogether withensureAdminsilently dropped the admin check. This now throws at startup, as do non-boolean values for either export.defaultErrorHandlerreturned the error message and stack trace in production. It now only does so whenNODE_ENVis notproduction.Routing
-(/users/:idwas mounted before/users/2fa). Static segments now always sort ahead of param segments./indexes.tswas mounted as/es, and the extension regex had a precedence bug..d.tsfiles were picked up as routes.routesPathwas resolved against the library's own folder, and glob characters in the path were treated as a pattern.logMounts, non-function exports now give a clear startup error, and the error handlers checkheadersSent.Behavior change to be aware of
The startup checks are stricter. A consumer with one of the misconfigurations above will now fail to boot with a descriptive error instead of running with the rule silently not applied.
Dependencies and packaging
pnpm auditis clean);ajvmoves to 8.20.@types/nodeno longer parses under 4.9.licenseis nowApache-2.0to matchLICENSE;versionis set to 0.2.2 to match the last published version.CI and release
ci.yml: typecheck, test, build and pack check on Node 22/24/26, plus dependency review on pull requests.release.yml: release-please onmaster, thennpm publishthrough OIDC trusted publishing in annpmenvironment. No npm token, no dependency cache in the publish job.pr-title.yml,codeql.yml,dependabot.yml.persist-credentials: false, and installs use--ignore-scripts.After merging
chore: release 0.2.3pull request.npm publishfrom the release tag, followed by:npm trust github @parallelworks/fsrouter --repo parallelworks/fsrouter --file release.yml --env npmTesting
actionlintpasses. The workflows run for the first time on this pull request.