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

module.exports = (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))));
});