diff --git a/Client/client.js b/Client/client.js index 74fdb60c2..5adf10a82 100644 --- a/Client/client.js +++ b/Client/client.js @@ -97,7 +97,10 @@ try { */ SA.nodeModules = { fs: require('fs'), - nodeFetch: require('node-fetch') + nodeFetch: require('node-fetch'), + open: require('open'), + http: require('http'), + ccxt: require('ccxt') } /* Setting up servers running inside this Client. diff --git a/Client/httpInterface.js b/Client/httpInterface.js index e2a02ca4e..89b98454e 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -13,9 +13,6 @@ exports.newHttpInterface = function newHttpInterface() { run: run } - const OPEN_NODE_MODULE = require('open') - const HTTP_NODE_MODULE = require('http') - let webhook = new Map() return thisObject @@ -32,12 +29,12 @@ exports.newHttpInterface = function newHttpInterface() { /* We will create an HTTP Server and leave it running forever. */ - HTTP_NODE_MODULE.createServer(onHttpRequest).listen(global.env.CLIENT_HTTP_INTERFACE_PORT) + SA.nodeModules.http.createServer(onHttpRequest).listen(global.env.CLIENT_HTTP_INTERFACE_PORT) /* Starting the browser now is optional */ if (process.argv.includes("noBrowser")) { //Running Client only with no UI. } else { - OPEN_NODE_MODULE('http://localhost:' + global.env.CLIENT_HTTP_INTERFACE_PORT) + SA.nodeModules.open('http://localhost:' + global.env.CLIENT_HTTP_INTERFACE_PORT) } } @@ -144,12 +141,10 @@ exports.newHttpInterface = function newHttpInterface() { try { let params = JSON.parse(body) - const ccxt = require('ccxt') - switch (params.method) { case 'fetchMarkets': { - const exchangeClass = ccxt[params.exchangeId] + const exchangeClass = SA.nodeModules.ccxt[params.exchangeId] const exchangeConstructorParams = { 'timeout': 30000, 'enableRateLimit': true, @@ -167,10 +162,10 @@ exports.newHttpInterface = function newHttpInterface() { } case 'listExchanges': { let exchanges = [] - for (let i = 0; i < ccxt.exchanges.length; i++) { - let exchangeId = ccxt.exchanges[i] + for (let i = 0; i < SA.nodeModules.ccxt.exchanges.length; i++) { + let exchangeId = SA.nodeModules.ccxt.exchanges[i] - const exchangeClass = ccxt[exchangeId] + const exchangeClass = SA.nodeModules.ccxt[exchangeId] const exchangeConstructorParams = { 'timeout': 30000, 'enableRateLimit': true,