Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Gzip responses to reduce payload size and speed up clients.
Response Compression is easiest to learn by reading the example, changing it, and observing the result.
import express from 'express';
import compression from 'compression';
const app = express();
app.use(compression()); // gzip responses above a threshold
app.get('/api/report', (req, res) => {
res.json({ rows: Array.from({ length: 1000 }, (_, i) => i) });
});
app.listen(3000);Practice the Response Compression example in a small scratch file, then explain what changed and why.