feat: filter hooks per call in createWrapper via getOptions - #46
Merged
vkarpov15 merged 5 commits intoAug 19, 2026
Merged
Conversation
Mirror createWrapperSync's getOptions support on the async path. wrap() now derives pre/post options from options.getOptions(args) and passes the resulting filters to execPre/execPost (including the error-handler path), so createWrapper-based hooks (custom statics and methods in Mongoose) can be selectively skipped per call. Backwards compatible: without getOptions, all hooks run as before.
- Correct execPre/execPost/execPreSync/execPostSync to their async/options signatures (callbacks were dropped, filter option added) - Add getOptions to createWrapper/createWrapperSync option types - Fix stale overwriteMiddlewareResult -> overwriteResult, add postError - Expose types via package.json "types" field
This was referenced Jun 29, 2026
AbdelrahmanHafez
marked this pull request as ready for review
June 30, 2026 00:13
vkarpov15
approved these changes
Jun 30, 2026
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.
re #43 and #44
Adds
getOptionssupport tocreateWrapper()/wrap(), mirroring #44 forcreateWrapperSync().wrap()reads per-call options fromoptions.getOptions(args)and passes thefiltertoexecPre/execPost(including the error path), socreateWrapper-based hooks (Mongoose statics and methods) can skip user middleware for a single call. WithoutgetOptions, nothing changes.Also fixes
index.d.ts, which had drifted from the runtime: corrected theexecPre/execPost/*Syncsignatures, addedgetOptionsandpostError, renamedoverwriteMiddlewareResult->overwriteResultto match the real export, and wired up the missingtypesfield.Heads up: the
overwriteResultrename is a type-level change for anything referencingKareem.OverwriteMiddlewareResult(Mongoose'stypes/does). I have the matching Mongoose change ready.Also documented
getOptions.