Breaking the encapsulation
In this new recipe, we’ll delve deeper into the world of the Fastify plugin system, expanding our understanding beyond what we’ve explored so far. Fastify offers a wide array of tools, each serving specific purposes, and gaining familiarity with them will greatly enhance your ability to customize and control various aspects of your application’s lifecycle and behavior.
Getting ready
In the previous Implementing authentication with hooks recipe, we learned about various hooks, but we didn’t see their practical application. Now, let’s apply our knowledge by developing a custom authentication plugin. Currently, our authentication logic is dispersed across the app.js
file, which is then utilized by both orders.js
and recipes.js
. While it works, it lacks centralization. To address this, we aim to create a company-wide plugin that can be easily integrated into all our projects, providing standardized authentication logic...