Wiring plugins
The dream architecture of a software engineer is the one having a small, minimal core, extensible as needed through the use of plugins. Unfortunately, this is not always easy to obtain, since most of the time it has a cost in terms of time, resources, and complexity. Nonetheless, it's always desirable to support some kind of external extensibility, even if limited to just some parts of the system. In this section, we are going to plunge into this fascinating world and focus on a dualistic problem:
Exposing the services of an application to a plugin
Integrating a plugin into the flow of the parent application
Plugins as packages
Often in Node.js, the plugins of an application are installed as packages into the node_modules
directory of a project. There are two advantages for doing this. Firstly, we can leverage the power of npm
to distribute the plugin and manage its dependencies. And secondly, a package can have its own private dependency graph, which reduces the chances of having...