Im implementing a node application that have app.js and server.js (using express) . To run my application you should run the server.js which start to listen to http calls. so far so good :).
There is a new requirements like following:
-
Register new module to the application during design time like adding new module to it
-
in Runtime find which modules are register and do my logic on them(the logic is not the point here)
I think its like command design pattern that external module can register to your module and you don't know about them until the need to run
How I can do it in node.js? There is a npm module which allow module registration which I can use as reference ?
I'm not talking about adding a module as node dependency(on package.json), I'm referring that developer will add/register his module to my module by code and in runtime I will know that userModule was register and do additional logic.
require my module myModule.register('userModule');
or register with path to the userModule
myModule.register('/path to user module');
Aucun commentaire:
Enregistrer un commentaire