mirror of
https://github.com/ApfelTeeSaft/Reload-Backend.git
synced 2026-08-26 19:33:26 +00:00
Finished Update Hopefully
This commit is contained in:
+8
-7
@@ -61,6 +61,14 @@
|
||||
"bEnableAutoBackendRestart": false,
|
||||
"bRestartTime": "",
|
||||
|
||||
"//": "Use HTTPS (For VPS Side Only, Or If You Were To Setup A Type Record To Your Own Public Adress From Your Domain) (You Also Need To Change The Examples In SSl Folder!)",
|
||||
"bEnableHTTPS": false, "//": "Only Enable if You Have SSL Certificate In The ssl Folder",
|
||||
"ssl": {
|
||||
"cert": "./ssl/certificate.crt",
|
||||
"//ca//": "./ssl/ca_bundle.crt", "//": "Optional (Only If You Have A CA Bundle from your ssl certificate)",
|
||||
"key": "./ssl/private.key"
|
||||
},
|
||||
|
||||
"//": "These are all the events you can add to the game, like the rift in the sky!",
|
||||
"bEnableGeodeEvent": false,
|
||||
"geodeEventStartDate": "2020-01-01T00:00:00.000Z",
|
||||
@@ -78,11 +86,4 @@
|
||||
"bEnableBlockbusterRiskyEvent": false,
|
||||
"bEnableCubeLake": false,
|
||||
"cubeLakeDate": "2020-01-01T00:00:00.000Z"
|
||||
|
||||
"//": "Use HTTPS (For VPS Side Only, Or If You Were To Setup A Type Record To Your Own Public Adress From Your Domain)",
|
||||
"bEnableHTTPS": true,
|
||||
"ssl": {
|
||||
"cert": "./ssl/certificate.crt", "//": "Path to SSL certificate",
|
||||
"ca": "./ssl/ca_bundle.crt", "//": "Path to CA bundle (optional)",
|
||||
"key": "./ssl/private.key" "//": "Path to private key",
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const jwt = require("jsonwebtoken");
|
||||
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 log = require("./structs/log.js");
|
||||
const error = require("./structs/error.js");
|
||||
@@ -21,8 +22,10 @@ global.JWT_SECRET = functions.MakeID();
|
||||
const PORT = config.port;
|
||||
const WEBSITEPORT = config.Website.websiteport;
|
||||
|
||||
// Check if HTTPS is enabled
|
||||
// Declare httpsServer once
|
||||
let httpsServer;
|
||||
|
||||
// Check if HTTPS is enabled
|
||||
if (config.bEnableHTTPS) {
|
||||
const https = require('https'); // Import the https module
|
||||
|
||||
@@ -123,20 +126,18 @@ app.get("/unknown", (req, res) => {
|
||||
});
|
||||
|
||||
// Start the server
|
||||
const startServer = (server) => {
|
||||
server.listen(PORT, () => {
|
||||
log.backend(`Backend started listening on port ${PORT}`);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
if (config.bUseAutoRotate === true) {
|
||||
require("./structs/autorotate.js");
|
||||
}
|
||||
|
||||
}).on("error", async (err) => {
|
||||
if (err.code === "EADDRINUSE") {
|
||||
log.error(`Port ${PORT} is already in use!\nClosing in 3 seconds...`);
|
||||
@@ -146,31 +147,33 @@ const startServer = (server) => {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Check if HTTPS is enabled
|
||||
if (config.bEnableHTTPS) {
|
||||
const httpsOptions = {
|
||||
cert: fs.readFileSync(config.ssl.cert),
|
||||
ca: fs.existsSync(config.ssl.ca) ? fs.readFileSync(config.ssl.ca) : undefined, // Optional
|
||||
key: fs.readFileSync(config.ssl.key)
|
||||
};
|
||||
|
||||
const httpsServer = https.createServer(httpsOptions, app);
|
||||
wss = new WebSocket({ server: httpsServer });
|
||||
|
||||
// Start the HTTPS server
|
||||
startServer(httpsServer);
|
||||
} else {
|
||||
// Start the HTTP server
|
||||
wss = new WebSocket({ server: app.listen(PORT) });
|
||||
startServer(app);
|
||||
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");
|
||||
}
|
||||
if (config.bUseAutoRotate === true) {
|
||||
require("./structs/autorotate.js");
|
||||
}
|
||||
}).on("error", async (err) => {
|
||||
if (err.code === "EADDRINUSE") {
|
||||
log.error(`Port ${PORT} is already in use!\nClosing in 3 seconds...`);
|
||||
await functions.sleep(3000);
|
||||
process.exit(0);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (config.bEnableAutoBackendRestart === true) {
|
||||
AutoBackendRestart.scheduleRestart(config.bRestartTime);
|
||||
}
|
||||
|
||||
|
||||
if (config.Website.bUseWebsite === true) {
|
||||
const websiteApp = express();
|
||||
require('./Website/website')(websiteApp);
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
title Reload Backend Package Installer
|
||||
|
||||
npm i
|
||||
npm install express
|
||||
npm install ws
|
||||
pause
|
||||
Generated
+567
-176
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -10,7 +10,7 @@
|
||||
"destr": "^2.0.3",
|
||||
"discord.js": "^13.7.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"express": "^4.21.1",
|
||||
"express-rate-limit": "^6.7.0",
|
||||
"ioredis": "^5.4.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
|
||||
Reference in New Issue
Block a user