From 30dc631566efe374d6809c984e944f24600b9747 Mon Sep 17 00:00:00 2001 From: tgpethan Date: Sat, 4 Jan 2020 12:54:06 +0000 Subject: [PATCH] Update index.js --- index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index e7c50c5..260ea82 100644 --- a/index.js +++ b/index.js @@ -50,17 +50,19 @@ fs.readFile('./misc/ascii.txt', function(err, data) { if (files[i].includes(".js")) { console.log(`[Modules] Found module ${files[i].toString()}`); global.modules[files[i].toString().replace(".js", "")] = require(`./modules/${files[i].toString()}`); + + // We want to find out what the request handler module is + if (global.modules[files[i].toString().replace(".js", "")].MOD_FUNC == "handle_requests") { + // Set reqhandler to the request handler for easy getting + reqhandler = global.modules[files[i].toString().replace(".js", "")]; + } + // Loop through and set the required modules flags for (var i1 = 0; i1 < requiredModules.length; i1++) { if (global.modules[files[i].toString().replace(".js", "")].MOD_FUNC == requiredModules[i1].name) { requiredModules[i1].status = true; } } - // We want to find out what the request handler module is - if (global.modules[files[i].toString().replace(".js", "")].MOD_FUNC == "handle_requests") { - // Set reqhandler to the request handler for easy getting - reqhandler = global.modules[files[i].toString().replace(".js", "")]; - } } else { if (files[i].split(".").length < 2) continue; console.log(`[Modules] Found file ${files[i]}. It is not a module.`) @@ -82,12 +84,12 @@ fs.readFile('./misc/ascii.txt', function(err, data) { process.exit(1); } else { global.modules.consoleHelper.printInfo(emoji.wave, "Starting Revolution..."); - server(); + frameworkServer(); } }); }); -function server() { +function frameworkServer() { reqhandler.extras(); app.get('*', (req, res) => reqhandler.get(req, res)); app.post('*', (req, res) => reqhandler.post(req, res));