art round 1
This commit is contained in:
12
nodejs/conf/base.js
Normal file
12
nodejs/conf/base.js
Normal file
@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
"mc": {
|
||||
"server": "corejourney.org._vAUTO.mc.proxy",
|
||||
"bots": {
|
||||
"bot_name": {
|
||||
"username": "<configure in secrets>",
|
||||
"password": "<configure in secrets>",
|
||||
'auth': "microsoft"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
32
nodejs/conf/index.js
Normal file
32
nodejs/conf/index.js
Normal file
@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
const extend = require('extend');
|
||||
|
||||
const environment = process.env.NODE_ENV || 'development';
|
||||
|
||||
function load(filePath, required){
|
||||
try {
|
||||
return require(filePath);
|
||||
} catch(error){
|
||||
if(error.name === 'SyntaxError'){
|
||||
console.error(`Loading ${filePath} file failed!\n`, error);
|
||||
process.exit(1);
|
||||
} else if (error.code === 'MODULE_NOT_FOUND'){
|
||||
console.warn(`No config file ${filePath} FOUND! This may cause issues...`);
|
||||
if (required){
|
||||
process.exit(1);
|
||||
}
|
||||
return {};
|
||||
}else{
|
||||
console.dir(`Unknown error in loading ${filePath} config file.\n`, error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = extend(
|
||||
true, // enable deep copy
|
||||
load('./base', true),
|
||||
load(`./${environment}`),
|
||||
load('./secrets'),
|
||||
{environment}
|
||||
);
|
Reference in New Issue
Block a user