Skip to content

Conversation

@SaraTahir28
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

This PR includes two working versions of the middleware application as required by the exercise:
1.Original version (manual JSON parsing)
2.Updated version (Express’s built‑in JSON parser)

Questions

I have no Questions. Thankyou.

@SaraTahir28 SaraTahir28 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 2, 2026
@OracPrime OracPrime added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Feb 10, 2026
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

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

Only real issue here is gitignoring package-lock.json, otherwise good


// Middleware - Extracting username

function usernameMiddleware(req, res, next){ //middleware always has three parameters. req from client, res you send back and a next function that passes controls to next middleware

Choose a reason for hiding this comment

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

Sort of. If you know you are the last middleware in the chain ("endware" I guess) then you don't need the next parameter - indeed the last (res,req)=> on a route declaration is just an example of this endware pattern. And there's also a special case middleware for error handling that has four parameters.

Copy link
Author

@SaraTahir28 SaraTahir28 Feb 10, 2026

Choose a reason for hiding this comment

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

Thanks for the clarification.
In this case usernameMiddleware is intended to run before the route handler, so it still needs the next parameter to pass control forward.
I understand the distinction now between middleware (req, res, next) and endware (req, res). Thanks for the explanation.

.gitignore Outdated
@@ -0,0 +1,2 @@
node_modules
package-lock.json No newline at end of file

Choose a reason for hiding this comment

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

You should always check in package-lock into version control. This is what allows someone else to replicate your build. node_modules is definitely an ignore though!

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@OracPrime OracPrime added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Feb 10, 2026
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

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

Speedy changes as a result of code reviews, particularly so speedy that you clearly haven't even run it, often don't end well.

// Middleware - Extracting username

function usernameMiddleware(req, res, next){ //middleware always has three parameters. req from client, res you send back and a next function that passes controls to next middleware
function usernameMiddleware(req, res,){ //no next as we are not passing controls to any other middleware.

Choose a reason for hiding this comment

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

I obviously didn't explain clearly. usernameMiddleware isn't last, because in the route there is the "final" middleware you specify inline - the (req,res)=> bit. So this one does need a next. Not least because you still call it on line 21. If this was in a professional team environment you would be getting an email from me saying "that code you've just pushed to github: have you even run it once?" because line 21 is clearly going to error.

Copy link
Author

Choose a reason for hiding this comment

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

I misunderstood your earlier point about middleware vs endware and removed next incorrectly. I will be careful next time.

@OracPrime OracPrime added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 10, 2026
@SaraTahir28 SaraTahir28 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 10, 2026
@OracPrime OracPrime added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants