Redis storage provider for the @nestjs/throttler package.
yarn add nestjs-throttler-storage-redis ioredis
npm install --save nestjs-throttler-storage-redis ioredis
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 {}
Bugs and features related to the redis implementation are welcome in this repository.
NestJS Throttler Redis Storage is licensed under the MIT license.