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

[CHE-171] Refactor Catch All Route Handler #140

Conversation

seantokuzo
Copy link
Contributor

Description

As part of the CHE-167 story to refactor backend error handling, this PR:

  • refactors the catch all route handler to use the NotFoundError custom error class
  • refactors the test for the catch all route handler
  • moves the connectDB function call into the startServer function to prevent an open handle / memory leak when using supertest in test suites
  • removes the unused errorController.ts

Jira Task

JIRA TICKET

Testing Instructions

Testing Setup

  • run npm run docker-remove-all to remove local containers/images/volumes
  • run docker build -f Dockerfile-dev -t codehammers/ch-dev-dep-v2 . to build the dev image including the express-async-errors package

Automated Testing:

  • run npm run docker-build-check to run linting and testing

Manual Testing:

  • add - 3000:3000 to the ports array in docker-compose-dev.yml
  • run npm run docker-dev
  • in a browser navigate to http://localhost:3000
  • Should see the serialized response from our NotFoundError class: [{ "message": "Not Found" }] and status of 404
  • in terminal should see our NotFoundError logged with stack trace pointing at **/server/index.ts

Checklist

All Team Members

  • I added a descriptive title to this PR.
  • I filled out the Description, Jira Task, and Testing Instructions sections above.
  • I added or updated [Jest unit tests]for any changes to components, server-side controllers, etc.
  • I ran npm run docker-build-check in my local environment to check that this PR passes all linting checks and unit tests.
  • I did a quick check to make sure my code changes follow the recommended style guide.

Copy link
Contributor

@brok3turtl3 brok3turtl3 left a comment

Choose a reason for hiding this comment

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

Short and sweet - Queue up the next one - Sean SMASH!

@brok3turtl3 brok3turtl3 merged commit b5850de into CHE-167/story/BE-Refactor-Error-Handling Jun 11, 2024
1 check passed
@brok3turtl3 brok3turtl3 deleted the CHE-171/subtask/Refactor-Catch-All-Route-Handler branch June 11, 2024 10:55
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