Skip to content

LONDON | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 3 | Middleware#66

Open
zohrehKazemianpour wants to merge 3 commits intoCodeYourFuture:mainfrom
zohrehKazemianpour:middleware
Open

LONDON | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 3 | Middleware#66
zohrehKazemianpour wants to merge 3 commits intoCodeYourFuture:mainfrom
zohrehKazemianpour:middleware

Conversation

@zohrehKazemianpour
Copy link

You must title your PR like this:

Region | Cohort | FirstName LastName | Sprint | Assignment Title

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

I finished the middleware exercise. I made two versions to show the difference:

  • app.js: I wrote my own parser using req.on('data') and req.on('end'). This helps me understand how Node.js actually receives data chunks.

  • app-builtin.js: I swapped my manual code for express.json().

I spent some time debugging the curl commands. I found out that:

  1. My manual parser was accepted anything.

  2. express.json() is more strict. It only works if I add the -H "Content-Type: application/json" header to the curl command.
    Logic included

I also added code to check if the user is authenticated with X-Username and made sure the response handles plural words correctly.

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.

1 participant