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

Refactor /redirect endpoint in preparation for transition page #59

Merged
merged 3 commits into from
May 4, 2020

Conversation

liangyuanruo
Copy link
Contributor

@liangyuanruo liangyuanruo commented May 3, 2020

Problem

Prerequisite for #10 Transition Page.

Improvements

  • Extract separate functions for get/set operations against the
    cache and database

  • Convert callback pattern into Promise-based functions for use with
    async/await (felt it was cleaner to do this than the alternative)

  • Introduce custom error type with NotFoundError

Bugfix

  • Fixed a bug where redirect did not fallback to database if Redis cache
    connectivity failed

Tests

  • Redirects successfully on cache hit
  • Redirects successfully on cache miss and database hit
  • Serves 404 Not Found page when link is not found
  • Cache lookup failure falls back on to database

Improvements

- Extract separate functions for get/set operations against the
cache and database

- Convert callback pattern into Promise-based functions for use with
async/await

- Introduce custom error type with NotFoundError

Bugfix

- Fixed a bug where redirect did not fallback to database if Redis cache
connectivity failed
@liangyuanruo liangyuanruo requested a review from yong-jie May 3, 2020 09:26
Copy link
Member

@yong-jie yong-jie left a comment

Choose a reason for hiding this comment

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

code looks good to me, only one observation being the use of promises over async/await, but not an issue since it's also used in various places throughout the codebase.

@liangyuanruo liangyuanruo merged commit a3d467b into develop May 4, 2020
@liangyuanruo liangyuanruo deleted the refactor-redirect branch May 4, 2020 02:09
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