nomi-plugin-loader
the plugin loader tool for loading the nomi plugins!
Installation
$ npm install nomi-plugin-loader --save
Node.js >= 8.0.0 required.
API
- get
Example
First of all, we need to edit the config file of plugins.
moduleexports ="name": "redirectPlugin" // use get('pluginA') to get the instance of plugin => new PluginA(options)"package": """path": "plugins/RedirectPlugin.js""options":"a": "a""b": "b""name": "cookie" // use .get('cookie', ctx, key) to get the instance of plugin => new Cookie(ctx, key)"package": "nomi-cookie""path": """options": "nomi-cookie-key";
then, we could call the get method to get the plugin instance.
demo1
const redirectPlugin = ; //获取某一个插件A的实例redirectPlugin;
demo2
const pluginLoader = ;@async {const cookie = pluginLoader;cookie;cookie); // weiguo.kong}exportsOrderController = OrderController;