aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/serverLib/CoreApp.js
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2019-03-19 07:36:21 +0100
committermarzavec <admin@marzavec.com>2019-03-19 07:36:21 +0100
commitc634e03cb553e21158fddc6d4221a54aa799de79 (patch)
tree74f303d4ab65b08c7ec316fb713146cc99024c00 /server/src/serverLib/CoreApp.js
parentMerge pull request #56 from paulgreg/manifest (diff)
downloadhackchat-c634e03cb553e21158fddc6d4221a54aa799de79.tar.gz
hackchat-c634e03cb553e21158fddc6d4221a54aa799de79.zip
refactoring 1 of 2
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;