LearnThatStack Ace your next interview
Backend Development

Express.js.

Start free Change topic Change
Practice · Questions

All questions

Showing of 52
Beginner 14
01

How do you create a basic Express.js application?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Create an application by calling express(), register a route on it, and start the server with app.listen(). Install the package first with npm install express.

const express = require('express');
const app = express();
const PORT = 3000;
app.get('/', (req, res) => {
  res.send('Hello World!');
});
app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});

app.get('/', ...) registers a route handler that runs for GET requests to the root path, and res.send() writes the response. The server listens on port 3000 and answers the root route with Hello World!. Express answers every other path with 404 Not Found. app.listen() returns the Node.js http.Server it creates, which you keep when you need to close the server later.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is middleware in Express.js?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

Middleware is a function that runs during the request-response cycle. It has access to the request object req, the response object res, and the next function. Express passes each request through a chain of these functions, in the order you register them.

A middleware function can:

  • run any code, such as logging or timing
  • change req or res, for example by adding req.user
  • end the cycle by sending a response
  • call next() to hand control to the next function in the chain
// Custom middleware
app.use((req, res, next) => {
  console.log('Time:', Date.now());
  next(); // Call next to continue to the next middleware
});

This one logs a timestamp for every request and then calls next(), so the routes still run. A middleware that neither responds nor calls next() leaves the request hanging.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What are the different types of middleware in Express.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The Express docs list five types of middleware.

  1. Application-level middleware is bound to the app object with app.use().
  2. Router-level middleware works the same way, but is bound to an express.Router() instance with router.use().
  3. Error-handling middleware takes four arguments, (err, req, res, next).
  4. Built-in middleware ships with Express, such as express.static and express.json.
  5. Third-party middleware comes from npm packages, such as morgan, cors and helmet.

The types overlap. Third-party cors() mounted with router.use() is also router-level middleware, and an error handler can sit on the app or on a router.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

How do you handle different HTTP methods in Express.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Express has one routing method per HTTP method, named after it in lowercase, such as app.get(), app.post() and app.delete(). Each takes a path and a handler, and the handler runs only when both the method and the path match.

app.get('/users', (req, res) => {
  res.send('GET request');
});
app.post('/users', (req, res) => {
  res.send('POST request');
});
app.put('/users/:id', (req, res) => {
  res.send('PUT request');
});
app.delete('/users/:id', (req, res) => {
  res.send('DELETE request');
});

Here /users answers GET and POST with different handlers, and /users/:id answers PUT and DELETE for one user. A method that no route handles, such as PATCH on /users, falls through to the 404 response. app.get() also answers HEAD requests for the same path.

To keep every method of one path together, chain them with app.route(), such as app.route('/users').get(...).post(...). Use app.all() when one handler must run for every method.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What is the purpose of next() function in middleware?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

next() passes control to the next middleware or route handler in the chain. A middleware that does not send a response must call it, or the request is left hanging.

app.use((req, res, next) => {
  if (req.headers.authorization) {
    next(); // Continue to next middleware
  } else {
    next(new Error('Unauthorized')); // Trigger error handling
  }
});

next has three common forms:

  • next() moves on to the next matching function.
  • next(err) skips the normal functions and jumps to the error-handling middleware.
  • next('route') skips the remaining callbacks of the current route and moves to the next matching route.

Use return next() when more code follows, so the function stops there.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

How do you serve static files in Express.js?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Use the built-in express.static middleware and point it at a folder. Express then maps request paths to files in that folder, such as images, CSS and JavaScript.

// Serve files from 'public' directory
app.use(express.static('public'));
// Serve with virtual path prefix
app.use('/static', express.static('public'));

With the first line, public/logo.png is served at /logo.png, because the folder name is not part of the URL. The second line adds a virtual path prefix, so the same file is also at /static/logo.png. The folder path is relative to where you start the node process, so path.join(__dirname, 'public') is safer.

When no file matches, the middleware calls next(), so later routes still run. In Express 5, it ignores dotfiles such as .env by default. For high traffic, put a reverse proxy cache in front of the static files.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

What is the difference between req.params, req.query, and req.body?

Part of Pro
08

How do you enable CORS in Express.js?

Part of Pro Visual
09

What is Express Router and why use it?

Part of Pro
10

What is Express.js and why is it used?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Express.js is a minimal web framework for Node.js. It adds routing, middleware and response helpers on top of Node's built-in http module.

With plain http, one callback parses the URL, reads the body stream and sets headers such as Content-Type itself. Express gives you routes such as app.get('/users/:id', handler), a middleware chain for shared steps such as authentication, and helpers such as res.json().

Teams use it for REST APIs and server-rendered sites. Its small core is quick to learn, and middleware packages add most other features. It is unopinionated, so it does not pick a folder structure, a validation library or a database for you. Express 5 is the current major version and needs Node.js 18 or later.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

11

How do you handle 404 errors in Express.js?

Part of Pro Visual
12

What is the difference between res.send(), res.json() and res.end()?

Part of Pro
13

What are template engines and how does Express use them?

Part of Pro
14

What is the purpose of body-parser middleware?

Part of Pro
Intermediate 25
15

How do you implement error handling in Express.js?

Part of Pro Visual
16

What is the difference between app.use() and app.get()?

Part of Pro
17

How do you implement authentication middleware?

Part of Pro
18

How do you handle file uploads in Express.js?

Part of Pro
19

What are Express.js route parameters and how do you validate them?

Part of Pro
20

How do you implement rate limiting in Express.js?

Part of Pro
21

How do you implement session management in Express.js?

Part of Pro Visual
22

What is the difference between cookies and sessions?

Part of Pro
23

How do you implement logging in Express.js?

Part of Pro
24

How do you handle environment variables in Express.js?

Part of Pro
25

What is Express.js middleware execution order?

Part of Pro
26

How do you implement data validation in Express.js?

Part of Pro
27

What is the difference between app.all() and app.use()?

Part of Pro
28

How do you implement request ID tracking across middleware?

Part of Pro Visual
29

What changed between Express 4 and Express 5?

Part of Pro
30

How would you implement role-based access control in Express.js?

Part of Pro
31

How would you structure a large Express.js application?

Part of Pro
32

What is the difference between app.locals and res.locals in Express?

Part of Pro Visual
33

How do you implement request/response compression in Express.js?

Part of Pro
34

How do you implement API documentation with Express.js?

Part of Pro
35

How do you implement security headers in Express.js?

Part of Pro
36

How do you implement health checks and monitoring?

Part of Pro
37

How do you implement content negotiation in Express.js?

Part of Pro
38

How do you implement request/response transformation middleware?

Part of Pro Visual
39

How do you implement testing strategies for Express.js applications?

Part of Pro
Expert 13
40

How do you implement custom middleware for API versioning?

Part of Pro
41

How do you implement graceful shutdown in Express.js?

Part of Pro Visual
42

How do you implement clustering in Express.js for better performance?

Part of Pro Visual
43

How do you implement caching strategies in Express.js?

Part of Pro Visual
44

How do you implement WebSocket support with Express.js?

Part of Pro
45

How do you implement database connection pooling with Express.js?

Part of Pro Visual
46

How do you implement request timeout handling?

Part of Pro Visual
47

How do you implement custom error classes and error handling strategies?

Part of Pro
48

How do you implement database transactions with Express.js?

Part of Pro Visual
49

How do you implement API rate limiting with different strategies?

Part of Pro Visual
50

How do you implement microservices communication with Express.js?

Part of Pro Visual
51

How do you implement performance monitoring and profiling?

Part of Pro
52

When would you choose Express over NestJS or Fastify?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Express.js? Send them this set.
Quick recap

Express.js in pictures.

A quick recap of Express.js in 32 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.

Pro The first chapter is free to play. The other 29 pictures come with Pro.

Get Pro · $10/mo
Pro · $10/mo

45 of 52 Express.js answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git