Skip to content

Commit

Permalink
refactor(#58) boardImage(PATCH) 데코레이터
Browse files Browse the repository at this point in the history
  • Loading branch information
2swo committed Nov 6, 2023
1 parent 53bf656 commit 0cfe097
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/boards/controllers/Boards.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ApiGetOneBoard } from '../swagger-decorators/get-one-board-decorators';
import { ApiUpdateBoard } from '../swagger-decorators/patch-board-decorators';
import { ApiTags } from '@nestjs/swagger';
import { ApiDeleteBoard } from '../swagger-decorators/delete-board-decorators';
import { ApiUpdateBoardImage } from '../swagger-decorators/patch-board-images-decorators';

@Controller('boards')
@ApiTags('board API')
Expand Down Expand Up @@ -93,6 +94,7 @@ export class BoardsController {
}

@Patch('/images')
@ApiUpdateBoardImage()
@UseInterceptors(FilesInterceptor('files', 3))
async editBoardImages(
@Headers('access_token') accessToken: string,
Expand Down
4 changes: 2 additions & 2 deletions src/boards/swagger-decorators/patch-board-decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ApiHeaders, ApiOperation, ApiResponse } from '@nestjs/swagger';
export function ApiUpdateBoard() {
return applyDecorators(
ApiOperation({
summary: '보드를 수정 API',
description: '보드 수정 API',
summary: '보드를 수정하는 API',
description: '보드 수정하는 API',
}),
ApiResponse({
status: 200,
Expand Down
85 changes: 85 additions & 0 deletions src/boards/swagger-decorators/patch-board-images-decorators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { applyDecorators } from '@nestjs/common';
import { ApiHeaders, ApiOperation, ApiResponse } from '@nestjs/swagger';

export function ApiUpdateBoardImage() {
return applyDecorators(
ApiOperation({
summary: '보드의 이미지를 수정하는 API',
description: '보드의 이미지를 수정하는 API',
}),
ApiResponse({
status: 200,
description: '보드의 내용을 성공적으로 수정한 경우',
content: {
JSON: {
example: {
message: '이미지 업데이트 및 삭제가 성공적으로 처리되었습니다.',
newImagesArray: [
{
boardId: '업데이트된 보드 아이디',
imageUrl: '새롭게 넣은 이미지 url',
id: '새롭게 넣은 이미지 id',
},
],
},
},
},
}),
ApiResponse({
status: 401,
description: '우리 서비스의 액세스 토큰이 아닌 경우',
content: {
JSON: {
example: { statusCode: 401, message: '유효하지 않은 토큰입니다.' },
},
},
}),
ApiResponse({
status: 403,
description: '만료된 액세스 토큰인 경우',
content: {
JSON: {
example: { statusCode: 403, message: '만료된 토큰입니다.' },
},
},
}),
ApiResponse({
status: 404,
description: 'DB에서 사용자를 찾을 수 없는 경우',
content: {
JSON: {
example: { statusCode: 404, message: '사용자를 찾을 수 없습니다.' },
},
},
}),
ApiResponse({
status: 411,
description: '액세스 토큰이 제공되지 않은 경우',
content: {
JSON: {
example: { statusCode: 411, message: '토큰이 제공되지 않았습니다.' },
},
},
}),
ApiResponse({
status: 500,
description: '보드 수정중 오류가 발생했습니다',
content: {
JSON: {
example: {
statusCode: 500,
message: '보드 수정 중 오류가 발생했습니다.',
},
},
},
}),
ApiHeaders([
{
name: 'access_token',
description: '액세스 토큰',
required: true,
example: '여기에 액세스 토큰',
},
]),
);
}

0 comments on commit 0cfe097

Please sign in to comment.