Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Where are req and res originally defined?

I'm working through Express and Node videos and have a question on req and res specifically as it relates to middleware.

In Expressjs, we can use app.use() with a middleware function that can eventually be sent to the next middleware function. If we manipulate the req e.g. update a property on req.params that new value for req is used in the second req middleware function.

My question is, where does the originally req and res come from? Where is req being defined and where is it being initialized as an object? Is this all behind the scenes and hard to actually see in Express?