Express.js: the reference web framework for Node.js

Express.js (May 2010) by TJ Holowaychuk: minimal web framework for Node.js, composable middleware, routing, inspired by Sinatra. MIT licence.

Open SourceWeb Express.jsNode.jsTJ HolowaychukJavaScriptOpen SourceWebBackend

Node.js needs a framework

Node.js (Ryan Dahl, 2009) offers a server-side JavaScript runtime with event loop and non-blocking I/O, but the HTTP API is low-level. Writing REST APIs requires handling routing, body parsing, cookies, middleware. A minimal framework encapsulating common patterns is needed.

The release

Express.js is released on 22 May 2010 by TJ Holowaychuk (prolific author of JavaScript tools, also Mocha, Koa, Stylus). Inspired by Ruby’s Sinatra, it is a minimal framework for Node. MIT licence.

const express = require('express');
const app = express();

app.get('/users/:id', (req, res) => {
  res.json({ id: req.params.id, name: 'Ada' });
});

app.listen(3000);

Features

  • Routingapp.get(), app.post(), routes with parameters and regex
  • Middlewareapp.use() composable pipeline for cross-cutting concerns
  • Request/Response helpersres.json(), res.send(), req.params, req.query, req.body
  • Template engines — Pug (formerly Jade), EJS, Handlebars supported
  • Static filesexpress.static() for assets
  • Error handling — 4-argument middleware

Middleware ecosystem

The Express ecosystem is huge:

  • body-parser — parse JSON/URL-encoded bodies (integrated in Express 4.16+)
  • cors — Cross-Origin Resource Sharing
  • helmet — security headers
  • morgan — HTTP request logger
  • multer — multipart/form-data upload
  • express-session — session management
  • passport — authentication, 500+ strategies (OAuth, JWT, local)
  • express-rate-limit — rate limiting

Impact

Express is defining the middleware pipeline pattern set to influence later frameworks. Together with Node.js and MongoDB it forms the emerging axis of full-JavaScript web stacks.

In the Italian context

Express is rapidly becoming the standard choice for Node.js APIs in Italian JS teams — agencies, startups and public bodies.


References: Express.js (22 May 2010). TJ Holowaychuk. MIT licence. Inspired by Sinatra (Ruby).

Need support? Under attack? Service Status
Need support? Under attack? Service Status