Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Express.js · Interface

Application

The Express application object, conventionally called app, is created with express(). It provides the interface for defining routes, configuring middleware, and handling HTTP requests.

How it works

An application is created by calling the top-level express() function. The resulting app object exposes routing and configuration methods, can be referenced through req.app and res.app, and can be passed to a Node.js HTTP server to handle requests.

Syntax

const app = express();

Key points

  • The application instance is conventionally named app.
  • Call the module's top-level express() function to create the application object.
  • Handlers can reach the application through req.app or res.app.
  • Use lowercase app.METHOD() names to route requests by HTTP method.
  • The page documents dedicated entries for common application routing methods, including GET, POST, PUT, and DELETE.
  • The application object is the central interface for defining an Express web service.

Common mistakes

  • Do not confuse app.all() with a normal HTTP-method route: it applies middleware for every request method at its path.

Example: Create and run an Express application

import express, { type Request, type Response } from 'express';

const app = express();

app.get('/health', (_req: Request, res: Response) => {
  res.send('ok');
});

app.listen(3000);

Creates an application, registers a GET route, and starts listening on port 3000.

When to use it

Define method-specific routes

Build an HTTP API

Attach application middleware

Apply cross-cutting request processing

Mount routers and route handlers

Expose reusable route groups

Listen for incoming connections

Run the service

Interview questions

QHow is an Express application created, and what does it provide?

The application object is the app value returned by calling the top-level express() function. It provides the methods used to define routes, configure middleware, and handle HTTP requests.

Follow-up: How can request handlers access the application? The same application is available as req.app and res.app.

QHow do application routing methods work?

app.METHOD() defines a route for the corresponding HTTP method, such as app.get() or app.post(). The method name is written in lowercase even though it represents an uppercase HTTP method.

Follow-up: When should app.all() be used? Use it when middleware must run for all HTTP methods at a specified path rather than only one method.

QHow does an Express application integrate with Node's HTTP server?

An application can be passed to Node's HTTP server because the application object acts as the request handler. Calling app.listen() starts listening for connections using the application.

Follow-up: What is the practical benefit? The same application handler can support both HTTP and HTTPS server setups.

  • express()
  • app.all()
  • app.METHOD()
  • app.use()
  • app.route()
  • app.param()
  • req.app
  • res.app

Source: Application Object · Express.js 4.x. Checked 2026-10-15.