fastify-plugin
is a plugin helper for Fastify.
When you build plugins for Fastify and you want that them to be accessible in the same contewxt where you require them, you have two ways:
- Use the
skip-override
hidden property - Use this module
fastify-plugin
can do two things for you:
- Add the
skip-override
hidden property - Check the bare-minimum version of Fastify
Example:
const fp = require('fastify-plugin')
module.exports = fp(function (fastify, opts, next) {
// your plugin code
next()
})
If you need to set a bare-minimum version of Fastify for your plugin, just add the semver range that you need:
const fp = require('fastify-plugin')
module.exports = fp(function (fastify, opts, next) {
// your plugin code
next()
}, '0.x')
You can check here how to define a semver
range.
This project is kindly sponsored by:
Licensed under MIT.