Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
api.get("/room", async (req: express.Request, res: express.Response) => {
const roomId = req.query.roomId;
try {
const [_, inspectData] = await matchMaker.remoteRoomCall(roomId, "getInspectData");
res.json(inspectData);
} catch (e) {
const message = UNAVAILABLE_ROOM_ERROR.replace("$roomId", roomId);
console.error(message);
res.status(500);
res.json({ message });
}
});
api.get("/room/call", async (req: express.Request, res: express.Response) => {
const roomId = req.query.roomId;
const method = req.query.method;
const args = JSON.parse(req.query.args);
try {
const [_, data] = await matchMaker.remoteRoomCall(roomId, method, args);
res.json(data);
} catch (e) {
const message = UNAVAILABLE_ROOM_ERROR.replace("$roomId", roomId);
console.error(message);
res.status(500);
res.json({ message });
}
});