Backend Framework Deep Dive

Express

The minimalist that defined Node.js backends. Tiny core, middleware everywhere — Express is the foundation under thousands of production APIs.

Node.jsJavaScript / TSMinimalistMiddleware-drivenUnopinionated
← Back to Server Side
Quick Facts

At a Glance

Created
2010 · TJ Holowaychuk
Steward
OpenJS Foundation
Style
Minimal, middleware pipeline
License
MIT

Basic Concepts

  • Middleware: functions that receive (req, res, next). Stack them to add behavior — logging, auth, parsing, your handler.
  • Routing maps URL patterns + HTTP verbs to handlers.
  • Unopinionated: Express ships almost nothing — you choose the ORM, validator, auth, templating.
  • Routers let you split the app into modular sub-applications.
  • Vast plugin ecosystem — virtually every common need has an Express middleware.
Syntax

Taste of Express

import express from "express";

const app = express();
app.use(express.json());

// Middleware
app.use((req, res, next) => {
  console.log(`${req.method} ${req.url}`);
  next();
});

// Routes
app.get("/api/products", async (req, res) => {
  const products = await db.query("SELECT * FROM products");
  res.json(products);
});

app.post("/api/products", async (req, res) => {
  const created = await db.insert(req.body);
  res.status(201).json(created);
});

app.listen(3000);
Mechanics

Key Features

Middleware Pipeline

The whole framework is essentially this pattern: every request flows through an ordered chain of (req, res, next) functions. Add cross-cutting concerns (auth, validation, error handling) by inserting middleware at the right spot.

Routers & Modularity

express.Router() lets you split routes by feature: app.use("/users", usersRouter). Combined with TypeScript and Zod, you can get type-safe routes without leaving Express.

Common Middleware
PackagePurpose
express.json / urlencodedParse request bodies.
corsCross-origin support.
helmetSensible HTTP security headers.
morganHTTP request logging.
passport / express-sessionAuthentication strategies.
express-rate-limitBrute-force protection.
Express 5 & Async Errors

Express 5 (current) finally handles thrown errors from async handlers natively — no more try/catch + next(err) boilerplate. Promise rejections automatically bubble to error middleware.

Trade-offs

Strengths & Weaknesses

Strengths
  • Minimal, predictable, infinitely flexible.
  • Largest middleware ecosystem in the Node.js world.
  • Easy to learn — most Node tutorials assume Express.
  • Stable for over a decade.
Weaknesses
  • No structure — large codebases need self-imposed conventions.
  • No built-in DI, validation, or schema handling.
  • Performance trails Fastify and NestJS for heavy throughput.
  • Async ergonomics were rough until v5.
Where It Shines

Sweet Spots

Quick APIs & Prototypes

From npm i express to a working endpoint in minutes.

BFFs & Edge Layers

Backend-for-frontend services that proxy and shape data for SPAs.

Microservices

Tiny, focused services — Express is light enough not to get in the way.

Learning Node.js

The lingua franca of Node tutorials.

Continue

Other Backend Frameworks