Two ways to build a Node.js server. Express is a minimal, unopinionated router; NestJS is a structured, TypeScript-first framework with decorators, modules and dependency injection.
An Express server maps a METHOD + path to a handler that returns a response. Pick a method, type a path and "send the request" — the simulated server matches a route and replies.
const express = require('express'); const app = express(); app.use(express.json()); app.get('/api/users', (req, res) => { res.json([{ id: 1, name: 'Ada' }]); }); app.post('/api/users', (req, res) => { res.status(201).json(req.body); }); app.listen(3000);
Express runs every request through a chain of middleware before the handler. Toggle each layer on/off and "send" a request to watch which ones run, in order.
NestJS wraps Node in structure. A @Controller class declares routes with @Get() / @Post() decorators, and a @Module wires everything together. Same idea as Express — far more organised.
// users.controller.ts @Controller('api/users') export class UsersController { constructor(private users: UsersService) {} @Get() findAll() { return this.users.findAll(); } @Post() create(@Body() dto: CreateUserDto) { return this.users.create(dto); } }
The injected UsersService is provided by Nest's dependency-injection container — you never call new UsersService() yourself.
The Nest CLI generates a whole feature for you. Click to run nest g resource products and watch the generated files stream in.
Both run on Node and can serve the same JSON. The difference is philosophy.