Categories
Node.js Quick Tips Quick Tips

What are the Express req and res objects?

< 1 min read

Have you ever wondered what the req and res objects in Express actually are?

req

An extended instance of the Node.js core http.IncomingMessage class:

/**
 * Request prototype.
 * @public
 */

var req = Object.create(http.IncomingMessage.prototype)

(Source: expressjs/express/lib/request.js#L26-L31)

res

An extended instance of the Node.js core http.ServerResponse class:

/**
 * Response prototype.
 * @public
 */

var res = Object.create(http.ServerResponse.prototype)

Leave a Reply

Your email address will not be published. Required fields are marked *