aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/serverLib/CoreApp.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/serverLib/CoreApp.js')
-rw-r--r--server/src/serverLib/CoreApp.js66
1 files changed, 66 insertions, 0 deletions
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;