5req/s universal rate limit
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||
import { ThrottlerModule } from '@nestjs/throttler';
|
||||
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { UsersModule } from './users/users.module';
|
||||
@@ -76,8 +77,8 @@ function validateOptionalProvider(
|
||||
inject: [ConfigService],
|
||||
useFactory: (config: ConfigService) => [
|
||||
{
|
||||
ttl: config.get('THROTTLE_TTL', 60000),
|
||||
limit: config.get('THROTTLE_LIMIT', 10),
|
||||
ttl: config.get('THROTTLE_TTL', 1000),
|
||||
limit: config.get('THROTTLE_LIMIT', 5),
|
||||
},
|
||||
],
|
||||
}),
|
||||
@@ -91,6 +92,12 @@ function validateOptionalProvider(
|
||||
DollsModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
providers: [
|
||||
AppService,
|
||||
{
|
||||
provide: APP_GUARD,
|
||||
useClass: ThrottlerGuard,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
Reference in New Issue
Block a user