0.4.1 • Published 2 years ago
@chienchheung/nestjs-throttler-storage-redis v0.4.1
NestJS Throttler Redis Storage for @nestjs/throttler ^3.0.0
Redis storage provider for the @nestjs/throttler package.
Installation
Yarn
yarn add @chienchheung/nestjs-throttler-storage-redis ioredis
NPM
npm install --save @chienchheung/nestjs-throttler-storage-redis ioredis
Usage
import { ThrottlerModule } from '@nestjs/throttler';
import { ThrottlerStorageRedisService } from '@chienchheung/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 '@chienchheung/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.