ModularKit is a plugin-based system framework designed for Node.js web applications. It allows developers to build and manage application features in a modular way, providing flexible plugin loading, route management, event handling, and database interaction.
- Plugin-based Architecture: Easily add, remove, and update functional modules of the application.
- Route Management: Plugins can independently register and manage their own routes.
- Event-driven: Supports the publication and subscription of events, facilitating communication and collaboration between plugins.
- Database Integration: Provides encapsulated database operations, supporting data isolation and secure data access.
- Flexibility and Extensibility: Simple API and flexible design suitable for various application needs.
Install ModularKit using npm:
npm install modularkit
Here's a basic example of how to use ModularKit in your Node.js application.
First, create a plugin:
// plugins/YourPlugin.js
class YourPlugin {
constructor(modularkit) {
this.routeManager = modularkit.routeManager;
// ...other managers
}
initialize() {
// Plugin initialization code
}
}
module.exports = YourPlugin;
Then, load and initialize the plugin in your application:
const Koa = require('koa');
const { PluginLoader } = require('modularkit');
const path = require('path');
const app = new Koa();
const pluginLoader = new PluginLoader(path.join(__dirname, 'plugins'));
pluginLoader.loadPlugins();
app.use(pluginLoader.routeManager.routeMiddleware());
app.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});
For more detailed documentation and API reference, please check Documentation Link.
MIT © shitiandmw