console.clear(); // Globals global.consoleHelper = require("./consoleHelper.js"); global.protocolVersion = 19; const app = require("express")(), fs = require("fs"), serverHandler = require("./server/serverHandler.js"), config = require("./config.json"); const debugMode = true; app.use((req, res) => { req.packet = new Buffer.alloc(0); req.on("data", (chunk) => req.packet = Buffer.concat([req.packet, chunk], req.packet.length + chunk.length)); req.on("end", () => { switch (req.method) { case "GET": if (req.url == "/" || req.url == "/index.html" || req.url == "/index.html") { fs.readFile("./web/serverPage.html", (err, data) => { if (err) throw err; if (debugMode) data = data.toString().replace("|isdebug?|", 'DEBUG'); else data = data.toString().replace("|isdebug?|", ''); res.send(data); }); } else if (req.url == "/chat") { fs.readFile("./web/chatPageTemplate.html", (err, data) => { if (err) throw err; let lines = "", flip = false; const limit = global.chatHistory.length < 10 ? 10 : global.chatHistory.length; for (let i = global.chatHistory.length - 10; i < limit; i++) { if (i < 0) i = 0; lines += `