add update game endpoint

This commit is contained in:
2025-06-01 12:47:13 -07:00
parent 62f0636d2d
commit 66ff3eaaea
3 changed files with 48 additions and 11 deletions

View File

@ -47,13 +47,6 @@ export const PUT: RequestHandler = async ({ params, request }): Promise<Response
const game = Game.from(listing.data);
if (game.setPlayerReady(player) === null) return notFoundResponse();
// TODO: there's a potential race condition here where some player is unreadying as this
// function is running. This should do some kind of check in MongoDB to make sure
// all players are ready if it's starting the game. For now: good enough.
if (game.players.every(({ isReady }) => isReady)) {
game.start();
}
await writeUpdatedListing(ServerCollections.Games, updateListing(listing, game));
return singleResponse(game);