From 8b261cbc0476fce33f3dc940401142790aab1645 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 13 Mar 2018 06:23:12 -0400 Subject: [PATCH] add api registration to plugin --- lib/core/plugin.js | 6 ++++++ lib/core/plugins.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/core/plugin.js b/lib/core/plugin.js index 5e9b84256..f762f3ae3 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -23,6 +23,7 @@ var Plugin = function(options) { this.dappGenerators = []; this.pluginTypes = []; this.uploadCmds = []; + this.apiCalls = []; this.imports = []; this.embarkjs_code = []; this.embarkjs_init_code = {}; @@ -223,6 +224,11 @@ Plugin.prototype.registerActionForEvent = function(eventName, cb) { this.addPluginType('eventActions'); }; +Plugin.prototype.registerAPICall = function(method, endpoint, cb) { + this.apiCalls.push({method: method, endpoint: endpoint, cb: cb}); + this.pluginTypes.push('apiCalls'); +}; + Plugin.prototype.runFilePipeline = function() { var self = this; diff --git a/lib/core/plugins.js b/lib/core/plugins.js index 0aa5accef..6220c1230 100644 --- a/lib/core/plugins.js +++ b/lib/core/plugins.js @@ -45,6 +45,7 @@ Plugins.prototype.createPlugin = function(pluginName, pluginConfig) { interceptLogs: this.interceptLogs, events: this.events, config: this.config, + //plugins: this, isInternal: true, context: this.context }); @@ -65,6 +66,7 @@ Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig) { interceptLogs: this.interceptLogs, events: this.events, config: this.config, + //plugins: this.plugins, isInternal: true, context: this.context, env: this.env