bloom-backend icon indicating copy to clipboard operation
bloom-backend copied to clipboard

Replace req["user"] with req["userEntity"] in the user.controller.ts

Open eleanorreem opened this issue 7 months ago • 2 comments

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 it user.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 the firebaseId we can use the userId instead to get the user.
  • [ ] In the controller, use the service method user.getUserProfile rather than returning req["user"]. You will need to pass it req["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.

eleanorreem avatar Jul 22 '24 15:07 eleanorreem