summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/games/reversi/invitations.ts
blob: 39622827597bed45f52672f326f57a3991993869 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Matching, { pack as packMatching } from '../../../../../models/games/reversi/matching';
import { ILocalUser } from '../../../../../models/user';

export const meta = {
	requireCredential: true
};

export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
	// Find session
	const invitations = await Matching.find({
		childId: user._id
	}, {
		sort: {
			_id: -1
		}
	});

	// Reponse
	res(Promise.all(invitations.map(async (i) => await packMatching(i, user))));
});