ExpressInterview preparation
Intermediate·Concept·2 min read

What happens during an Express request?

Practice this question

Definition:

Express handles requests through a sequence of registered middleware and route handlers. Middleware can inspect or change the request, stop it with a response, or pass it onward. The order of registration matters because later handlers see the result of earlier ones.

Key points:

  • Matching middleware runs in registration order.

  • A route handler calls the service and sends a response.

  • Middleware must send a response or call next(); otherwise the request can hang.

  • A router groups related routes; controllers translate HTTP details while services implement business rules.

Request flow:

  1. Client sends a request; Express matches the registered path and middleware.
  2. Parsing middleware reads permitted input and authentication identifies the caller.
  3. Authorization and validation reject requests that should not continue.
  4. The controller calls business logic in a service.
  5. The service completes database or external work.
  6. A response is sent, or an error is forwarded to error middleware.

Interview point:

  • Explain the full path from request parsing and authentication to validation, business logic and one final response.
Adapted from 02_NODE_EXPRESS_HTTP.md · “What happens during an Express request?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.