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
Have the opportunity of visualize the plugins of a fastify application in a form of a graph to understand relationships and dependencies between plugins.
Is there any way to specify which onClose (or preClose) hooks from each plugin should be executed before the others? I have some plugins that rely on other main plugins in order to execute correctly their onClose hooks.
E.G.: Some plugins need the database plugin in order to perform some cleaning operations on the database before closing the server. If the database plugin gets torn down before the plugin, the database client results disconnected.
constfastify=require('fastify');constdbPlugin=require('./my-db-plugin');constotherPlugin=require('./my-other-plugin');// my-db-plugin.jsasyncfunctionplugin(instance,opts){fastify.decorate('database',mydbdriver);fastify.addHook('onClose',async(app)=>{console.log('second');// Let's say that my-other-plugin requires// the database plugin to execute some cleanup work, whatever this could beawaitapp.database.close();});}module.exports=fp(plugin,{name: ['database']});// my-other-plugin.jsasyncfunctionplugin(instance,opts){fastify.addHook('onClose',async(app)=>{console.log('first');// Let's say that my-other-plugin requires// the database plugin to execute some cleanup work, whatever this could beawaitapp.database.cleanup();});}module.exports=fp(plugin,{name: 'other',dependencies: ['database']});// index.js// ... all the bootup processawaitfastify.ready();console.log(fastify.overview());/** Just an illustrative example{ "plugins": { "my-other-plugin": { "depends": { "my-db-plugin": { "depends": {} } } } }}*/
The text was updated successfully, but these errors were encountered:
Prerequisites
🚀 Feature Proposal
Have the opportunity of visualize the plugins of a
fastify
application in a form of a graph to understand relationships and dependencies between plugins.Motivation
From: fastify/help#1018
Transferred from: fastify/fastify#5375
Example
The text was updated successfully, but these errors were encountered: