snaphy / snaphyBackend

Snaphy Backend Template for all cloud tech
3 stars 0 forks source link

At plugin/backend insert a global method through which plugin will expose its method to extend the plugin behavior. #1

Closed robinskumar73 closed 8 years ago

robinskumar73 commented 8 years ago

Insert a global object inside plugin which other plugin can use to extend its functionality. like

module.exports = function( server, databaseObj, helper, packageObj, plugins) {
     //Suppose this plugin uses login plugin functionality..
     plugins.login.addUserToAdmin()

}
robinskumar73 commented 8 years ago

Or we should export the methods which we wants to use in the plugins and and then we can use it by exporting the methods.

robinskumar73 commented 8 years ago

Also every plugins must have a onInit method in which the function which should run which should initialize the plugins.

robinskumar73 commented 8 years ago

You cannot use node default method to export methods as. it has a database attachment to method that can only be initialize at run time.

robinskumar73 commented 8 years ago

One options is to create a static method in the helper function. var plugin-load = loadPlugin('plugin-name') which will load the required plugins.