diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-06-17 08:10:54 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-06-17 08:10:54 +0900 |
| commit | 1ef66c962a1cea81dee4f5db32cd011feac7de44 (patch) | |
| tree | 006945b7ae9d437cebb0fabc5eb5a849cff518c5 /src/server/api/endpoints/othello/games.ts | |
| parent | Add missing semicolon (diff) | |
| download | misskey-1ef66c962a1cea81dee4f5db32cd011feac7de44.tar.gz misskey-1ef66c962a1cea81dee4f5db32cd011feac7de44.tar.bz2 misskey-1ef66c962a1cea81dee4f5db32cd011feac7de44.zip | |
reversi :white_flower: :100:
Diffstat (limited to 'src/server/api/endpoints/othello/games.ts')
| -rw-r--r-- | src/server/api/endpoints/othello/games.ts | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/server/api/endpoints/othello/games.ts b/src/server/api/endpoints/othello/games.ts deleted file mode 100644 index 2320a34b04..0000000000 --- a/src/server/api/endpoints/othello/games.ts +++ /dev/null @@ -1,62 +0,0 @@ -import $ from 'cafy'; import ID from '../../../../cafy-id'; -import OthelloGame, { pack } from '../../../../models/othello-game'; - -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'my' parameter - const [my = false, myErr] = $.bool.optional().get(params.my); - if (myErr) return rej('invalid my param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit); - if (limitErr) return rej('invalid limit param'); - - // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $.type(ID).optional().get(params.sinceId); - if (sinceIdErr) return rej('invalid sinceId param'); - - // Get 'untilId' parameter - const [untilId, untilIdErr] = $.type(ID).optional().get(params.untilId); - if (untilIdErr) return rej('invalid untilId param'); - - // Check if both of sinceId and untilId is specified - if (sinceId && untilId) { - return rej('cannot set sinceId and untilId'); - } - - const q: any = my ? { - isStarted: true, - $or: [{ - user1Id: user._id - }, { - user2Id: user._id - }] - } : { - isStarted: true - }; - - const sort = { - _id: -1 - }; - - if (sinceId) { - sort._id = 1; - q._id = { - $gt: sinceId - }; - } else if (untilId) { - q._id = { - $lt: untilId - }; - } - - // Fetch games - const games = await OthelloGame.find(q, { - sort, - limit - }); - - // Reponse - res(Promise.all(games.map(async (g) => await pack(g, user, { - detail: false - })))); -}); |