SchoolOfCode / bc17-w4d2-project-i-need-a-rest

bootcamp-17-bc17-w4d2-project-empty-repo created by GitHub Classroom
0 stars 0 forks source link

User Story 7: Improve input validation on all endpoints using Express Validator #7

Closed WaferMouse closed 3 months ago

WaferMouse commented 3 months ago

Description:

As Klara, a Full Stack Engineer at TrackIt I want to be able to use pre-built middleware as much as possible so I can focus on building code that actually delivers the features I need to build.

As Norman, a Tech Lead working across lots of projects I care deeply about standardisation so I want us to use a consistent error format.

Acceptance Criteria:

Given I am a developer who clones down the Activity API repo, When I look at any of the controllers (event handlers), Then I should see that express validator is configured as middleware to check the expected request inputs, Then the controllers are written to check for express validator errors.

Given I am a developer who has made an invalid request, When I inspect the API response, Then the the API call should fail with the correct response code and a clear error message in the format of express validator errors (response.error).

### Tasks for User Story 7
- [x] Identify all controllers (event handlers) within the repo.
- [x] Integrate express-validator middleware to validate incoming requests in each controller.
- [x] Ensure all necessary request inputs are checked using express-validator.
- [x] Modify each controller to check for errors from express-validator.
- [x] Implement logic to handle validation errors by sending appropriate responses.
- [x] Ensure each invalid request hits the respective validation rules.
- [x] Confirm the API responds with the correct HTTP status code on validation failure.
- [x] Ensure the response includes a clear error message formatted according to express-validator standards (e.g., response.error).
faisalagood commented 3 months ago

Closed