The core workflow of any Express application revolves around three pillars: initializing the application instance, registering routes mapped to HTTP verbs, and manipulating the Request (req) and Response (res) objects.
An Express application begins by invoking the top-level express() function exported by the module:
Express supports all standard HTTP verbs:
req and res EcosystemExpress decorates the native Node.js request and response objects with convenient helper properties and methods:
req Propertiesreq.method: The HTTP verb (GET, POST, etc.)req.path: The path part of the request URL (e.g., /api/users)req.ip: Client IP addressreq.headers: Key-value map of incoming HTTP headersreq.get(headerName): Case-insensitive header lookup (e.g., req.get('Authorization'))res Methodsres.status(code): Sets the HTTP status code (chainable)res.json(data): Sends JSON response with appropriate headersres.send(body): Sends generic HTTP body (HTML, string, or Buffer)res.sendStatus(code): Sets status code and sends its text representation (e.g., res.sendStatus(404) sends "Not Found")res.redirect(url): Performs HTTP 302/301 redirectionres.set(field, value): Sets an outgoing HTTP headerres object sets the HTTP response code and returns the response in a chainable manner?Authorization header safely regardless of whether the client sent it in upper or lowercase?res.status(204).send() communicate to the client?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Native HTTP Server vs Express Framework Philosophy | Route Parameters, Query Strings & Request Body Parsing |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.