๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
DemoInstallSign in
Socket

@nestjs/platform-fastify

Package Overview
Dependencies
Maintainers
2
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/platform-fastify

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

11.1.2
latest
Source
npm
Version published
Weekly downloads
335K
-21.22%
Maintainers
2
Weekly downloads
ย 
Created

What is @nestjs/platform-fastify?

@nestjs/platform-fastify is an adapter package for the NestJS framework that allows you to use Fastify as the underlying HTTP server instead of the default Express. Fastify is known for its high performance and low overhead, making it a good choice for applications that require high throughput and low latency.

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

Basic Setup

This code demonstrates how to set up a basic NestJS application using Fastify as the HTTP server. The `FastifyAdapter` is passed to the `NestFactory.create` method to initialize the application with Fastify.

const { NestFactory } = require('@nestjs/core');
const { FastifyAdapter } = require('@nestjs/platform-fastify');
const { AppModule } = require('./app.module');

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

Middleware Integration

This code shows how to integrate middleware in a NestJS application using Fastify. The `app.use` method is used to add a middleware function that logs each incoming request.

const { NestFactory } = require('@nestjs/core');
const { FastifyAdapter } = require('@nestjs/platform-fastify');
const { AppModule } = require('./app.module');

async function bootstrap() {
  const app = await NestFactory.create(AppModule, new FastifyAdapter());
  app.use((req, res, next) => {
    console.log('Request...');
    next();
  });
  await app.listen(3000);
}
bootstrap();

Route Handling

This code demonstrates how to define a simple route in a NestJS application using Fastify. The `ExampleController` class defines a route that responds with 'Hello, Fastify!' when accessed via a GET request.

const { Controller, Get } = require('@nestjs/common');

@Controller('example')
class ExampleController {
  @Get()
  getExample() {
    return 'Hello, Fastify!';
  }
}

const { NestFactory } = require('@nestjs/core');
const { FastifyAdapter } = require('@nestjs/platform-fastify');
const { AppModule } = require('./app.module');

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

Other packages similar to @nestjs/platform-fastify

FAQs

Package last updated on 26 May 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