🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@nestjs/platform-express

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/platform-express

Nest - modern, fast, powerful node.js web framework (@platform-express)

11.1.3
latest
Version published
Weekly downloads
3.5M
-0.17%
Maintainers
2
Weekly downloads
 
Created

What is @nestjs/platform-express?

The @nestjs/platform-express package is a platform-specific module for NestJS that allows the framework to work on top of the Express.js web application framework. It provides the necessary adapters and interfaces to integrate NestJS with Express, enabling developers to leverage the robust features of both NestJS and Express in their applications.

What are @nestjs/platform-express's main functionalities?

HTTP Server

This feature allows you to create an HTTP server using Express as the underlying platform for your NestJS application. The code sample demonstrates how to bootstrap a NestJS application with the Express platform.

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as express from 'express';

async function bootstrap() {
  const server = express();
  const app = await NestFactory.create(AppModule, server);
  await app.listen(3000);
}
bootstrap();

Middleware Configuration

This feature allows you to define and configure middleware in your NestJS application. The code sample shows how to implement a simple logging middleware using the @nestjs/platform-express package.

import { NestMiddleware, MiddlewareFunction, Injectable } from '@nestjs/common';

@Injectable()
export class LoggerMiddleware implements NestMiddleware {
  resolve(...args: any[]): MiddlewareFunction {
    return (req, res, next) => {
      console.log('Request logged:', req.method, req.path);
      next();
    };
  }
}

Request Handling

This feature enables you to handle HTTP requests and interact with the request object provided by Express. The code sample illustrates how to create a controller with a route that returns a string response.

import { Controller, Get, Req } from '@nestjs/common';
import { Request } from 'express';

@Controller('cats')
export class CatsController {
  @Get()
  findAll(@Req() request: Request): string {
    return 'This action returns all cats';
  }
}

Other packages similar to @nestjs/platform-express

FAQs

Package last updated on 06 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts