Skip to content

Commit

Permalink
feat(server): Throw 404 from create endpoint if game not found
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed May 7, 2020
1 parent af72f03 commit da8a473
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/server/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export const addApiToServer = ({
let numPlayers = parseInt(ctx.request.body.numPlayers);

const game = games.find(g => g.name === gameName);
if (!game) ctx.throw(404, 'Game ' + gameName + ' not found');

const gameID = await CreateGame(
db,
game,
Expand Down

0 comments on commit da8a473

Please sign in to comment.