mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-27 00:07:50 +01:00
some game joining logic
This commit is contained in:
@@ -17,4 +17,20 @@ router.post('/create', function (req, res) {
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/availability/:code', function (req, res) {
|
||||
const joinGamePromise = gameManager.joinGame(req.params.code);
|
||||
joinGamePromise.then((result) => {
|
||||
if (result === 404) {
|
||||
res.status(404).send();
|
||||
} else if (result instanceof Error) {
|
||||
res.status(400).send(result.message);
|
||||
} else if (typeof result === "string") {
|
||||
logger.debug(result);
|
||||
res.status(200).send(result);
|
||||
} else {
|
||||
res.status(500).send();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user