- let gameID = req.query["gid"];
- GameModel.getById(ObjectId(gameID), (err,game) => {
- access.checkRequest(res, err, game, "Game not found", () => {
- res.json({game: game});
- });
- });
+ const gameId = req.query["gid"];
+ if (!!gameId)
+ {
+ GameModel.getOne(gameId, (err,game) => {
+ access.checkRequest(res, err, game, "Game not found", () => {
+ res.json({game: game});
+ });
+ });
+ }
+ else
+ {
+ // Get by (non-)user ID:
+ const userId = req.query["uid"];
+ const excluded = !!req.query["excluded"];
+ GameModel.getByUser(userId, excluded, (err,games) => {
+ access.checkRequest(res, err, games, "Games not found", () => {
+ res.json({games: games});
+ });
+ });
+ }