1
0
Fork 0
auth.rxbn.de/app.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-06-01 20:35:40 +00:00
/*
* This file is part of the authRXBN single sign-on package.
*
* (c) Ruben Meyer <contact@rxbn.de>
*/
// GDS: Global Data System
global['gds'] = {
2019-06-23 21:27:52 +00:00
debug: (process.env.NODE_ENV === 'debug') ? true : false,
2019-06-01 20:35:40 +00:00
db: null,
cache: {},
cfg: require(__dirname+'/bin/config')
};
global['modules'] = {};
global['__dirname'] = __dirname;
/**
* load modules
*/
let load = (name) => {
return require(__dirname+'/bin/'+name+'/module');
};
2019-06-23 21:27:52 +00:00
// environment variable check
2019-09-08 17:57:42 +00:00
let env_vars = ["DB_URL", "DB_NAME"];
let env_missing = false;
env_vars.forEach((el) => {
if(typeof process.env[el] == 'undefined') {
console.error("environment variable "+el+" is not set");
env_missing = true;
}
});
if(env_missing) process.exit();
2019-06-23 21:27:52 +00:00
2019-06-01 20:35:40 +00:00
global['modules'].events = load('events'); // event handler
global['modules'].cli = load('cli'); // command line interface
2019-09-25 18:21:00 +00:00
2019-06-01 20:35:40 +00:00
global['modules'].logs = load('logs'); // log handler
2019-09-25 18:21:00 +00:00
global['logs'] = global['modules'].logs; // alias
2019-06-01 20:35:40 +00:00
global['modules'].database = load('database'); // database service
global['modules'].web = load('web'); // web server
global['modules'].auth = load('auth'); // authentication handler
2019-09-01 19:28:33 +00:00
global['logs'] = global['modules'].logs; // alias
2019-06-01 20:35:40 +00:00
// start web server
global['modules'].web.start();