feat(exec): add filter option to execPreSync and execPostSync - #44
Merged
vkarpov15 merged 5 commits intoJan 29, 2026
Merged
Conversation
… options for `execPreSync` and `execPostSync`
…re it is used in pre and post hooks
AbdelrahmanHafez
force-pushed
the
feat/add-filter-option-to-exec-pre-sync
branch
from
January 15, 2026 12:29
11bc3e4 to
0f03371
Compare
AbdelrahmanHafez
marked this pull request as draft
January 15, 2026 12:33
AbdelrahmanHafez
marked this pull request as ready for review
January 15, 2026 13:11
vkarpov15
approved these changes
Jan 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds hook filtering support to the synchronous hook execution APIs and extends createWrapperSync() to better match createWrapper() behavior (context handling + forwarding options), along with restoring generated README documentation content.
Changes:
- Add
{ filter }support toexecPreSync()andexecPostSync()to selectively run hooks. - Extend
createWrapperSync()to accept an explicitcontextand agetOptions()callback to forward options into pre/post sync execution. - Restore the pre-hooks documentation block in the generated README output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
index.js |
Adds filter option to sync exec methods and extends createWrapperSync() with context + getOptions() forwarding. |
test/pre.test.js |
Adds coverage for execPreSync(..., { filter }) and null/undefined filter behavior. |
test/post.test.js |
Adds coverage for execPostSync(..., { filter }) and null/undefined filter behavior. |
test/wrap.test.js |
Adds coverage for createWrapperSync() context selection and getOptions()-driven hook filtering. |
README.md |
Reintroduces the pre-hooks documentation content in the generated README section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This PR:
filteroption toexecPreSyncandexecPostSync, they're needed to handle pre/postinitin feat: add option to skip middleware Automattic/mongoose#15883contextparameter tocreateWrapperSyncfor compatibility withcreateWrapper, mongoose usage was already assumingcontextandoptionswhich didn't exist.getOptionsoption tocreateWrapperSyncto enable users to send options through toexecPreSyncandexecPostSync.filteroption to allow executing hooks based on a filter function #43.