Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Improve middleware route exclusion for dynamic endpoints #14194

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sapenlei
Copy link
Contributor

fixes #13593

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #13593

What is the new behavior?

The middleware route exclusion now correctly handles the coexistence of static and dynamic routes:

  • Static routes (e.g., /all) are not affected by dynamic route exclusions
  • Dynamic routes (e.g., /:id) can be excluded without impacting other routes
  • Middleware correctly runs for non-excluded routes while skipping excluded ones

For example, when excluding /:id route:

  • Middleware runs for /all endpoint
  • Middleware skips /:id endpoint

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Nov 24, 2024

Pull Request Test Coverage Report for Build b72c5f50-710a-40ab-86ee-2547082376eb

Details

  • 13 of 13 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.009%) to 91.998%

Totals Coverage Status
Change from base Build 24988914-aaa6-4b6c-ba68-8172e56cd7a9: 0.009%
Covered Lines: 6818
Relevant Lines: 7411

💛 - Coveralls

@kamilmysliwiec
Copy link
Member

Could you also add an integration test?

@sapenlei
Copy link
Contributor Author

Could you also add an integration test?

Yes, I can

@sapenlei sapenlei changed the title fix(core): Improve middleware route exclusion for dynamic endpoints test(core): Improve middleware route exclusion for dynamic endpoints Nov 29, 2024
@sapenlei sapenlei changed the title test(core): Improve middleware route exclusion for dynamic endpoints fix(core): Improve middleware route exclusion for dynamic endpoints Nov 29, 2024
@sapenlei
Copy link
Contributor Author

Integration tests have been completed @kamilmysliwiec

@sapenlei
Copy link
Contributor Author

@kamilmysliwiec Can this be merged? 😭

@kamilmysliwiec
Copy link
Member

We need to be very careful when making any changes to the middleware exclusion algorithm as they will certainly affect many users of the framework. Might need to wait with this change till the next major release

@sapenlei
Copy link
Contributor Author

We need to be very careful when making any changes to the middleware exclusion algorithm as they will certainly affect many users of the framework. Might need to wait with this change till the next major release

ok, I understand.

Copy link

@Vue-Pu Vue-Pu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge nestjs:master into sapenlei:fix/Express-Middleware-not-being-called-for-some-endpoints. All checks passed

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.

Express Middleware not being called for some endpoints
4 participants