nestjs-throttler-storage-redis

Redis storage provider for the @nestjs/throttler package

Usage no npm install needed!

<script type="module">
  import nestjsThrottlerStorageRedis from 'https://cdn.skypack.dev/nestjs-throttler-storage-redis';
</script>

README

NestJS Throttler Redis Storage

Tests status

Redis storage provider for the @nestjs/throttler package.

Installation

Yarn

  • yarn add nestjs-throttler-storage-redis ioredis

NPM

  • npm install --save nestjs-throttler-storage-redis ioredis

Usage

import { ThrottlerModule } from '@nestjs/throttler';
import { ThrottlerStorageRedisService } from 'nestjs-throttler-storage-redis';

@Module({
  imports: [
    ThrottlerModule.forRoot({
      ttl: 60,
      limit: 5,
      storage: new ThrottlerStorageRedisService(),
    }),
  ],
})
export class AppModule {}
import { ThrottlerModule } from '@nestjs/throttler';
import { ThrottlerStorageRedisService } from 'nestjs-throttler-storage-redis';

@Module({
  imports: [
    ThrottlerModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        ttl: config.get('THROTTLE_TTL'),
        limit: config.get('THROTTLE_LIMIT'),
        storage: new ThrottlerStorageRedisService(),
      }),
    }),
  ],
})
export class AppModule {}

Issues

Bugs and features related to the redis implementation are welcome in this repository.

License

NestJS Throttler Redis Storage is licensed under the MIT license.