Skip to content

Commit

Permalink
Merge pull request #104 from ReflectionsProjections/dev/alex/get-points
Browse files Browse the repository at this point in the history
GET /attendee/points
  • Loading branch information
aletya authored Jul 17, 2024
2 parents 33b6e45 + 4bfe90d commit bd3e61c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/services/attendee/attendee-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ attendeeRouter.get(
}
);

attendeeRouter.get(
"/points",
RoleChecker([Role.Enum.USER]),
async (req, res, next) => {
try {
const payload = res.locals.payload;
const userId = payload.userId;

// Check if the user exists in the database
const user = await Database.ATTENDEE.findOne({ userId });

if (!user) {
return res
.status(StatusCodes.NOT_FOUND)
.json({ error: "UserNotFound" });
}

return res.status(StatusCodes.OK).json({ points: user.points });
} catch (error) {
next(error);
}
}
);

attendeeRouter.get(
"/",
RoleChecker([Role.Enum.USER]),
Expand Down

0 comments on commit bd3e61c

Please sign in to comment.