Docs
/
Node Express
Chapter 6
06 — Express Setup & Basics
Core Concepts
- express() — creates an Express application
- app.listen() — starts the HTTP server
- Routing —
app.get(),app.post(),app.put(),app.delete() - req — request object (params, query, body, headers)
- res — response object (json, send, status, redirect)
- Route parameters —
/users/:id→req.params.id - Query strings —
/users?page=1→req.query.page
HTTP Status Codes
| Range | Meaning | Common Codes |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created, 204 No Content |
| 3xx | Redirect | 301 Moved, 304 Not Modified |
| 4xx | Client Error | 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 422 Unprocessable |
| 5xx | Server Error | 500 Internal, 502 Bad Gateway, 503 Service Unavailable |