Files
nest-template/src/core/throttler/throttler.module.ts
2026-04-14 11:49:30 +08:00

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 {}