Skip to content

Commit

Permalink
pulled changes into this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
divyack2 committed Sep 18, 2024
1 parent 93d05c5 commit 3cd5414
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
29 changes: 26 additions & 3 deletions src/services/checkin/checkin-router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Router } from "express";
import { StatusCodes } from "http-status-codes";
import { ScanValidator, MerchScanValidator } from "./checkin-schema";
import { ScanValidator, MerchScanValidator, EventValidator } from "./checkin-schema";

Check failure on line 3 in src/services/checkin/checkin-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `·ScanValidator,·MerchScanValidator,·EventValidator·` with `⏎····ScanValidator,⏎····MerchScanValidator,⏎····EventValidator,⏎`
import RoleChecker from "../../middleware/role-checker";
import { Role } from "../auth/auth-models";
import { validateQrHash } from "./checkin-utils";
Expand All @@ -23,8 +23,31 @@ checkinRouter.post(
.status(StatusCodes.UNAUTHORIZED)
.json({ error: "QR code has expired" });
}

Check failure on line 26 in src/services/checkin/checkin-router.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `············`
try {
await checkInUserToEvent(eventId, userId);
} catch (error: any) {

Check failure on line 29 in src/services/checkin/checkin-router.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (error instanceof Error && error.message == "IsDuplicate") {
return res.status(StatusCodes.FORBIDDEN).json({error: "IsDuplicate"});

Check failure on line 31 in src/services/checkin/checkin-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `.status(StatusCodes.FORBIDDEN).json({error:·"IsDuplicate"` with `⏎························.status(StatusCodes.FORBIDDEN)⏎························.json({·error:·"IsDuplicate"·`
}
return res.sendStatus(StatusCodes.INTERNAL_SERVER_ERROR);
}

return res.status(StatusCodes.OK).json(userId);
} catch (error) {
next(error);
}
}
);

checkinRouter.post(
"/event",
RoleChecker([Role.Enum.ADMIN, Role.Enum.STAFF]),
async (req, res, next) => {
try {
const { eventId, userId, isCheckin } = EventValidator.parse(req.body);

Check failure on line 48 in src/services/checkin/checkin-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `req.body` with `⏎················req.body⏎············`

await checkInUserToEvent(eventId, userId, true);
await checkInUserToEvent(eventId, userId, isCheckin);

return res.status(StatusCodes.OK).json(userId);
} catch (error) {
Expand Down Expand Up @@ -93,4 +116,4 @@ checkinRouter.post(
}
);

export default checkinRouter;
export default checkinRouter;

Check failure on line 119 in src/services/checkin/checkin-router.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎`
8 changes: 7 additions & 1 deletion src/services/checkin/checkin-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ const MerchScanValidator = z.object({
qrCode: z.string(),
});

export { ScanValidator, MerchScanValidator };
const EventValidator = z.object({
eventId: z.string(),
userId: z.string(),
isCheckin: z.boolean(),
});

export { ScanValidator, MerchScanValidator, EventValidator };

Check failure on line 18 in src/services/checkin/checkin-schema.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎`
4 changes: 2 additions & 2 deletions src/services/checkin/checkin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function checkForDuplicateAttendance(eventId: string, userId: string) {
]);

if (isRepeatEvent || isRepeatAttendee) {
throw new Error("Is Duplicate");
throw new Error("IsDuplicate");
}
}

Expand Down Expand Up @@ -131,4 +131,4 @@ export function validateQrHash(qrCode: string) {
}

return { userId, expTime };
}
}

Check failure on line 134 in src/services/checkin/checkin-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎`

0 comments on commit 3cd5414

Please sign in to comment.