Multi-Project module reused between Client and Task Server
This commit is contained in:
1 parent
6504f47b6f
commit
71514d580e
8 files changed
+80
-137
No files matched your search
@@ -1,69 +0,0 @@
|
||||
exports.newMultiProject = function () {
|
||||
|
||||
let thisObject = {
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(rootObject, rootObjectName) {
|
||||
/*
|
||||
First thing is to load the project schema file.
|
||||
*/
|
||||
let PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECTS_REQUIRED + '/' + 'ProjectsSchema.json')
|
||||
|
||||
/*
|
||||
Here we will setup the CL object, with all the
|
||||
projects and modules that will have inside.
|
||||
*/
|
||||
rootObject.projects = {}
|
||||
|
||||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
|
||||
let projectDefinition = PROJECTS_SCHEMA[i]
|
||||
global[rootObjectName].projects[projectDefinition.propertyName] = {}
|
||||
let projectInstance = global[rootObjectName].projects[projectDefinition.propertyName]
|
||||
|
||||
projectInstance.utilities = {}
|
||||
projectInstance.globals = {}
|
||||
projectInstance.functionLibraries = {}
|
||||
|
||||
if (projectDefinition[rootObjectName] === undefined) { continue }
|
||||
|
||||
/* Set up Utilities of this Project */
|
||||
if (projectDefinition[rootObjectName].utilities !== undefined) {
|
||||
for (let j = 0; j < projectDefinition[rootObjectName].utilities.length; j++) {
|
||||
let utilityDefinition = projectDefinition[rootObjectName].utilities[j]
|
||||
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Utilities' + '/' + utilityDefinition.fileName
|
||||
|
||||
let requiredObject = require(path)
|
||||
let requiredFunction = requiredObject[utilityDefinition.functionName]
|
||||
projectInstance.utilities[utilityDefinition.propertyName] = requiredFunction.call()
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up Globals of this Project */
|
||||
if (projectDefinition[rootObjectName].globals !== undefined) {
|
||||
for (let j = 0; j < projectDefinition[rootObjectName].globals.length; j++) {
|
||||
let globalDefinition = projectDefinition[rootObjectName].globals[j]
|
||||
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Globals' + '/' + globalDefinition.fileName
|
||||
|
||||
let requiredObject = require(path)
|
||||
let requiredFunction = requiredObject[globalDefinition.functionName]
|
||||
projectInstance.globals[globalDefinition.propertyName] = requiredFunction.call()
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up Function Libraries of this Project */
|
||||
if (projectDefinition[rootObjectName].functionLibraries !== undefined) {
|
||||
for (let j = 0; j < projectDefinition[rootObjectName].functionLibraries.length; j++) {
|
||||
let functionLibraryDefinition = projectDefinition[rootObjectName].functionLibraries[j]
|
||||
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Function-Libraries' + '/' + functionLibraryDefinition.fileName
|
||||
|
||||
let requiredObject = require(path)
|
||||
let requiredFunction = requiredObject[functionLibraryDefinition.functionName]
|
||||
projectInstance.functionLibraries[functionLibraryDefinition.propertyName] = requiredFunction.call()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-12
@@ -54,17 +54,6 @@ global.CUSTOM_FAIL_RESPONSE = {
|
||||
message: 'Custom Message'
|
||||
}
|
||||
|
||||
/*
|
||||
The CL object is accesible everywhere at the Superalgos Client.
|
||||
It provides access to all modules built for this Client.
|
||||
*/
|
||||
global.CL = {}
|
||||
/*
|
||||
The SA object is accesible everywhere at the Superalgos Client.
|
||||
It provides access to all modules built Superalgos in general.
|
||||
*/
|
||||
global.SA = {}
|
||||
|
||||
/* Servers */
|
||||
let WEB_SERVER = require('./webServer.js')
|
||||
let DATA_FILE_SERVER = require('./dataFileServer.js')
|
||||
@@ -82,10 +71,24 @@ let WEB_SOCKETS_INTERFACE = require('./webSocketsInterface.js')
|
||||
let HTTP_INTERFACE = require('./httpInterface.js')
|
||||
|
||||
try {
|
||||
/*
|
||||
The CL object is accesible everywhere at the Superalgos Client.
|
||||
It provides access to all modules built for this Client.
|
||||
*/
|
||||
global.CL = {}
|
||||
/*
|
||||
The SA object is accesible everywhere at the Superalgos Client.
|
||||
It provides access to all modules built Superalgos in general.
|
||||
*/
|
||||
global.SA = {}
|
||||
/*
|
||||
First thing is to load the project schema file.
|
||||
*/
|
||||
global.PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECT_SCHEMA)
|
||||
/*
|
||||
Setting up the modules that will be available for the Servers Running inside this Client
|
||||
*/
|
||||
let MULTI_PROJECT = require('./MultiProject.js');
|
||||
let MULTI_PROJECT = require('../MultiProject.js');
|
||||
let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject()
|
||||
MULTI_PROJECT_MODULE.initialize(CL, 'CL')
|
||||
MULTI_PROJECT_MODULE.initialize(SA, 'SA')
|
||||
|
||||
Reference in new issue
Block a user