-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: explicit hook configuration via addHook
#212
Merged
Merged
Conversation
This file contains 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
hook
optionaddHook
2d0bde0
to
df801c0
Compare
climba03003
reviewed
Feb 5, 2025
Co-authored-by: KaKa <23028015+climba03003@users.noreply.github.com> Signed-off-by: Frazer Smith <frazer.dev@icloud.com>
Co-authored-by: KaKa <23028015+climba03003@users.noreply.github.com> Signed-off-by: Frazer Smith <frazer.dev@icloud.com>
climba03003
approved these changes
Feb 5, 2025
climba03003
reviewed
Feb 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
Readme.md:83
- The
addHook
option description is duplicated. Please remove the redundant description.
* `addHook`: If `false`, this plugin will not register any hook automatically. Instead, it provides two decorations: `fastify.verifyBearerAuth` and `fastify.verifyBearerAuthFactory`. If `true` or nullish, it will default to `onRequest`. You can also specify `onRequest` or `preParsing` to register the respective hook
lib/errors.js:6
- The error message for FST_BEARER_AUTH_INVALID_HOOK is clear and helpful.
const FST_BEARER_AUTH_INVALID_HOOK = createError('FST_BEARER_AUTH_INVALID_HOOK', 'options.addHook must be either "onRequest" or "preParsing"')
climba03003
approved these changes
Feb 6, 2025
jsumners
reviewed
Feb 6, 2025
jsumners
approved these changes
Feb 9, 2025
gurgunday
approved these changes
Feb 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
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.
Supersedes #207.
This PR updates the
addHook
option to allow the hook type to be explicitly configured to be eitheronRequest
orpreParsing
.The hooks are limited to these two values so that developers cannot open themselves up to DoS attacks.
If the option is nullish or true it defaults to
onRequest
, which is its original functionality.Checklist
npm run test
andnpm run benchmark
and the Code of conduct