ZA | 25-SDC-July | Luke Manyamazi | Sprint 3 | Middleware Exercises#40
ZA | 25-SDC-July | Luke Manyamazi | Sprint 3 | Middleware Exercises#40Luke-Manyamazi wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
1. Middleware-custom: Express app with two custom-written middlewares (username and JSON array parser) 2. Middleware-offTheShelf: Express app replacing JSON parser with Express's built-in middleware - Both apps handle POST requests and return authentication and subject info messages
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
5 similar comments
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
LonMcGregor
left a comment
There was a problem hiding this comment.
Looking good, though I have a suggestion of something to think about to help practise writing even more reusable middleware
| // Simple string check | ||
| for (let item of req.body) { | ||
| if (typeof item !== 'string') { | ||
| return res.status(400).send('Error: All items must be strings'); |
There was a problem hiding this comment.
What is the goal of this middleware - it seems to do two things.
Here you're combining JSON parsing and checking the input is strings. As middleware aims to allow re-use of code, what change could you make to this that would allow you to re-use these separate checks more easily?
Learners, PR Template
Self checklist
Changelist
I have added code for all middleware exercises
Questions
I do not have any questions.