1
0

Fix invalid game state

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2022-01-28 18:09:46 -08:00
parent 302826b5e5
commit 7f813ff2bd

View File

@ -344,7 +344,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
}
break;
}
return sendGame(res, req, game, error);
})
@ -352,15 +352,19 @@ router.get("/:id", async (req, res/*, next*/) => {
const { id } = req.params;
console.log("GET games/" + id);
let error;
const game = await loadGame(id);
if (game) {
return sendGame(res, req, game)
}
error = `Game ${id} not found -- returning invalid game state.`;
console.warn(error);
return sendGame(res, req, { id: id, state: 'invalid' }, error);
const invalid = {
id: id,
players: {},
state: 'invalid'
};
return sendGame(res, req, invalid, error);
});
router.put("/:id", (req, res/*, next*/) => {