feat(middleware): auto-resolve transitive dependencies#396
Merged
Conversation
When a middleware declares dependencies via getDependencies(), assigning only that middleware to a route now auto-includes all transitive dependencies from MiddlewareRegistry via BFS traversal. - resolveDependencies() walks the dependency graph before sorting - Missing dependencies are silently skipped - No duplicates when dependency is already assigned - Execution order preserved via existing topological sort Closes #380
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #396 +/- ##
============================================
+ Coverage 83.67% 83.75% +0.07%
- Complexity 3067 3083 +16
============================================
Files 103 104 +1
Lines 9018 9061 +43
============================================
+ Hits 7546 7589 +43
Misses 1472 1472
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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
Auto-resolve transitive middleware dependencies from the registry when assigned to a route.
Motivation
Previously,
getDependencies()only affected sort order for middleware already assigned. If a dependency was not explicitly listed on the route, it was silently skipped. Now assigning middleware E (which depends on D→C→B→A) auto-includes the entire chain.Changes
resolveDependencies()inRouterUri— BFS traversal of dependency graphsortByDependencies()ingetMiddleware()How to Test / Verify
6 unit tests covering all branches:
Breaking Changes and Migration Steps
None. Existing routes with all middleware explicitly assigned behave identically. Routes that relied on dependencies being silently skipped will now have those dependencies execute — this is the correct behavior per ADR-0002.
Checklist
Related issues
Closes #380