/* * This file is part of the authRXBN single sign-on package. * * (c) Ruben Meyer */ // GDS: Global Data System global['gds'] = { debug: (process.env.NODE_ENV === 'debug') ? true : false, db: null, cache: {}, cfg: require(__dirname+'/bin/config') }; global['modules'] = {}; global['__dirname'] = __dirname; /** * load modules */ let load = (name) => { return require(__dirname+'/bin/'+name+'/module'); }; // environment variable check 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(); global['modules'].events = load('events'); // event handler global['modules'].cli = load('cli'); // command line interface global['modules'].logs = load('logs'); // log handler global['logs'] = global['modules'].logs; // alias global['modules'].database = load('database'); // database service global['modules'].web = load('web'); // web server global['modules'].auth = load('auth'); // authentication handler global['logs'] = global['modules'].logs; // alias // start web server global['modules'].web.start();