-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination & Filters #154
Pagination & Filters #154
Changes from 1 commit
656e0b6
c70bee1
bc7efec
6726bce
e681ee7
f69cf1e
337dd9d
dd1dc4a
06f344d
0cd5393
d21f343
ee6b36d
300c80b
b1f8c25
6e9112c
177ff75
39bff9b
9475148
6bba980
b233372
0b1a977
90ff6d2
140374c
05ebd11
0ee9488
066d721
c8642bf
0fef38b
10fcad0
e510812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,13 +90,13 @@ friendshipRouter.get( | |
); | ||
|
||
friendshipRouter.get( | ||
"/:userId/friend-suggestions/:page", | ||
"/:userId/friend-suggestions", | ||
async (req: Request, res: Response) => { | ||
try { | ||
const session: Session = driver.session(); | ||
const userId: string = req.params.userId; | ||
const page: number = parseInt(req.params.page); | ||
const maxUsersOnPage = 3; | ||
const page: number = parseInt(req.query.page as string); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Casting should be done if you are absolutely sure that the type can be safely cast. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be fixed by now |
||
const maxUsersOnPage: number = parseInt(req.query.maxUsers as string); | ||
|
||
const user = await userExists(session, res, userId); | ||
if ("json" in user) { | ||
|
@@ -122,6 +122,13 @@ friendshipRouter.get( | |
|
||
await session.close(); | ||
|
||
if (users.length === 0) { | ||
return res.status(404).json({ | ||
status: "not found", | ||
message: "No users found with given queries", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other responses have a different format: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you're right 😅 |
||
}); | ||
} | ||
|
||
return res.json({ | ||
status: "ok", | ||
size: allUsers.length, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Response isn't typed so type checking doesn't work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember if it was already in code or I added, but changing the Response to custom would cause to change it everywhere where friends are mentioned, like friend-suggestions or friends endpoints, each to corresponing endpoint. I didn't come to any other conslusion, so if you have any, let me know! 😊