Sharkey/src/server/api/endpoints/games/reversi/invitations.ts

21 lines
499 B
TypeScript
Raw Normal View History

2018-07-07 13:01:33 +03:00
import Matching, { pack as packMatching } from '../../../../../models/games/reversi/matching';
import { ILocalUser } from '../../../../../models/user';
2018-03-07 10:48:32 +02:00
2018-07-16 22:36:44 +03:00
export const meta = {
requireCredential: true
};
2018-07-05 20:58:29 +03:00
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
2018-03-07 10:48:32 +02:00
// Find session
const invitations = await Matching.find({
2018-03-29 08:48:47 +03:00
childId: user._id
2018-03-07 11:56:55 +02:00
}, {
sort: {
_id: -1
}
2018-03-07 10:48:32 +02:00
});
// Reponse
res(Promise.all(invitations.map(async (i) => await packMatching(i, user))));
});