Skip to content

Commit

Permalink
asdfsadf
Browse files Browse the repository at this point in the history
  • Loading branch information
aletya committed Jan 25, 2024
1 parent 8d77237 commit c06071c
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/services/mentor/mentor-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const mentorRouter: Router = Router();
* {"error": "InvalidPermission"}
*/
mentorRouter.post("/", strongJwtVerification, async (req: Request, res: Response, next: NextFunction) => {
const mentorName: string | undefined = req.body.mentorName;
const mentorName: string | undefined = req.body.mentorName;
const payload: JwtPayload = res.locals.payload as JwtPayload;

Expand All @@ -64,7 +63,6 @@ mentorRouter.post("/", strongJwtVerification, async (req: Request, res: Response
//generate mentorId, add document to database, return generated document in response
const mentorId: string = crypto.randomBytes(Config.MENTOR_BYTES_GEN).toString("hex");

const officeHours: OfficeHoursFormat = { mentorId: mentorId, mentorName: mentorName, attendees: [] };
const officeHours: OfficeHoursFormat = { mentorId: mentorId, mentorName: mentorName, attendees: [] };

const newOfficeHours = await Models.MentorOfficeHours.create(officeHours);
Expand Down Expand Up @@ -117,13 +115,11 @@ mentorRouter.get("/", strongJwtVerification, async (_: Request, res: Response, n

const officeHours: OfficeHoursFormat[] | null = await Models.MentorOfficeHours.find();

if (!officeHours) {
if (!officeHours) {
return next(new RouterError(StatusCode.ServerErrorInternal, "InternalError"));
}

return res.status(StatusCode.SuccessOK).send(officeHours);
return res.status(StatusCode.SuccessOK).send(officeHours);
});

/**
Expand Down Expand Up @@ -156,7 +152,6 @@ mentorRouter.get("/", strongJwtVerification, async (_: Request, res: Response, n
* {"error": "InvalidPermission"}
*/
mentorRouter.delete("/", strongJwtVerification, async (req: Request, res: Response, next: NextFunction) => {
const mentorId: string | undefined = req.body.mentorId;
const mentorId: string | undefined = req.body.mentorId;
const payload: JwtPayload = res.locals.payload as JwtPayload;

Expand All @@ -170,7 +165,6 @@ mentorRouter.delete("/", strongJwtVerification, async (req: Request, res: Respon

const officeHours: OfficeHoursFormat | null = await Models.MentorOfficeHours.findOne({ mentorId: mentorId });

if (!officeHours) {
if (!officeHours) {
return next(new RouterError(StatusCode.ClientErrorBadRequest, "MentorNotFound"));
}
Expand Down Expand Up @@ -224,7 +218,6 @@ mentorRouter.delete("/", strongJwtVerification, async (req: Request, res: Respon
* {"error": "AlreadyCheckedIn"}
*/
mentorRouter.post("/attendance/", strongJwtVerification, async (req: Request, res: Response, next: NextFunction) => {
const mentorId: string | undefined = req.body.mentorId;
const mentorId: string | undefined = req.body.mentorId;
const payload: JwtPayload = res.locals.payload as JwtPayload;

Expand All @@ -238,13 +231,11 @@ mentorRouter.post("/attendance/", strongJwtVerification, async (req: Request, re

const officeHours: OfficeHoursFormat | null = await Models.MentorOfficeHours.findOne({ mentorId: mentorId });

if (!officeHours) {
if (!officeHours) {
return next(new RouterError(StatusCode.ClientErrorBadRequest, "MentorNotFound"));
}

// Checks whether the attendee has already checked in for the office hours
if (officeHours.attendees.includes(payload.id)) {
if (officeHours.attendees.includes(payload.id)) {
return next(new RouterError(StatusCode.ClientErrorBadRequest, "AlreadyCheckedIn"));
}
Expand Down

0 comments on commit c06071c

Please sign in to comment.