Skip to content

Commit 5c711b5

Browse files
committed
Add some check for page and limit
1 parent 6b2b63f commit 5c711b5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/controllers/interview.controller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ export const getInterviews = async (req: Request, res: Response) => {
66
const page = parseInt(req.query.page as string) || 1;
77
const limit = parseInt(req.query.limit as string) || 10;
88

9+
if(isNaN(page) || page<1){
10+
throw new ApiError("Page must me greater than or equal to 1",400);
11+
}
12+
if(isNaN(limit) || limit<1 || limit>100){
13+
throw new ApiError("Limit must me between 1 to 100",400)
14+
}
15+
916
const { interviews, total } = await interviewService.getInterviews(page, limit);
1017

1118
return res.status(200).json({

0 commit comments

Comments
 (0)