From 121488aab3fb31a8a15715418b4025bdc852d57c Mon Sep 17 00:00:00 2001 From: Xargana Date: Sat, 29 Mar 2025 13:35:23 +0300 Subject: [PATCH] a --- api/server.js | 12 ++++-------- api/status/server.js | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/api/server.js b/api/server.js index 0e855f1..d21a51a 100644 --- a/api/server.js +++ b/api/server.js @@ -3,8 +3,6 @@ const cors = require("cors"); const fs = require("fs"); const https = require("https"); const http = require("http"); -const path = require("path"); -const ping = require("ping"); const status = require("./status/server") const app = express(); @@ -16,19 +14,17 @@ const cert = "/etc/letsencrypt/live/blahaj.tr/fullchain.pem" app.use(cors()); app.use("/status", status); -// Try to load SSL Certificates +// Try to load certificates try { const sslOptions = { key: fs.readFileSync(key), cert: fs.readFileSync(cert), }; - // Start HTTPS Server if certificates are available https.createServer(sslOptions, app).listen(PORT, () => { - console.log(`API running securely at https://localhost:${PORT}`); + console.log(`API running at https://localhost:${PORT}`); }); } catch (e) { - // If certificate loading fails, start HTTP server instead if (e.code === 'ENOENT') { console.warn(`SSL certificate file(s) not found: ${e.path}`); } else { @@ -37,8 +33,8 @@ try { console.log("Starting server without SSL..."); - // Start HTTP Server as fallback + // Start http server as fallback http.createServer(app).listen(PORT, () => { - console.log(`API running insecurely at http://localhost:${PORT}`); + console.log(`API running at http://localhost:${PORT}`); }); } diff --git a/api/status/server.js b/api/status/server.js index 441bf41..6776a6f 100644 --- a/api/status/server.js +++ b/api/status/server.js @@ -1,5 +1,4 @@ const express = require("express"); -const cors = require("cors"); const ping = require("ping"); const router = express.Router();