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 issue has not already been raised
Issue
Thanks for the extensive Plugin Guide in your documentation.
I'm new to the Fastify ecosystem so please correct wrong assumptions. Imho a typical usecase for plugins is to extend preHandler logics for routes. You briefly touch this topic in your docs to register a hook just for a "subset of routes", but this only seems to fit for the routes that are introduced by the plugin itself (and the route logic belonging to my app should be at another place in the code structure). The way more powerful approach is combining plugins with the onRoute hook to attach logic when an application route is registered (for example like this plugin code https://github.com/Eomm/fastify-raw-body/blob/master/plugin.js#L29.
My questions:
are my assumptions correct and do you think extending the guide would be useful?
can you share your opinion about the best practise how to limit the plugin to only apply to certain routes
via a path filter in the plugin options?
via config property when defining a route?
...?
The text was updated successfully, but these errors were encountered:
are my assumptions correct and do you think extending the guide would be useful?
I think extending the guide to cover onRoute will be appreciated by everybody. It's a very powerful technique that we added after the guide was written.
can you share your opinion about the best practise how to limit the plugin to only apply to certain routes
via a path filter in the plugin options?
Unfortunately this will really be bad for performance because you'd need to match all incoming request and see if a hook applies.
via config property when defining a route?
This is the approach I recommend and it's used throughout the plugins in this organization.
Prerequisites
Issue
Thanks for the extensive Plugin Guide in your documentation.
I'm new to the Fastify ecosystem so please correct wrong assumptions. Imho a typical usecase for plugins is to extend
preHandler
logics for routes. You briefly touch this topic in your docs to register a hook just for a "subset of routes", but this only seems to fit for the routes that are introduced by the plugin itself (and the route logic belonging to my app should be at another place in the code structure). The way more powerful approach is combining plugins with theonRoute
hook to attach logic when an application route is registered (for example like this plugin code https://github.com/Eomm/fastify-raw-body/blob/master/plugin.js#L29.My questions:
The text was updated successfully, but these errors were encountered: