Skip to content

Commit

Permalink
Fix casting params for page and maxUsersOnPage
Browse files Browse the repository at this point in the history
  • Loading branch information
Piterson25 committed Mar 25, 2024
1 parent c8642bf commit 10fcad0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions backend/src/routes/usersFriendsRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ friendshipRouter.get(
try {
const session = driver.session();
const userId = req.params.userId;
const page: number = parseInt(req.query.page as string);
const maxUsersOnPage: number = parseInt(req.query.maxUsers as string);
const page: number = parseInt((req.query.page as string) || "");
const maxUsersOnPage: number = parseInt(
(req.query.maxUsers as string) || "",
);

const user = await userExists(session, res, userId);
if ("json" in user) {
Expand Down Expand Up @@ -142,9 +144,10 @@ friendshipRouter.get(
try {
const session: Session = driver.session();
const userId: string = req.params.userId;
const page: number = parseInt(req.query.page as string);
const maxUsersOnPage: number = parseInt(req.query.maxUsers as string);

const page: number = parseInt((req.query.page as string) || "");
const maxUsersOnPage: number = parseInt(
(req.query.maxUsers as string) || "",
);
const user = await userExists(session, res, userId);
if ("json" in user) {
await session.close();
Expand Down
6 changes: 4 additions & 2 deletions backend/src/routes/usersRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ usersRouter.get(
}

try {
const page: number = parseInt(req.query.page as string);
const maxUsersOnPage: number = parseInt(req.query.maxUsers as string);
const page: number = parseInt((req.query.page as string) || "");
const maxUsersOnPage: number = parseInt(
(req.query.maxUsers as string) || "",
);
const session = driver.session();
let allUsers: User[] = [];

Expand Down

0 comments on commit 10fcad0

Please sign in to comment.