Backend · 15 concepts
Express and building APIs
Write simple, correct Express endpoints and explain routing, middleware, errors, validation, security middleware and shutdown.
Asked in these mock interviews
Part 1 · 5 concepts
Express basics
- 01
The http module under Express
Express is a thin layer over Node's http module: http.createServer gives you a request (a readable stream) and a response (a writable stream) for every request, and…
- 02
Routing, params, query and Router
Express matches routes in the order you register them, by method and path, puts path parameters in req.params and the query string in req.query, and lets you group…
- 03
Middleware and next()
Middleware is a function (req, res, next) that runs in the order it was added; each one either ends the response or calls next() to pass control on, which is how…
- 04
Error handling in Express 4 and 5
Express sends errors to error-handling middleware, the functions with four parameters (err, req, res, next) registered after all routes; in Express 5 a rejected promise…
- 05
What changed in Express 5
Express 5 (first released in late 2024; 5.3.0 is the npm 'latest' in November 2026) needs Node 18+, forwards async errors to error middleware, uses a stricter route…
Part 2 · 5 concepts
Handling requests safely
- 06
Body parsing and validation with zod
Parse the body with express.json() (with a size limit), then validate params, query and body against a schema such as zod and reject bad input with 400 before it…
- 07
CORS and security headers (helmet)
CORS headers tell browsers which other origins may read your API's responses, and helmet sets a group of security headers; neither one authenticates users or stops…
- 08
Rate limiting middleware
Rate limiting caps how many requests a client can make in a time window and answers 429 Too Many Requests with Retry-After; with more than one server instance, the…
- 09
Authentication and authorization middleware
Authentication middleware turns a session cookie or Bearer token into req.user (or answers 401), and authorization checks that this user may do this action on this…
- 10
File uploads: multer and presigned URLs
For uploads, either parse multipart/form-data with multer and strict limits, or better, let the client upload straight to object storage (S3) with a short-lived…
Part 3 · 5 concepts
Structure, logging, testing and shutdown
- 11
Project structure: routes, controllers, services
Keep HTTP details in thin routes and controllers, business rules in services, and database access in repositories, so each layer can be tested and changed without…
- 12
Structured logging and request IDs
Production logs should be structured JSON lines with a level, a timestamp, a request ID and useful fields, written to stdout and collected by the platform, and they…
- 13
Testing APIs with supertest
Test an Express API by importing the app (without calling listen) and sending real HTTP requests with supertest, checking status codes, headers and bodies, with either…
- 14
Graceful shutdown and health checks
On SIGTERM a server should stop accepting new connections, finish the requests already in progress, close database pools and queue workers, and then exit, with a hard…
- 15
Express vs Fastify vs NestJS vs Hono
Express is the simple, unopinionated default; Fastify is faster with built-in schema validation and logging; NestJS adds an opinionated structure with modules…
Your first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.