✌️
This commit is contained in:
parent
910ccf1804
commit
e82268db7e
7 changed files with 38 additions and 9 deletions
16
src/api/endpoints/othello/games/show.ts
Normal file
16
src/api/endpoints/othello/games/show.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import $ from 'cafy';
|
||||
import Game, { pack } from '../../../models/othello-game';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'game_id' parameter
|
||||
const [gameId, gameIdErr] = $(params.game_id).id().$;
|
||||
if (gameIdErr) return rej('invalid game_id param');
|
||||
|
||||
const game = await Game.findOne({ _id: gameId });
|
||||
|
||||
if (game == null) {
|
||||
return rej('game not found');
|
||||
}
|
||||
|
||||
res(await pack(game, user));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue