feat: implements a new GET route /users?profile=true#2201
Merged
iamitprakash merged 12 commits intoRealDevSquad:developfrom Oct 16, 2024
Merged
feat: implements a new GET route /users?profile=true#2201iamitprakash merged 12 commits intoRealDevSquad:developfrom
iamitprakash merged 12 commits intoRealDevSquad:developfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
shubhdevelop
reviewed
Oct 8, 2024
|
@vikasosmium can you please add test coverage? |
Contributor
Author
|
I have added test coverage screenshots. |
shubhdevelop
reviewed
Oct 9, 2024
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
yesyash
reviewed
Oct 10, 2024
yesyash
reviewed
Oct 10, 2024
yesyash
requested changes
Oct 14, 2024
Comment on lines
+119
to
+137
| if (dev) { | ||
| let user; | ||
|
|
||
| try { | ||
| if (req.userData.id) { | ||
| const result = await dataAccess.retrieveUsers({ id: req.userData.id }); | ||
| user = result.user; | ||
| } else { | ||
| return res.boom.badRequest("User ID not provided."); | ||
| } | ||
| } catch (error) { | ||
| logger.error(`Error while fetching user: ${error}`); | ||
| return res.boom.serverUnavailable(INTERNAL_SERVER_ERROR); | ||
| } | ||
|
|
||
| return res.send(user); | ||
| } else { | ||
| return res.boom.badRequest("Route not found"); | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| if (dev) { | |
| let user; | |
| try { | |
| if (req.userData.id) { | |
| const result = await dataAccess.retrieveUsers({ id: req.userData.id }); | |
| user = result.user; | |
| } else { | |
| return res.boom.badRequest("User ID not provided."); | |
| } | |
| } catch (error) { | |
| logger.error(`Error while fetching user: ${error}`); | |
| return res.boom.serverUnavailable(INTERNAL_SERVER_ERROR); | |
| } | |
| return res.send(user); | |
| } else { | |
| return res.boom.badRequest("Route not found"); | |
| } | |
| if (dev) { | |
| if (!req.userData.id) { | |
| return res.boom.badRequest("User ID not provided."); | |
| } | |
| try { | |
| const result = await dataAccess.retrieveUsers({ id: req.userData.id }); | |
| return res.send(result.user); | |
| } catch (error) { | |
| logger.error(`Error while fetching user: ${error}`); | |
| return res.boom.serverUnavailable(INTERNAL_SERVER_ERROR); | |
| } | |
| } else { | |
| return res.boom.badRequest("Route not found"); | |
| } |
Contributor
Author
There was a problem hiding this comment.
Will check this!
Contributor
Author
There was a problem hiding this comment.
I have made the suggested changes.
vikasosmium
commented
Oct 15, 2024
Comment on lines
+119
to
+137
| if (dev) { | ||
| let user; | ||
|
|
||
| try { | ||
| if (req.userData.id) { | ||
| const result = await dataAccess.retrieveUsers({ id: req.userData.id }); | ||
| user = result.user; | ||
| } else { | ||
| return res.boom.badRequest("User ID not provided."); | ||
| } | ||
| } catch (error) { | ||
| logger.error(`Error while fetching user: ${error}`); | ||
| return res.boom.serverUnavailable(INTERNAL_SERVER_ERROR); | ||
| } | ||
|
|
||
| return res.send(user); | ||
| } else { | ||
| return res.boom.badRequest("Route not found"); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Will check this!
| router.get("/userId/:userId", users.getUserById); | ||
| router.patch("/self", authenticate, userValidator.updateUser, users.updateSelf); | ||
| router.get("/", userValidator.getUsers, users.getUsers); | ||
| router.get("/", authenticateProfile(authenticate), userValidator.getUsers, users.getUsers); |
Check failure
Code scanning / CodeQL
Missing rate limiting
prakashchoudhary07
approved these changes
Oct 15, 2024
iamitprakash
approved these changes
Oct 16, 2024
This was referenced Oct 19, 2024
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Date: 08-Oct-2024
Developer Name: Vikas Singh
Design Doc: Deprecate /users/self GET Route and Implement New Replacement Route #2126
Issue Ticket Number
Description
Implements a new route for fetching user data as /users?profile=true
Documentation Updated?
Raised the PR (API Contract): (https://github.com/Real-Dev-Squad/website-api-contracts/pull/191)
Under Feature Flag
Database Changes
Breaking Changes
Development Tested?
Screenshots
Screenshot 1
Test Coverage
1. Unit Test