Refactor use of getUserDto schema between functions #453
Labels
complexity: advanced
Time needed to do this ticket will be large e.g. 2-3+ days
help wanted
Extra attention is needed
maintenance
Maintenance / chore work
priority: high
Should be prioritized next week or longer.
state: approved
Ready to go. Not blocked or pending.
Milestone
Is your feature request related to a problem?
Most of our backend api requests are related to users, so before the request function is run, we get the current user from the database and make the user data available in the request and following functions. The problem is that we are passing around the user data in a serialized schema
GetUserDto
and instead we should be using the pureUserEntity
schema/types, for all internal functions.GetUserDto
schema should only be used to serialize user data before returning the response, i.e. in the controllerDescribe a solution:
user
from the request context - we are aiming to useuserEntity
instead - see FirebaseAuthGuard.tsx andgetUserByFirebaseId
function in user.service.tsreq['user']
in controllers, instead usingreq['userEntity']
GetUserDto
from our functions/service files, instead usingUserEntity
typeyarn test
andyarn lint
will help discover issuesThis is the first step (see #454) in improving the maintainability and performance of the API and how it handles users. The cleaner typing will help future contributors understand the code!
Additional context and resources:
Tests may need to be fixed following this update - run to check failing tests
Ticket breakdown
#547
#546
#545
The text was updated successfully, but these errors were encountered: