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

feat: Using neverthrow to explicitly handle errors in AuthController #332

Merged
merged 26 commits into from
Sep 22, 2020

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Sep 17, 2020

Problem

This is an extension PR for #215 to implement explicit error handling to the endpoints.

Solution

Improvements:

  • Add explicit handling using neverthrow's FP-like Result class to return either success oks or error tracks for entire Auth module endpoints

Note that mail related files should technically be updated to be in their own module, and the other mail-related functions should also be converted to use Result. However, that is outside the scope of this PR and should be done in their respective PRs.

Tests

  • Tests are refactored to use new FPfied methods for AuthService and MailService

New dependencies:

  • neverthrow^2.7.1 - used to implement FP-like error handling

@karrui karrui force-pushed the feat/neverthrow branch 12 times, most recently from 5852802 to a519fbe Compare September 18, 2020 01:54
@karrui
Copy link
Contributor Author

karrui commented Sep 18, 2020

I'm so happy this passes now

src/app/modules/auth/auth.controller.ts Outdated Show resolved Hide resolved
src/app/modules/auth/auth.controller.ts Outdated Show resolved Hide resolved
src/app/modules/auth/auth.controller.ts Outdated Show resolved Hide resolved
src/config/logger.ts Show resolved Hide resolved
Copy link
Contributor

@mantariksh mantariksh left a comment

Choose a reason for hiding this comment

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

nicely done! thank you for all the prior research and experimentation as well!

@liangyuanruo liangyuanruo changed the title feat: apply FP using neverthrow to explicitly handle errors in AuthController feat: Using neverthrow to explicitly handle errors in AuthController Sep 21, 2020
@karrui karrui merged commit c64927e into develop Sep 22, 2020
@karrui karrui deleted the feat/neverthrow branch September 22, 2020 01:37
@tshuli tshuli mentioned this pull request Sep 22, 2020
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.

3 participants