pf4n
Motivation
There is a plugin framework in the Java ecosystem: pf4j (Plugin Framework For Java), but it seems that the ecosystem here in node.js is somewhat lacking. This is an important pass. If there is a plug-in design, the server can become more lightweight and detachable, greatly reducing the minimum implementation. Service size.
Therefore, pf4n came out.
Installation
npm install pf4n
Ecosystem
The ecosystem is still in the early stages of development, and the following plug-ins are currently still not available.
- @pf4n/core: The core of pf4n, which provides the basic framework for the plug-in system.
- @pf4n/fastify-plugin: A plug-in that provides a fastify server for pf4n.
- @pf4n/express-plugin: A plug-in that provides an express server for pf4n.
Components
- Plugin is the base class for all plugins. All plugins must inherit from this class.
- PluginManager is the manager of all plugins. It is responsible for loading, unloading, enabling, disabling, and other operations of all plugins.
-
PluginLoader is responsible for loading plugins. The default is to load plugins from the
plugins
directory under the current working directory. - ExtensionPoint is the extension point of the plugin. The plugin can extend the extension point to provide more functions.
- Extension is the implementation of the extension point. The plugin can implement the extension point to provide more functions.
PLUGIN == Container of ExtensionPoint + Extension + Lifecycle