Skip to content
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

Introduce UserRepository abstraction layer and Introduce Mappers #169

Merged
merged 5 commits into from
Jun 10, 2020

Conversation

JasonChong96
Copy link
Contributor

@JasonChong96 JasonChong96 commented Jun 9, 2020

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:

  • Mapper classes and interfaces have been introduced to map between persistence and dto's.
  • Code coverage increased somehow

Tests

  • Creating URL works
  • Transferring ownership of URL works
  • Editing of URL works
  • Redirect works
  • Toggling state to active/inactive works and is reflected accordingly
  • Repeat all previous steps for files
  • Logging in works
  • Verifying OTP works

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.

@JasonChong96 JasonChong96 requested a review from liangyuanruo June 9, 2020 11:59
@JasonChong96 JasonChong96 marked this pull request as ready for review June 9, 2020 11:59
@yong-jie yong-jie changed the title Introduce UrlRepository abstraction layer and Introduce Mappers Introduce UserRepository abstraction layer and Introduce Mappers Jun 9, 2020
Copy link
Contributor

@liangyuanruo liangyuanruo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm barring one comment

@JasonChong96 JasonChong96 merged commit 40b9d20 into develop Jun 10, 2020
@JasonChong96 JasonChong96 deleted the user-repository branch June 10, 2020 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants