Skip to content

Commit bba633b

Browse files
committed
#1182 - teams endpoint wip
1 parent fb2774d commit bba633b

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/backend/src/controllers/teams.controllers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,12 @@ export default class TeamsController {
6262
next(error);
6363
}
6464
}
65+
66+
static async createTeam(req: Request, res: Response, next: NextFunction) {
67+
try {
68+
69+
} catch (error: unknown) {
70+
next(error);
71+
}
72+
}
6573
}

src/backend/src/routes/teams.routes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,17 @@ teamsRouter.post(
2222
TeamsController.editDescription
2323
);
2424
teamsRouter.post('/:teamId/set-head', intMinZero(body('userId')), validateInputs, TeamsController.setTeamHead);
25+
teamsRouter.post(
26+
'/create',
27+
body('teamId').isString(),
28+
body('teamName').isString(),
29+
intMinZero(body('head')),
30+
body('slackId').isString(),
31+
body('description').isString(),
32+
body('members').isArray(),
33+
body('projects').isArray(),
34+
body('leads').isArray(),
35+
TeamsController.createTeam
36+
);
2537

2638
export default teamsRouter;

src/backend/src/services/teams.services.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,15 @@ export default class TeamsService {
162162

163163
return teamTransformer(updateTeam);
164164
}
165+
/**
166+
* Create a new team.
167+
*/
168+
static async createTeam(submitter: User): Promise<Team> {
169+
if (!isAdmin(submitter.role)) {
170+
throw new AccessDeniedException('You must be an admin or higher to create a new team!');
171+
}
172+
const team = await prisma.team.create({});
173+
174+
return team;
175+
}
165176
}

0 commit comments

Comments
 (0)