crispuavy Posted July 22, 2022 Report Share Posted July 22, 2022 Here's a patebin of the code (password isn't real): https://pastebin.com/Br37dX8r const functions = require("firebase-functions"); const express = require("express"); const redis = require("redis"); const regionInfo = require("./regionInfo.json"); const app = express(); const client = redis.createClient({ database: 0, password: "hunter123", url: "redis://database.skeld.net", socket: 6379, }); app.get("/games", async (request, response) => { console.log("/games request"); await client.connect(); const codes = await client.sMembers("skeldsync.games"); response.set("Cache-Control", "public, max-age=10, s-maxage=20"); response.setHeader("Access-Control-Allow-Origin", "*"); var lobbyInfos = new Array(); for (const idx in codes) { const code = codes[idx]; const lobbyInfo = await client.hGetAll("ImpostorRedis" + code); if (lobbyInfo.in_progress == "true") continue; lobbyInfos.push(lobbyInfo.lobby_data); } var result = `${JSON.stringify(lobbyInfos)}`; response.send(result); console.log("Lobby infos length: " + lobbyInfos.length); await client.disconnect(); }); app.get("/playercount", async (request, response) => { console.log("/playercount request"); await client.connect(); const codes = await client.sMembers("skeldsync.games"); response.set("Cache-Control", "public, max-age=5, s-maxage=10"); response.setHeader("Access-Control-Allow-Origin", "*"); var totalPlayers = 0; for (const idx in codes) { const code = codes[idx]; const str = await client.hGet("ImpostorRedis" + code, "player_count"); if (str == null) continue; const playerCount = Number.parseInt(str); totalPlayers += playerCount; } var result = `${totalPlayers}`; response.send(result); console.log("Total players: " + result); await client.disconnect(); }); app.get("/regionInfo", async (request, response) => { console.log("/regionInfo request"); response.set("Cache-Control", "public, max-age=3600, s-maxage=3600"); response.send(regionInfo); }); app.get("/ip", async (request, response) => { console.log("/ip request"); response.set("Cache-Control", "public, max-age=3600, s-maxage=3600"); response.send(regionInfo.Regions[0].Servers[0].Ip); }); app.get("/deeplink", async (request, response) => { console.log("/deeplink request"); response.setHeader("Access-Control-Allow-Origin", "*"); response.set("Cache-Control", "public, max-age=3600, s-maxage=3600"); response.send( `amongus://init\?servername=<color=\"orange\">skeld.net\&serverport=22023\&serverip=${regionInfo.Regions[0].Servers[0].Ip}\&usedtls=false` ); }); exports.app = functions.https.onRequest(app); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.