You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the feature has not already been requested
馃殌 Feature Proposal
Hooks called onDecorate, onDecorateRequest and onDecorateReply, which is triggered each time decorate, decorateRequest, decorateReply is called.
Motivation
Very interesting ideas could be implemented with this feature. For example:
Plugin that automatically generate a types.d.ts file that provides types for all decorators, which is useful even for js projects
Example
importFastifyfrom'fastify'constapp=Fastify()app.addHook('onDecorate',function(instance,name,fn){console.log(`Fastify instance got decorated with a property named ${name} of type ${typeoffn}`)})app.decorate('test',()=>'Test')
The text was updated successfully, but these errors were encountered:
I like the idea but have concerns about its implications, like when and how to run it.
Usually, the number of decorations is bigger than the number of hooks per app.
Every time a decoration happens, we will need to run the hooks at least once (although we do that already with onRoute, I doubt the cardinality will be the same with decorate and its variants; I imagine it will be bigger).
Prerequisites
馃殌 Feature Proposal
Hooks called
onDecorate
,onDecorateRequest
andonDecorateReply
, which is triggered each timedecorate
,decorateRequest
,decorateReply
is called.Motivation
Very interesting ideas could be implemented with this feature. For example:
types.d.ts
file that provides types for all decorators, which is useful even for js projectsExample
The text was updated successfully, but these errors were encountered: