removed some comments

This commit is contained in:
Burlone
2024-10-28 00:44:17 +01:00
parent 504868afb1
commit 43332b87b9
3 changed files with 7 additions and 20 deletions
+3 -14
View File
@@ -7,7 +7,7 @@ const path = require("path");
const kv = require("./structs/kv.js");
const config = JSON.parse(fs.readFileSync("./Config/config.json").toString());
const WebSocket = require('ws');
const https = require("https"); // Import the https module
const https = require("https");
const log = require("./structs/log.js");
const error = require("./structs/error.js");
@@ -23,17 +23,12 @@ global.JWT_SECRET = functions.MakeID();
const PORT = config.port;
const WEBSITEPORT = config.Website.websiteport;
// Declare httpsServer once
let httpsServer;
// Check if HTTPS is enabled
if (config.bEnableHTTPS) {
const https = require('https'); // Import the https module
// Load SSL certificate options from config
const httpsOptions = {
cert: fs.readFileSync(config.ssl.cert),
ca: fs.existsSync(config.ssl.ca) ? fs.readFileSync(config.ssl.ca) : undefined, // Optional
ca: fs.existsSync(config.ssl.ca) ? fs.readFileSync(config.ssl.ca) : undefined,
key: fs.readFileSync(config.ssl.key)
};
@@ -126,12 +121,10 @@ app.get("/unknown", (req, res) => {
res.json({ msg: "Reload Backend - Made by Burlone" });
});
// Start the server
let server;
if (config.bEnableHTTPS) {
server = httpsServer.listen(PORT, () => {
log.backend(`Backend started listening on port ${PORT} (HTTPS)`);
// Load additional modules
require("./xmpp/xmpp.js");
if (config.discord.bUseDiscordBot === true) {
require("./DiscordBot");
@@ -151,7 +144,6 @@ if (config.bEnableHTTPS) {
} else {
server = app.listen(PORT, () => {
log.backend(`Backend started listening on port ${PORT} (HTTP)`);
// Load additional modules
require("./xmpp/xmpp.js");
if (config.discord.bUseDiscordBot === true) {
require("./DiscordBot");
@@ -179,17 +171,15 @@ if (config.Website.bUseWebsite === true) {
const websiteApp = express();
require('./Website/website')(websiteApp);
// Load SSL certificate options if HTTPS is enabled
let httpsOptions;
if (config.bEnableHTTPS) {
httpsOptions = {
cert: fs.readFileSync(config.ssl.cert),
ca: fs.existsSync(config.ssl.ca) ? fs.readFileSync(config.ssl.ca) : undefined, // Optional
ca: fs.existsSync(config.ssl.ca) ? fs.readFileSync(config.ssl.ca) : undefined,
key: fs.readFileSync(config.ssl.key)
};
}
// Create the HTTPS server for the website
if (config.bEnableHTTPS) {
const httpsServer = https.createServer(httpsOptions, websiteApp);
httpsServer.listen(config.Website.websiteport, () => {
@@ -204,7 +194,6 @@ if (config.Website.bUseWebsite === true) {
}
});
} else {
// Fallback to HTTP server
websiteApp.listen(config.Website.websiteport, () => {
log.website(`Website started listening on port ${config.Website.websiteport} (HTTP)`);
}).on("error", async (err) => {
View File
+4 -6
View File
@@ -3,7 +3,7 @@ const XMLBuilder = require("xmlbuilder");
const XMLParser = require("xml-parser");
const express = require("express");
const fs = require("fs");
const https = require("https"); // Import the https module
const https = require("https");
const config = JSON.parse(fs.readFileSync("./Config/config.json").toString());
const app = express();
@@ -12,20 +12,18 @@ const functions = require("../structs/functions.js");
const User = require("../model/user.js");
const Friends = require("../model/friends.js");
const port = config.bEnableHTTPS ? 443 : 80; // Use port 443 for HTTPS, 80 for HTTP
const port = config.bEnableHTTPS ? 443 : 80;
let wss;
// Load SSL certificate options if HTTPS is enabled
let httpsOptions;
if (config.bEnableHTTPS) {
httpsOptions = {
cert: fs.readFileSync(config.ssl.cert),
ca: fs.existsSync(config.ssl.ca) ? fs.readFileSync(config.ssl.ca) : undefined, // Optional
ca: fs.existsSync(config.ssl.ca) ? fs.readFileSync(config.ssl.ca) : undefined,
key: fs.readFileSync(config.ssl.key)
};
}
// Create the WebSocket server
if (config.bEnableHTTPS) {
const httpsServer = https.createServer(httpsOptions, app);
wss = new WebSocket({ server: httpsServer });
@@ -39,7 +37,7 @@ if (config.bEnableHTTPS) {
global.xmppDomain = "prod.ol.epicgames.com";
global.Clients = [];
global.MUCs = {}; // Multi-user chat rooms
global.MUCs = {};
app.get("/", (req, res) => {
res.type("application/json");