Socket
Book a DemoInstallSign in
Socket

@voiceflow/nestjs-rate-limit

Package Overview
Dependencies
Maintainers
27
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@voiceflow/nestjs-rate-limit

HTTP request rate-limiting for NestJS.

latest
Source
npmnpm
Version
1.3.4
Version published
Weekly downloads
0
Maintainers
27
Weekly downloads
 
Created
Source

NestJS Rate Limit

HTTP request rate limiting for NestJS.

Installation

yarn add @voiceflow/nestjs-rate-limit

This package also requires you to have @voiceflow/nestjs-redis installed since RateLimitModule uses RedisModule as a dependency.

Usage

Module registration

The redis module can be setup in a couple different ways using forRootAsync:

  • A RateLimitOptions object can be provided via useValue.
  • A useFactory function can be provided to return a RateLimitOptions object (or a promise for one!).
  • A class implementing RateLimitOptions can be provided using useClass.
import { RateLimitModule, RateLimitService, RateLimitOptions } from '@voiceflow/nestjs-rate-limit';

@Module({
  imports: [
    RateLimitModule.forRootAsync({
      imports: [],

      // Union field, one of `useValue`, `useFactory`, or `useClass`:
      useValue: {
        serviceName: 'my-service',
        points: 5,
        duration: 60,
      },
      useFactory: () => getRateLimitConfig(),
      useClass: RateLimitConfigService,
    }),
  ],
})
export class AppModule {}

If you have an existing rate limit options object that you'd like to reuse, you can provide that in forRoot.

const rateLimitOptions = { ... };

@Module({
  imports: [
    RateLimitModule.forRoot(rateLimitOptions),
  ],
})
export class AppModule {}

Once the RateLimitModule is globally registered, RateLimitService can be injected in other providers without having to import RateLimitModule again.

RateLimitGuard

By default no routes will be rate limited. To apply rate limiting to a route or controller use RateLimitGuard:

import { Controller, UseGuards } from '@nestjs/common';
import { RateLimitGuard } from '@voiceflow/nestjs-rate-limit';

@Controller()
@UseGuards(RateLimitGuard)
export class MyController {
  /* ... */
}

Default token extractor

The default token extractor will extract the user's token from the request headers or cookies.

For using cookies you must install cookie-parser and configure it per the NestJS documentation.

Keywords

http

FAQs

Package last updated on 24 Nov 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