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("/", async (req: express.Request, res: express.Response) => {
try {
const rooms: any[] = await matchMaker.query({});
res.json(rooms.map(room => {
const data = room.toJSON();
// additional data
data.locked = room.locked || false;
data.private = room.private;
data.elapsedTime = Date.now() - new Date(room.createdAt).getTime();
return data;
}));
} catch (e) {
const message = e.message;
console.error(message);
res.status(500);
res.json({ message });