Skip to content

Commit

Permalink
fix: Throttler 테스트를 위해 오픈
Browse files Browse the repository at this point in the history
  • Loading branch information
yunuo46 committed Dec 13, 2023
1 parent d9b645b commit defee79
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions back/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { AuthModule } from './modules/auth/auth.module';
import typeOrmConfig from './config/orm-config';
import { JwtModule } from '@nestjs/jwt';
import { UserModule } from './modules/user/user.module';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import { ControllerLoggerInterceptor } from './common/interceptors/log.interceptor';
import { ThrottlerModule } from '@nestjs/throttler';
import throttlerConfig from './config/throttler-config';
import { MongooseModule } from '@nestjs/mongoose';
//import { ThrottlerBehindProxyGuard } from './common/guards/throttler.guard';
import { ThrottlerBehindProxyGuard } from './common/guards/throttler.guard';

@Module({
imports: [
Expand All @@ -27,8 +27,8 @@ import { MongooseModule } from '@nestjs/mongoose';
controllers: [AppController],
providers: [
AppService,
{ provide: APP_INTERCEPTOR, useClass: ControllerLoggerInterceptor }
//{ provide: APP_GUARD, useClass: ThrottlerBehindProxyGuard }
{ provide: APP_INTERCEPTOR, useClass: ControllerLoggerInterceptor },
{ provide: APP_GUARD, useClass: ThrottlerBehindProxyGuard }
]
})
export class AppModule {}
4 changes: 2 additions & 2 deletions back/src/config/throttler-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const throttlerConfig: ThrottlerModuleOptions = {
throttlers: [
{
name: 'api',
ttl: 1000, // 5 seconds
limit: 5
ttl: 10000, // 1 seconds
limit: 3
}
],
errorMessage: 'Too Many API Requests'
Expand Down
5 changes: 2 additions & 3 deletions back/src/modules/message/message.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import { JWTRequest } from 'src/common/interface/request.interface';
import { ClovaService } from './clova.service';
import { UpdateMessageLocationsDto } from './dto/update-message-locations.dto';
import { IPLoggerInterceptor } from 'src/common/interceptors/ip-log.interceptor';
//import { Throttle } from '@nestjs/throttler';

import { Throttle } from '@nestjs/throttler';
@ApiTags('Message API')
@Controller('message')
export class MessageController {
Expand Down Expand Up @@ -125,7 +124,7 @@ export class MessageController {
}

@UseGuards(JWTGuard)
//@Throttle({ api: { limit: 10, ttl: 1000 } })
@Throttle({ api: { limit: 10, ttl: 1000 } })
@ApiCookieAuth('access_token')
@Put('/:message_id/open')
@HttpCode(200)
Expand Down
4 changes: 2 additions & 2 deletions back/src/modules/snowball/snowball.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { JWTGuard } from '../../common/guards/jwt.guard';
import { UpdateMainDecoDto } from './dto/update-main-decoration.dto';
import { JWTRequest } from '../../common/interface/request.interface';
import { hasJWTInterceptor } from '../../common/interceptors/hasJwt.interceptor';
//import { Throttle } from '@nestjs/throttler';
import { Throttle } from '@nestjs/throttler';

@ApiTags('Snowball API')
@Controller('snowball')
Expand Down Expand Up @@ -87,7 +87,7 @@ export class SnowballController {
}

@Get('/:snowball_id')
//@Throttle({ api: { limit: 10, ttl: 1000 } })
@Throttle({ api: { limit: 10, ttl: 1000 } })
@UseInterceptors(hasJWTInterceptor)
@HttpCode(200)
@ApiResponse({
Expand Down

0 comments on commit defee79

Please sign in to comment.