IO-2632 Add basic instance manager functions & editor config.
This commit is contained in:
34
server/utils/instanceMgr.js
Normal file
34
server/utils/instanceMgr.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Returns the corresponding component/function/object based on the type of instance.
|
||||
* Based on the node env params, return the correct prop.
|
||||
* Default is to return the ImEX Prop
|
||||
* @typedef {Object} InstanceManagerObject
|
||||
* @property { string | object | function } rome Return this prop if Rome.
|
||||
* @property { string | object | function } proman Return this prop if Rome.
|
||||
* @property { string | object | function } imex Return this prop if Rome.
|
||||
*/
|
||||
|
||||
function InstanceManager({ rome, proman, imex }) {
|
||||
let propToReturn = null;
|
||||
|
||||
switch (process.env.INSTANCE) {
|
||||
case "IMEX":
|
||||
propToReturn = imex;
|
||||
break;
|
||||
case "ROME":
|
||||
propToReturn = rome;
|
||||
break;
|
||||
case "PROMANAGER":
|
||||
propToReturn = proman;
|
||||
break;
|
||||
default:
|
||||
propToReturn = imex;
|
||||
break;
|
||||
}
|
||||
if (!propToReturn) {
|
||||
throw new Error(
|
||||
`Prop to return is not valid for this instance (${process.env.INSTANCE}).`
|
||||
);
|
||||
}
|
||||
return propToReturn;
|
||||
}
|
||||
Reference in New Issue
Block a user