Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
divyack2 committed Sep 18, 2024
1 parent 3cd5414 commit 38cee76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions src/services/checkin/checkin-router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Router } from "express";
import { StatusCodes } from "http-status-codes";
import { ScanValidator, MerchScanValidator, EventValidator } from "./checkin-schema";
import {
ScanValidator,
MerchScanValidator,
EventValidator,
} from "./checkin-schema";
import RoleChecker from "../../middleware/role-checker";
import { Role } from "../auth/auth-models";
import { validateQrHash } from "./checkin-utils";
Expand All @@ -23,12 +27,14 @@ checkinRouter.post(
.status(StatusCodes.UNAUTHORIZED)
.json({ error: "QR code has expired" });
}

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

Check failure on line 33 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"});
return res
.status(StatusCodes.FORBIDDEN)
.json({ error: "IsDuplicate" });
}
return res.sendStatus(StatusCodes.INTERNAL_SERVER_ERROR);
}
Expand All @@ -45,7 +51,9 @@ checkinRouter.post(
RoleChecker([Role.Enum.ADMIN, Role.Enum.STAFF]),
async (req, res, next) => {
try {
const { eventId, userId, isCheckin } = EventValidator.parse(req.body);
const { eventId, userId, isCheckin } = EventValidator.parse(
req.body
);

await checkInUserToEvent(eventId, userId, isCheckin);

Expand Down Expand Up @@ -116,4 +124,4 @@ checkinRouter.post(
}
);

export default checkinRouter;
export default checkinRouter;
2 changes: 1 addition & 1 deletion src/services/checkin/checkin-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ const EventValidator = z.object({
isCheckin: z.boolean(),
});

export { ScanValidator, MerchScanValidator, EventValidator };
export { ScanValidator, MerchScanValidator, EventValidator };
2 changes: 1 addition & 1 deletion src/services/checkin/checkin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ export function validateQrHash(qrCode: string) {
}

return { userId, expTime };
}
}

0 comments on commit 38cee76

Please sign in to comment.