-
Couldn't load subscription status.
- Fork 0
Get all users route #69
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
base: main
Are you sure you want to change the base?
Conversation
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.
Awesome work! Just a couple quick suggestions to make sure tests pass. also sorry for all the merge commits
| @@ -1 +1 @@ | |||
| DATABASE_URL=postgresql://branch_dev:password@localhost:5432/branch_db | |||
| DATABASE_URL=postgresql://branch_dev:password@localhost:5433/branch_db | |||
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.
Good catch!
|
|
||
| const users = await db | ||
| .selectFrom('branch.users') | ||
| .selectAll() |
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.
| .selectAll() | |
| .selectAll() | |
| .orderBy('user_id', 'asc') |
Need this to make sure tests pass since it depends on users being ordered by id
| expect(body.users.length).toBe(3); | ||
|
|
||
| const firstUser = body.users[0]; | ||
| expect(firstUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
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.
| expect(firstUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
Created at is a little too brittle of a test since we all set up our DBs at different times
| expect(body.users.length).toBe(1); | ||
|
|
||
| const firstUser = body.users[0]; | ||
| expect(firstUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
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.
| expect(firstUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
| expect(secondUser.user_id).toBe(2); | ||
|
|
||
| const thirdUser = body.users[2]; | ||
| expect(thirdUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
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.
| expect(thirdUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
| expect(firstUser.user_id).toBe(1); | ||
|
|
||
| const secondUser = body.users[1]; | ||
| expect(secondUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
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.
| expect(secondUser.created_at).toBe("2025-10-20T21:19:52.978Z"); |
ℹ️ Issue
Closes #49
📝 Description
Added GET /users endpoint to retrieve users from the database. Optional pagination with page number and limit implemented.
Briefly list the changes made to the code:
✔️ Verification
Wrote Jest tests as well as checked different cases on Swagger to ensure it was working.


🏕️ (Optional) Future Work / Notes
Perhaps having user authentication for who can get users?