21 lines
544 B
TypeScript
21 lines
544 B
TypeScript
import { Module } from '@nestjs/common'
|
|
import { ConfigService } from '@nestjs/config'
|
|
import { ThrottlerModule as NestThrottlerModule } from '@nestjs/throttler'
|
|
|
|
@Module({
|
|
imports: [
|
|
NestThrottlerModule.forRootAsync({
|
|
inject: [ConfigService],
|
|
useFactory: (config: ConfigService) => ({
|
|
throttlers: [
|
|
{
|
|
ttl: config.getOrThrow<number>('THROTTLE_TTL'),
|
|
limit: config.getOrThrow<number>('THROTTLE_LIMIT'),
|
|
},
|
|
],
|
|
}),
|
|
}),
|
|
],
|
|
})
|
|
export class ThrottlerModule {}
|