From c634e03cb553e21158fddc6d4221a54aa799de79 Mon Sep 17 00:00:00 2001 From: marzavec Date: Mon, 18 Mar 2019 23:36:21 -0700 Subject: refactoring 1 of 2 --- server/src/serverLib/CoreApp.js | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 server/src/serverLib/CoreApp.js (limited to 'server/src/serverLib/CoreApp.js') diff --git a/server/src/serverLib/CoreApp.js b/server/src/serverLib/CoreApp.js new file mode 100644 index 0000000..012ae44 --- /dev/null +++ b/server/src/serverLib/CoreApp.js @@ -0,0 +1,66 @@ +/** + * The core / global reference object + * + * Version: v2.0.0 + * Developer: Marzavec ( https://github.com/marzavec ) + * License: WTFPL ( http://www.wtfpl.net/txt/copying/ ) + * + */ + +const path = require('path'); +const { + CommandManager, + ConfigManager, + ImportsManager, + MainServer, + StatsManager +} = require('./'); + +class CoreApp { + /** + * Create the main core instance. + */ + constructor () { + + } + + async init () { + await this.buildConfigManager(); + + this.buildImportManager(); + this.buildCommandsManager(); + this.buildStatsManager(); + this.buildMainServer(); + } + + async buildConfigManager () { + this.configManager = new ConfigManager(path.join(__dirname, '../..')); + this.config = await this.configManager.load(); + + if (this.config === false) { + console.error('Missing config.json, have you run: npm run config'); + process.exit(0); + } + } + + buildImportManager () { + this.dynamicImports = new ImportsManager(path.join(__dirname, '../..')); + this.dynamicImports.init(); + } + + buildCommandsManager () { + this.commands = new CommandManager(this); + this.commands.loadCommands(); + } + + buildStatsManager () { + this.stats = new StatsManager(this); + this.stats.set('start-time', process.hrtime()); + } + + buildMainServer () { + this.server = new MainServer(this); + } +} + +module.exports = CoreApp; -- cgit v1.2.1