Foundations / Client: Servers now inside the CL object.
This commit is contained in:
1 parent
30beda6da1
commit
2f0c8ec695
5 files changed
+57
-70
No files matched your search
@@ -16,9 +16,8 @@ exports.newMultiProject = function () {
|
||||
Here we will setup the CL object, with all the
|
||||
projects and modules that will have inside.
|
||||
*/
|
||||
global.CL = {
|
||||
projects: {}
|
||||
}
|
||||
CL.projects = {}
|
||||
|
||||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
|
||||
let projectDefinition = PROJECTS_SCHEMA[i]
|
||||
global.CL.projects[projectDefinition.propertyName] = {}
|
||||
|
||||
+39
-42
@@ -54,6 +54,9 @@ global.CUSTOM_FAIL_RESPONSE = {
|
||||
message: 'Custom Message'
|
||||
}
|
||||
|
||||
/* The CL object is accesible everywhere at the Superalgos Client */
|
||||
global.CL = {}
|
||||
|
||||
/* Servers */
|
||||
let WEB_SERVER = require('./webServer.js')
|
||||
let DATA_FILE_SERVER = require('./dataFileServer.js')
|
||||
@@ -67,7 +70,7 @@ let WEB3_SERVER = require('./web3Server.js')
|
||||
let GITHUB_SERVER = require('./githubServer.js')
|
||||
|
||||
/* Network Interfaces */
|
||||
let WEB_SOCKETS_INTERFACE = require('./webSocketsServer.js')
|
||||
let WEB_SOCKETS_INTERFACE = require('./webSocketsInterface.js')
|
||||
let HTTP_INTERFACE = require('./httpInterface.js')
|
||||
|
||||
try {
|
||||
@@ -81,82 +84,76 @@ try {
|
||||
Setting up external dependencies.
|
||||
*/
|
||||
CL.nodeModules = {
|
||||
fs: require('fs'),
|
||||
fs: require('fs'),
|
||||
nodeFetch: require('node-fetch')
|
||||
}
|
||||
|
||||
/*
|
||||
Setting up servers running inside this Client.
|
||||
*/
|
||||
CL.servers = {}
|
||||
console.log('CLIENT SERVERS:')
|
||||
console.log('')
|
||||
|
||||
WEB_SERVER = WEB_SERVER.newWebServer()
|
||||
WEB_SERVER.initialize()
|
||||
WEB_SERVER.run()
|
||||
CL.servers.WEB_SERVER = WEB_SERVER.newWebServer()
|
||||
CL.servers.WEB_SERVER.initialize()
|
||||
CL.servers.WEB_SERVER.run()
|
||||
console.log('Web Server .................................................. Started')
|
||||
|
||||
UI_FILE_SERVER = UI_FILE_SERVER.newUIFileServer()
|
||||
UI_FILE_SERVER.initialize()
|
||||
UI_FILE_SERVER.run()
|
||||
CL.servers.UI_FILE_SERVER = UI_FILE_SERVER.newUIFileServer()
|
||||
CL.servers.UI_FILE_SERVER.initialize()
|
||||
CL.servers.UI_FILE_SERVER.run()
|
||||
console.log('UI File Server .............................................. Started')
|
||||
|
||||
PROJECT_FILE_SERVER = PROJECT_FILE_SERVER.newProjectFileServer()
|
||||
PROJECT_FILE_SERVER.initialize()
|
||||
PROJECT_FILE_SERVER.run()
|
||||
CL.servers.PROJECT_FILE_SERVER = PROJECT_FILE_SERVER.newProjectFileServer()
|
||||
CL.servers.PROJECT_FILE_SERVER.initialize()
|
||||
CL.servers.PROJECT_FILE_SERVER.run()
|
||||
console.log('Project File Server ......................................... Started')
|
||||
|
||||
PLUGIN_SERVER = PLUGIN_SERVER.newPluginServer()
|
||||
PLUGIN_SERVER.initialize()
|
||||
PLUGIN_SERVER.run()
|
||||
CL.servers.PLUGIN_SERVER = PLUGIN_SERVER.newPluginServer()
|
||||
CL.servers.PLUGIN_SERVER.initialize()
|
||||
CL.servers.PLUGIN_SERVER.run()
|
||||
console.log('Plugin Server ............................................... Started')
|
||||
|
||||
DATA_FILE_SERVER = DATA_FILE_SERVER.newDataFileServer()
|
||||
DATA_FILE_SERVER.initialize()
|
||||
DATA_FILE_SERVER.run()
|
||||
CL.servers.DATA_FILE_SERVER = DATA_FILE_SERVER.newDataFileServer()
|
||||
CL.servers.DATA_FILE_SERVER.initialize()
|
||||
CL.servers.DATA_FILE_SERVER.run()
|
||||
console.log('Data File Server ............................................ Started')
|
||||
|
||||
EVENT_SERVER = EVENT_SERVER.newEventServer()
|
||||
EVENT_SERVER.initialize()
|
||||
EVENT_SERVER.run()
|
||||
CL.servers.EVENT_SERVER = EVENT_SERVER.newEventServer()
|
||||
CL.servers.EVENT_SERVER.initialize()
|
||||
CL.servers.EVENT_SERVER.run()
|
||||
console.log('Events Server ............................................... Started')
|
||||
|
||||
TASK_MANAGER_SERVER = TASK_MANAGER_SERVER.newTaskManagerServer(WEB_SOCKETS_INTERFACE, EVENT_SERVER)
|
||||
TASK_MANAGER_SERVER = TASK_MANAGER_SERVER.newTaskManagerServer()
|
||||
TASK_MANAGER_SERVER.initialize()
|
||||
TASK_MANAGER_SERVER.run()
|
||||
console.log('Task Manager Server ......................................... Started')
|
||||
|
||||
CCXT_SERVER = CCXT_SERVER.newCCXTServer()
|
||||
CCXT_SERVER.initialize()
|
||||
CCXT_SERVER.run()
|
||||
CL.servers.CCXT_SERVER = CCXT_SERVER.newCCXTServer()
|
||||
CL.servers.CCXT_SERVER.initialize()
|
||||
CL.servers.CCXT_SERVER.run()
|
||||
console.log('CCXT Server ................................................. Started')
|
||||
|
||||
WEB3_SERVER = WEB3_SERVER.newWeb3Server()
|
||||
WEB3_SERVER.initialize()
|
||||
WEB3_SERVER.run()
|
||||
CL.servers.WEB3_SERVER = WEB3_SERVER.newWeb3Server()
|
||||
CL.servers.WEB3_SERVER.initialize()
|
||||
CL.servers.WEB3_SERVER.run()
|
||||
console.log('WEB3 Server ................................................. Started')
|
||||
|
||||
GITHUB_SERVER = GITHUB_SERVER.newGithubServer()
|
||||
GITHUB_SERVER.initialize()
|
||||
GITHUB_SERVER.run()
|
||||
CL.servers.GITHUB_SERVER = GITHUB_SERVER.newGithubServer()
|
||||
CL.servers.GITHUB_SERVER.initialize()
|
||||
CL.servers.GITHUB_SERVER.run()
|
||||
console.log('Github Server ............................................... Started')
|
||||
|
||||
console.log('')
|
||||
console.log('CLIENT INTERFACES:')
|
||||
console.log('')
|
||||
|
||||
WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface(EVENT_SERVER)
|
||||
WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface()
|
||||
WEB_SOCKETS_INTERFACE.initialize()
|
||||
WEB_SOCKETS_INTERFACE.run()
|
||||
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.WEB_SOCKETS_INTERFACE_PORT)
|
||||
|
||||
HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface(
|
||||
WEB_SERVER,
|
||||
DATA_FILE_SERVER,
|
||||
PROJECT_FILE_SERVER,
|
||||
UI_FILE_SERVER,
|
||||
PLUGIN_SERVER,
|
||||
CCXT_SERVER,
|
||||
WEB3_SERVER,
|
||||
GITHUB_SERVER
|
||||
)
|
||||
HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface()
|
||||
HTTP_INTERFACE.initialize()
|
||||
HTTP_INTERFACE.run()
|
||||
console.log('Http Interface .............................................. Listening at port ' + global.env.HTTP_INTERFACE_PORT)
|
||||
|
||||
+12
-21
@@ -1,13 +1,4 @@
|
||||
exports.newHttpInterface = function newHttpInterface(
|
||||
WEB_SERVER,
|
||||
DATA_FILE_SERVER,
|
||||
PROJECT_FILE_SERVER,
|
||||
UI_FILE_SERVER,
|
||||
PLUGIN_SERVER,
|
||||
CCXT_SERVER,
|
||||
WEB3_SERVER,
|
||||
GITHUB_SERVER
|
||||
) {
|
||||
exports.newHttpInterface = function newHttpInterface() {
|
||||
|
||||
/*
|
||||
IMPORTANT: If you are reviewing the code of the project please note
|
||||
@@ -111,7 +102,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
switch (params.method) {
|
||||
case 'getNetworkClientStatus': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.getNetworkClientStatus(
|
||||
let serverResponse = await CL.servers.WEB3_SERVER.getNetworkClientStatus(
|
||||
params.host,
|
||||
params.port,
|
||||
params.interface
|
||||
@@ -122,7 +113,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'createWalletAccount': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.createWalletAccount(
|
||||
let serverResponse = await CL.servers.WEB3_SERVER.createWalletAccount(
|
||||
params.entropy
|
||||
)
|
||||
|
||||
@@ -131,7 +122,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'getWalletBalances': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.getWalletBalances(
|
||||
let serverResponse = await CL.servers.WEB3_SERVER.getWalletBalances(
|
||||
params.host,
|
||||
params.port,
|
||||
params.interface,
|
||||
@@ -143,7 +134,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'signData': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.signData(
|
||||
let serverResponse = await CL.servers.WEB3_SERVER.signData(
|
||||
params.privateKey,
|
||||
params.data
|
||||
)
|
||||
@@ -153,7 +144,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'recoverAddress': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.recoverAddress(
|
||||
let serverResponse = await CL.servers.WEB3_SERVER.recoverAddress(
|
||||
params.signature
|
||||
)
|
||||
|
||||
@@ -162,7 +153,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'mnemonicToPrivateKey': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.mnemonicToPrivateKey(
|
||||
let serverResponse = await CL.servers.WEB3_SERVER.mnemonicToPrivateKey(
|
||||
params.mnemonic
|
||||
)
|
||||
|
||||
@@ -1057,7 +1048,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
switch (params.method) {
|
||||
case 'getGithubStars': {
|
||||
|
||||
let serverResponse = await GITHUB_SERVER.getGithubStars(
|
||||
let serverResponse = await CL.servers.GITHUB_SERVER.getGithubStars(
|
||||
params.repository,
|
||||
params.username,
|
||||
params.token
|
||||
@@ -1068,7 +1059,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'getGithubWatchers': {
|
||||
|
||||
let serverResponse = await GITHUB_SERVER.getGithubWatchers(
|
||||
let serverResponse = await CL.servers.GITHUB_SERVER.getGithubWatchers(
|
||||
params.repository,
|
||||
params.username,
|
||||
params.token
|
||||
@@ -1079,7 +1070,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'getGithubForks': {
|
||||
|
||||
let serverResponse = await GITHUB_SERVER.getGithubForks(
|
||||
let serverResponse = await CL.servers.GITHUB_SERVER.getGithubForks(
|
||||
params.repository,
|
||||
params.username,
|
||||
params.token
|
||||
@@ -1090,7 +1081,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'mergePullRequests': {
|
||||
|
||||
let serverResponse = await GITHUB_SERVER.mergePullRequests(
|
||||
let serverResponse = await CL.servers.GITHUB_SERVER.mergePullRequests(
|
||||
params.commitMessage,
|
||||
params.username,
|
||||
params.token
|
||||
@@ -1101,7 +1092,7 @@ exports.newHttpInterface = function newHttpInterface(
|
||||
}
|
||||
case 'payContributors': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.payContributors(
|
||||
let serverResponse = await CL.servers.WEB3_SERVER.payContributors(
|
||||
params.contractAddress,
|
||||
params.contractAbi,
|
||||
params.paymentsArray,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
exports.newTaskManagerServer = function newTaskManagerServer(WEB_SOCKETS_INTERFACE, EVENT_SERVER) {
|
||||
exports.newTaskManagerServer = function newTaskManagerServer() {
|
||||
|
||||
let thisObject = {
|
||||
initialize: initialize,
|
||||
@@ -263,7 +263,7 @@
|
||||
responseWaiters.set(command.callerId, responseCallBack)
|
||||
}
|
||||
|
||||
EVENT_SERVER.onMessage(JSON.stringify(command), thisObject.onMessage)
|
||||
CL.servers.EVENT_SERVER.onMessage(JSON.stringify(command), thisObject.onMessage)
|
||||
} catch (err) {
|
||||
console.log('[ERROR] Client -> Task Manager Server -> sendCommand -> Error Sending Command to Events Server -> command = ' + JSON.stringify(command))
|
||||
console.log('[ERROR] Client -> Task Manager Server -> sendCommand -> Error Sending Command to Events Server -> error = ' + err.stack)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
exports.newWebSocketsInterface = function newWebSocketsInterface(EVENT_SERVER) {
|
||||
exports.newWebSocketsInterface = function newWebSocketsInterface() {
|
||||
|
||||
const MODULE = "Web Sockets Interface"
|
||||
const LOG_INFO = false
|
||||
@@ -92,7 +92,7 @@
|
||||
}
|
||||
|
||||
|
||||
EVENT_SERVER.onMessage(messageToEventServer, onResponse)
|
||||
CL.servers.EVENT_SERVER.onMessage(messageToEventServer, onResponse)
|
||||
|
||||
function onResponse(message) {
|
||||
socket.send(message)
|
||||
Reference in new issue
Block a user