bloom-backend
bloom-backend copied to clipboard
Replace req["user"] with req["userEntity"] in the user.controller.ts
Overview
Take a read through the umbrella ticket. As a sub task to this ticket we want to phase out the use of req["user"]
from the user.controller.ts. This most popular endpoint is GET /user/me
. For a short period this endpoint will be less performant as the endpoint will be getting the full user profile twice: once in the AuthGuard and once when we hit the service. However, this hopefully will be solved swiftly as the refactor proceeds.
Action Items
- [ ] In the user service, create a almost duplicate function
user.getUserByFirebaseId
and call ituser.getUserProfile
.getUserByFirebaseId
will be refactored to only return the user and will be used by the FirebaseAuthguard. See detials blocked [ticket] (https://github.com/chaynHQ/bloom-backend/issues/454). The difference between the two functions is that instead of using thefirebaseId
we can use theuserId
instead to get the user. - [ ] In the controller, use the service method
user.getUserProfile
rather than returningreq["user"]
. You will need to pass itreq["userEntity"].id
. - [ ] Replace all other instances in the controller of req["user"] with references to req["userEntity"]. These are found in DELETE /user and PATCH /user.
- [ ] Run all tests. This includes Cypress tests as this endpoint is used everywhere.