diff --git a/BE/src/chat/chats.gateway.ts b/BE/src/chat/chats.gateway.ts index b070772..fa45c04 100644 --- a/BE/src/chat/chats.gateway.ts +++ b/BE/src/chat/chats.gateway.ts @@ -25,14 +25,13 @@ export class ChatsGateway implements OnGatewayConnection, OnGatewayDisconnect { private readonly logger = new Logger('ChatsGateway'); constructor(private readonly chatService: ChatService) {} handleConnection(client: ChatWebSocket, ...args) { - // const { authorization } = args[0].headers; - // const userId = this.chatService.validateUser(authorization); - // if (userId === null) { - // client.close(1008, '토큰이 유효하지 않습니다.'); - // } - // client.userId = userId; - // this.logger.debug(`[${userId}] on connect`, 'ChatsGateway'); - this.logger.debug(`[] on connect`, 'ChatsGateway'); + const { authorization } = args[0].headers; + const userId = this.chatService.validateUser(authorization); + if (userId === null) { + client.close(1008, '토큰이 유효하지 않습니다.'); + } + client.userId = userId; + this.logger.debug(`[${userId}] on connect`, 'ChatsGateway'); } handleDisconnect(client: ChatWebSocket) { diff --git a/BE/src/post/post.controller.ts b/BE/src/post/post.controller.ts index c70f809..6760229 100644 --- a/BE/src/post/post.controller.ts +++ b/BE/src/post/post.controller.ts @@ -4,7 +4,9 @@ import { Get, HttpCode, HttpException, + MaxFileSizeValidator, Param, + ParseFilePipe, Patch, Post, Query, @@ -38,7 +40,12 @@ export class PostController { @Post() @UseInterceptors(FilesInterceptor('image', 12)) async postsCreate( - @UploadedFiles() files: Array, + @UploadedFiles( + new ParseFilePipe({ + validators: [new MaxFileSizeValidator({ maxSize: 1024 * 1024 * 20 })], + }), + ) + files: Array, @MultiPartBody( 'post_info', new ValidationPipe({ validateCustomDecorators: true }), @@ -64,7 +71,11 @@ export class PostController { @UseInterceptors(FilesInterceptor('image', 12)) async postModify( @Param('id') id: number, - @UploadedFiles() + @UploadedFiles( + new ParseFilePipe({ + validators: [new MaxFileSizeValidator({ maxSize: 1024 * 1024 * 20 })], + }), + ) files: Array, @MultiPartBody( 'post_info', diff --git a/BE/src/users/users.controller.ts b/BE/src/users/users.controller.ts index 31ec611..179cd25 100644 --- a/BE/src/users/users.controller.ts +++ b/BE/src/users/users.controller.ts @@ -11,6 +11,8 @@ import { HttpException, UseGuards, Body, + ParseFilePipe, + MaxFileSizeValidator, } from '@nestjs/common'; import { UsersService } from './users.service'; import { CreateUserDto } from './createUser.dto'; @@ -38,7 +40,12 @@ export class UsersController { @Post() @UseInterceptors(FileInterceptor('profileImage')) async usersCreate( - @UploadedFile() file: Express.Multer.File, + @UploadedFile( + new ParseFilePipe({ + validators: [new MaxFileSizeValidator({ maxSize: 1024 * 1024 * 20 })], + }), + ) + file: Express.Multer.File, @MultiPartBody( 'profile', new ValidationPipe({ validateCustomDecorators: true }),