Skip to content

Conversation

@Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 22, 2024

@Eomm

is this the naming you suggest in your book?

Copy link
Member

@Eomm Eomm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I suggest to use named function because it improves the stack trace and debug tools (such as fastify-overview)

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 22, 2024

i mean more like, what is the naming convention?

i used caching as prefix fo the hook handlers and a name describing the functionality-

}

instance.addHook('onRequest', (req, res, next) => {
instance.addHook('onRequest', function cachingSetCacheControlHeader (req, res, next) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really the only change needed in this PR. The other names are fine; the fact that they are named is enough. And we don't need names in the tests. The names provide information when reviewing stack traces, stepping through with a debugger, and reviewing observability data.

@Uzlopak Uzlopak merged commit 742aec4 into master Sep 25, 2024
13 checks passed
@Uzlopak Uzlopak deleted the chore-named-hook-fn branch September 25, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants