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
If you register a plugin that does not match the Fastify version, an error is thrown. It would be helpful to have a function like 'checkPluginVersion' that follows the same logic to check if the given plugin version matches the Fastify version.
Motivation
No response
Example
importfpfrom'fastify-plugin'importFastifyfrom'fastify'constplugin=fp(asyncapp=>{},{fastify: '4.x'})constapp=Fastify()if(app.checkPluginVersion(plugin)){console.log('plugin version does match')}else{console.log('plugin version does not match')}
The text was updated successfully, but these errors were encountered:
I'm kind of over the fence, it seems like a good fit for a plugin, but also do not have a strong argument for not add it to core; what use cases do you have in mind?
My use case is as follows: I have a CLI that receives a file path/several file paths to plugins from the user. This CLI then registers the given plugins in a self-created Fastify instance. Now it would be handy to be able to check whether the version of the Fastify plugins matches the Fastify version. Currently this is possible via a register, where you can see if an error is thrown. But I would prefer to have a method to easily check this without having to catch an error.
It kind of sounds pretty well for a plugin, fastify already exposes the version from the instance that be consumed by a meta-plugin that decorates app with the API you propose to validate plugins.
e.g.
constmetaPlugin=require('<the_name_of_the_plugin>');constapp=fastify().register(metaPlugin,{throw: true,/* ... other opts */});app.verifyPlugin(plugin)//throws or returns false.
Prerequisites
馃殌 Feature Proposal
If you register a plugin that does not match the Fastify version, an error is thrown. It would be helpful to have a function like 'checkPluginVersion' that follows the same logic to check if the given plugin version matches the Fastify version.
Motivation
No response
Example
The text was updated successfully, but these errors were encountered: