From 31479019f5e69b2ca547ba26382ba1b1a2edd5de Mon Sep 17 00:00:00 2001 From: sky Date: Sat, 27 Sep 2025 20:54:40 -0400 Subject: [PATCH] optimizations --- index.js | 16 +++++++--------- pm2.config.cjs | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 3a32ddf..b47f1c4 100755 --- a/index.js +++ b/index.js @@ -27,15 +27,15 @@ app.use(cookieParser()); app.use(express.json({ limit: "10mb" })); app.use(express.urlencoded({ extended: false })); app.use(express.text()); -app.use("/", (req, res, next) => { - next(); -}); +// app.use("/", (req, res, next) => { +// next(); +// }); // setInterval(()=>{ // }, 1000) import WebSocket, { WebSocketServer } from "ws"; const wss = new WebSocketServer({ noServer: true }); -let openSockets = 0; +// let openSockets = 0; wss.on("connection", function connection(ws, req, res) { ws.send(`online=${wss.clients.size}`); setInterval(() => { @@ -125,7 +125,7 @@ app.post("/api/account/upload", async (req, res, next) => { res.status(400).send(status); } } else { - return "KILL YOURSELF"; + // return "KILL YOURSELF"; } }); @@ -243,14 +243,12 @@ app.use("/data/:id/:file", async (req, res) => { const filePath = path.join(process.env.DATA_PATH, "data", id, file); try { await fs.access(filePath); - - const image = await fs.readFile(filePath); if (mime.lookup(filePath) == "image/webp") { res.type("image/webp"); - res.status(200).send(image); + res.status(200).send(await fs.readFile(filePath)); } else if (mime.lookup(filePath) == "audio/ogg") { res.type("audio/ogg"); - res.status(200).send(image); + res.status(200).send(await fs.readFile(filePath)); } else { res.status(404).send("File not found"); } diff --git a/pm2.config.cjs b/pm2.config.cjs index f1a2a7b..461b794 100755 --- a/pm2.config.cjs +++ b/pm2.config.cjs @@ -2,4 +2,8 @@ module.exports = { name: "Selenite", // Name of your application script: "index.js", // Entry point of your application interpreter: "bun", // Path to the Bun interpreter + watch: true, + cron_restart: '0 0 * * *', + instances : "max", + exec_mode : "cluster" };