-
Notifications
You must be signed in to change notification settings - Fork 264
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
feat: implements a new GET route /users?profile=true #2201
feat: implements a new GET route /users?profile=true #2201
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@vikasosmium can you please add test coverage? |
I have added test coverage screenshots. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
controllers/users.js
Outdated
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"); | ||
} |
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.
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"); | |
} |
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.
Will check this!
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 have made the suggested changes.
controllers/users.js
Outdated
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"); | ||
} |
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.
Will check this!
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