Beispiel #1
0
      mongo.games.get(req.params.id, function (err, game) {
        if (err) { return common.handleErr(err, res); }
        if (!game) { return res.sendStatus(404); } //TODO test and repeat that elsewhere

        var view = req.user ? game.toUserView(req.user) : game.toPublicView();

        res.set('Content-Type', 'application/json');
        res.json(_.defaults({ _contentType: 'duelo-game' }, view.toJSON()));
      });
Beispiel #2
0
      mongo.games.create({ players: players }).save(function (err, game) {
        if (err) { return common.handleErr(err, res); }

        res.set('Location', game.selfHref());
        res.sendStatus(201);
      });