Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 1x 1x 6x 6x 6x 3x 2x 3x | import {BadRequestError} from '@app/errors';
import {InviteService} from '@app/models';
import {RequestHandler} from 'express';
/**
* Handles request for retrieving all invites of a specified group.
* Only works if the logged in user is a member of that group
* @param req - Request
* @param res - Response
* @param next - Next
*/
export const getInvitesForGroupController: RequestHandler =
async (req, res, next) => {
const groupId = parseInt(req.params.groupId, 10);
const user = req.user;
if (!isNaN(groupId) && user) {
const invites = await InviteService.findAllForGroup(user, groupId);
res.send({invites});
} else {
throw new BadRequestError('Missing information');
}
};
|