Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestjs/platform-express

Package Overview
Dependencies
Maintainers
2
Versions
250
Alerts
File Explorer

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)

  • 7.6.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1M
increased by9.51%
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 17 Jun 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc