Introduce UserRepository abstraction layer and Introduce Mappers #169
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.
Problem
According to #156, the back-end directory structure beginning to look incoherent and is showing signs of unbridled growth. It is currently a good time for refactoring given the recent expansion of file upload feature.
This PR continues the process of addressing this by creating a UrlRepository which handles the data store of users.
With the introduction of UserRepository, multiple classes need to share usage of mapper functions which map persistence (sequelize) objects to data transfer objects.
Solution
Introduce UserRepository to further abstract the data store from other services.
Improvements:
Tests
Additional notes
There are some consecutive lines such as these
persistenceToDto(urlType: UrlType): StorableUrl
persistenceToDto(urlType: UrlType | null): StorableUrl | null {
in the mappers. These are there to tell the typescript compiler to that the method returns a nullable value if and only if the input is nullable.