From e6b016194e9f80807b8b253549cf6fe29475b64c Mon Sep 17 00:00:00 2001 From: azures04 Date: Thu, 1 May 2025 18:42:48 +0200 Subject: [PATCH] Sync --- .npmrc | 1 + data/main.db | Bin 20480 -> 28672 bytes package.json | 3 +++ routes/api/v1/ban/index.js | 1 - routes/api/v1/file/game.js | 25 ++++++++++++++++++++++--- routes/api/v1/file/hash.js | 4 ++-- server.js | 2 +- 7 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..4fd0219 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict=true \ No newline at end of file diff --git a/data/main.db b/data/main.db index 2d095a0754d6aa4c737ca20f3e10fc1501c68b36..4222931fda0c76d03eac8edf822fd473673f6a22 100644 GIT binary patch delta 986 zcmeIv%Sr-a7>Dt1KIh~(&U7xbgB|UBG&3`maPO{7n}Q)CA|k@I-a+C{BqSo*dLtnb z5z(UiaMQ?h2SK|w{~z!6dCN_u{H@$YwSo}BsK#@*C9clilxE+6m;dY#JM}`~W zq}{eJY&CQrN?EVgrKJa(!L<2iUYVxxU}W@n{aUxQM=h&X}2^fblh{7mDU<8I?2nJyQ`k@bcp$A-WAPhEy zz=9x{V1N!9s1N|zrB*MV9{YXuc-Y^#C<(XjCY+c5*xsMSK1+8yM|A5Kom-W*CcQl0 p%Rv?nAOri5hCN8ZE+kWae_1}D+2=q>qG^6M%Il93+%agfm}xZSq%KMHVX<&;Acu= 23.11.0" } } diff --git a/routes/api/v1/ban/index.js b/routes/api/v1/ban/index.js index 94cfb74..9c72d2b 100644 --- a/routes/api/v1/ban/index.js +++ b/routes/api/v1/ban/index.js @@ -5,7 +5,6 @@ const express = require("express") const router = express() router.post("/iam", (req, res) => { - console.log(req.body) if (!req.body || !req.body.hwid) { const ip = req.headers['x-forwarded-for'] || req.socket.remoteAddress utils.handleError(req, res, 422, "Paramètre manquant dans le corp de la requête : ") diff --git a/routes/api/v1/file/game.js b/routes/api/v1/file/game.js index cefebb3..ac1967a 100644 --- a/routes/api/v1/file/game.js +++ b/routes/api/v1/file/game.js @@ -4,11 +4,30 @@ const utils = require("../../../../modules/utils") const express = require("express") const router = express() -router.use("", (req, res) => { +router.use("/download", (req, res) => { const gameFiles = path.join(__dirname, "..", "..", "..", "..", "data", "gameFiles") - if (fs.existsSync(finalPath)) { + const gameFile = path.join(gameFiles, req.path) + if (fs.existsSync(gameFile)) { try { - res.status(200).json(fs.readdirSync(gameFiles, { recursive: true })) + res.download(gameFile) + } catch (error) { + console.error(error) + utils.handleError(req, res, 500, "Erreur interne du serveur.") + } + } else { + utils.handleError(req, res, 404, "Fichier introuvable.") + } +}) + +router.get("", (req, res) => { + const gameFiles = path.join(__dirname, "..", "..", "..", "..", "data", "gameFiles") + if (fs.existsSync(gameFiles)) { + try { + res.status(200).json(fs.readdirSync(gameFiles, { recursive: true }).filter(value => { + if (!fs.statSync(path.join(gameFiles, value)).isDirectory()) { + return value + } + })) } catch (error) { console.error(error) utils.handleError(req, res, 500, "Erreur interne du serveur.") diff --git a/routes/api/v1/file/hash.js b/routes/api/v1/file/hash.js index 53b08c1..d27b319 100644 --- a/routes/api/v1/file/hash.js +++ b/routes/api/v1/file/hash.js @@ -5,10 +5,10 @@ const utils = require("../../../../modules/utils") const express = require("express") const router = express() -router.use("", (req, res) => { +router.use("", async (req, res) => { const finalPath = path.join(__dirname, "..", "..", "..", "..", "data", "gameFiles", req.path) if (fs.existsSync(finalPath)) { - res.status(200).json(controller.getFileHash(finalPath)) + res.status(200).send(await controller.getFileHash(finalPath)) } else { utils.handleError(req, res, 404, "Fichier introuvable.") } diff --git a/server.js b/server.js index dcd2230..e4934af 100644 --- a/server.js +++ b/server.js @@ -35,7 +35,7 @@ io.on("connection", (socket) => { socket.on("force-update", () => { const token = socket.handshake.auth.token if (dbController.isTokenValid(token)) { - io.to("/game/updates").emit("confirmed") + io.emit("force-game-update") } else { socket.disconnect() }