/** * SugarNode-TS * This is a fast-easy framework with a lot syntactic-sugar for node developers. * It is the 3rd version from my own develop framework,which had been used for some commercial projects,even some high concurrency iot projects. * And now i decide to port it to TS version. * * @Author HonorLee (dev@honorlee.me) * @Version 1.0 (2022-06-25) * @License MIT */ /* * Entry File * DO NOT CHANGE ANYTHING IN THIS FILE! */ (global as any).SYSTEM = {}; SYSTEM.ROOTPATH = __dirname; require("./config"); require('./system/core'); if(SYSTEM.CONFIG.entrance){ FILE.stat(`${SYSTEM.PATH.App}/${SYSTEM.CONFIG.entrance}`,async (err:Error,stats:any)=>{ if(err || !stats.isFile()){ LOGGER.error(`Wrong entrance file: ${SYSTEM.CONFIG.entrance}`); LOGGER.error(`Entrance Error: ${err}`); }else{ for(const module of SYSTEM.CONFIG.module){ if(!module.enable) continue; const moduleName = module.name.toLowerCase(); const modulePath = `${SYSTEM.PATH.Module}/${moduleName}/${moduleName}`; try{ // eslint-disable-next-line @typescript-eslint/no-var-requires const MOD = require(modulePath); new MOD(module.option) LOGGER.info(`Module [${moduleName.toUpperCase()}] loaded`); }catch(e:any){ LOGGER.error(`Module [${moduleName.toUpperCase()}] loaded error`); if(e.stack) LOGGER.error(e.stack); } } await import(`${SYSTEM.PATH.App}/${SYSTEM.CONFIG.entrance}`); } }) }else{ LOGGER.error('Empty entrance option,please check Config.js'); } process.on('uncaughtException',(err)=>{ LOGGER.error(err.stack as string); })