patched requireLeaderOfTeam usecases

This commit is contained in:
Laurin
2022-06-05 03:35:37 +02:00
parent 619b46a6aa
commit 1d2794c75c
5 changed files with 61 additions and 27 deletions
+5 -1
View File
@@ -32,7 +32,7 @@ export const getTeams = async (req: Request, res: Response) => {
res.status(200).json({ type: "success", payload: { teams } });
};
export const getTeam = async (req: Request, res: Response) => {
export const getTeam = async (req: Request<{ pid: string }>, res: Response) => {
const { pid } = req.params;
if (req.teamleader?.isAuthenticated) {
@@ -44,6 +44,10 @@ export const getTeam = async (req: Request, res: Response) => {
select: basicTeam,
});
if (!team) {
throw new NotFoundError("team", pid);
}
res.status(200).json({ type: "success", payload: { team } });
};