From 68cb790fdf339582bdc6d1daeda844261bd99867 Mon Sep 17 00:00:00 2001 From: ScriptSorcerer20 Date: Tue, 6 May 2025 15:26:48 +0200 Subject: [PATCH] swagger port updated and added leave button --- gambling.js | 12 ++++++++++++ swagger.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gambling.js b/gambling.js index 15eb412..a240882 100644 --- a/gambling.js +++ b/gambling.js @@ -252,6 +252,18 @@ app.get("/lobby/join", authenticateToken, async (req, res) => { } }); +app.delete("/lobby/leave", authenticateToken, async (req, res) => { + let lobbyId = req.query.lobbyId; + let username = req.query.username; + + console.log(playerMap); + if (lobbyId in playerMap) { + playerMap[lobbyId].splice(username, 1); + + res.send("Succesfully logged out."); + } else console.log("Couldn't leave"); +}); + app.get("/lobby/players", authenticateToken, async (req, res) => { let lobbyId = req.query.lobbyId; let players = playerMap[lobbyId] || []; diff --git a/swagger.js b/swagger.js index 89d0c84..13114d8 100644 --- a/swagger.js +++ b/swagger.js @@ -5,7 +5,7 @@ const doc = { title: 'GAMBLE!', description: 'Gambling API' }, - host: 'localhost:3000', + host: 'localhost:25565', components: { securitySchemes:{ bearerAuth: {