Skip to content

Commit

Permalink
feat: limit transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
jonassimoen committed Mar 1, 2024
1 parent 405938a commit b6cf942
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/controllers/Team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ export const PostTransfersTeamHandler = async (req: any, rep: any) => {
const remainingWeekIds = Array.from(Array(lastWeekId - weekId + 1).keys()).map(x => x + weekId);

if (transfers) {
const alreadyPerformedTransfers = await prisma.transfer.findMany({
where: {
teamId: +req.params.id,
weekId,
}
});

if(process.env.MAX_TRANSFERS && (transfers.length + alreadyPerformedTransfers.length) > +process.env.MAX_TRANSFERS) {
rep.status(403).send({ msg: "Whoaaa, too much transfers!" });
return;
}
const transferCreateInput = transfers.map((transfer: any) => {
return {
teamId: +req.params.id,
Expand Down

0 comments on commit b6cf942

Please sign in to comment.