refactor(middleware): use metadataTarget consistently in class decorator branches#161
Merged
VikramAditya33 merged 1 commit intoMay 18, 2026
Conversation
…tor branches Closes FOSSFORGE#79. `UsePipes`, `UseGuards`, and `UseFilters` already compute `metadataTarget` for the method-decorator branch but the class-decorator branch still calls `Reflect.getMetadata`/`defineMetadata` with `target` directly. Hoist the `metadataTarget` computation to the top of the decorator body and use it in both branches. Functionally equivalent (class decorators receive the constructor as `target`), but keeps the metadata-key target consistent across method and class application sites - which matters when the same decorator might one day be used to look up a key written by the other branch.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Hoist the
metadataTargetderivation inUsePipes,UseGuards, andUseFiltersso the class-decorator branch uses the same target as the method-decorator branch.Closes #79
Why
Each of the three decorators already derives
metadataTargetfor method/parameter application:but the class-decorator branch still calls
Reflect.getMetadata/Reflect.defineMetadatawithtargetdirectly. For a class decoratortargetis the constructor itself so the two are equivalent today, but mixing the keys means a future lookup usingmetadataTargeton a class-decorated handler would not find the metadata written viatarget. Hoisting the derivation keeps the metadata key consistent across both branches.Changes
src/websocket/middleware/pipes/use-pipes.decorator.ts: class branch now reads/writes againstmetadataTarget.src/websocket/middleware/guards/use-guards.decorator.ts: hoistmetadataTargetto the top of the decorator body, use it in both branches.src/websocket/middleware/filters/use-filters.decorator.ts: same hoist.The method-decorator branches are unchanged (they already used
metadataTarget); the only semantic move is in the class branch.Verification
npm run buildclean.npx jest src/websocket/middleware/{pipes,guards,filters}/- 50/50 passing.npm run format:checkclean on the three files.npx eslintclean on the three files.