Express.js Fundamentals
5 min read
Module Overview
What You’ll Learn
- Create a real Express server and define routes on it
- Read data from route parameters, query parameters, and the request body
- Send back JSON responses with the correct HTTP status codes
💡 Why this module matters: Module 4 built an HTTP server from Node’s raw
httpmodule. This module picks up exactly where that left off, Express is the layer that makes routing, request handling, and responses dramatically less tedious to write by hand.
What’s Covered
- Creating an Express server, from an empty project to a running app.
- Routing, matching a URL and HTTP method to the code that handles it.
- Request and response objects, the two objects every route handler receives.
- Route parameters, capturing dynamic segments of a URL.
- Query parameters, reading values from a URL’s
?key=valueportion. - Serving static files, letting Express hand out images, CSS, and other assets directly.
- JSON responses, sending structured data back to a client.
- HTTP status codes, communicating what actually happened, not just returning data.
Hands-On
By the end of this module, you’ll have a real running Express server with multiple routes, reading parameters correctly and responding with proper JSON and status codes.
Next module: rendering real HTML pages from the server, with a view engine.