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.js84
1 files changed, 56 insertions, 28 deletions
diff --git a/server/src/serverLib/CoreApp.js b/server/src/serverLib/CoreApp.js
index 6bab090..8c2225d 100644
--- a/server/src/serverLib/CoreApp.js
+++ b/server/src/serverLib/CoreApp.js
@@ -1,30 +1,32 @@
-/**
- * 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 {
+import { join } from 'path';
+import {
CommandManager,
ConfigManager,
ImportsManager,
MainServer,
- StatsManager
-} = require('./');
+ StatsManager,
+} from '.';
+/**
+ * The core app builds all required classes and maintains a central
+ * reference point across the app
+ * @property {ConfigManager} configManager - Provides loading and saving of the server config
+ * @property {Object} config - The current json config object
+ * @property {ImportsManager} dynamicImports - Dynamic require interface allowing hot reloading
+ * @property {CommandManager} commands - Manages and executes command modules
+ * @property {StatsManager} stats - Stores and adjusts arbritary stat data
+ * @property {MainServer} server - Main websocket server reference
+ * @author Marzavec ( https://github.com/marzavec )
+ * @version v2.0.0
+ * @license WTFPL ( http://www.wtfpl.net/txt/copying/ )
+ */
class CoreApp {
/**
- * Create the main core instance.
- */
- constructor () {
-
- }
-
- async init () {
+ * Load config then initialize children
+ * @public
+ * @return {void}
+ */
+ async init() {
await this.buildConfigManager();
this.buildImportManager();
@@ -33,8 +35,14 @@ class CoreApp {
this.buildMainServer();
}
- async buildConfigManager () {
- this.configManager = new ConfigManager(path.join(__dirname, '../..'));
+ /**
+ * Creates a new instance of the ConfigManager, loads and checks
+ * the server config
+ * @private
+ * @return {void}
+ */
+ async buildConfigManager() {
+ this.configManager = new ConfigManager(join(__dirname, '../..'));
this.config = await this.configManager.load();
if (this.config === false) {
@@ -43,23 +51,43 @@ class CoreApp {
}
}
- buildImportManager () {
- this.dynamicImports = new ImportsManager(path.join(__dirname, '../..'));
+ /**
+ * Creates a new instance of the ImportsManager
+ * @private
+ * @return {void}
+ */
+ buildImportManager() {
+ this.dynamicImports = new ImportsManager(join(__dirname, '../..'));
}
- buildCommandsManager () {
+ /**
+ * Creates a new instance of the CommandManager and loads the command modules
+ * @private
+ * @return {void}
+ */
+ buildCommandsManager() {
this.commands = new CommandManager(this);
this.commands.loadCommands();
}
- buildStatsManager () {
+ /**
+ * Creates a new instance of the StatsManager and sets the server start time
+ * @private
+ * @return {void}
+ */
+ buildStatsManager() {
this.stats = new StatsManager(this);
this.stats.set('start-time', process.hrtime());
}
- buildMainServer () {
+ /**
+ * Creates a new instance of the MainServer
+ * @private
+ * @return {void}
+ */
+ buildMainServer() {
this.server = new MainServer(this);
}
}
-module.exports = CoreApp;
+export { CoreApp };