-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(users): divide swagger decorators to docs file
- Loading branch information
1 parent
07ac573
commit 2e00720
Showing
13 changed files
with
326 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MethodNames } from '@/common/types/method'; | ||
import { applyDocs } from '@/utils/docs.utils'; | ||
import { ApiOperation } from '@nestjs/swagger'; | ||
import { ApiAuthResponse } from '@/common/decorators/api-auth-response.dto'; | ||
import { ApiResponseFromMetadata } from '@/common/decorators/api-response-from-metadata.decorator'; | ||
import { UsersCreateController } from '../controllers/users-create.controller'; | ||
|
||
type UsersCreateEndpoints = MethodNames<UsersCreateController>; | ||
|
||
const UsersCreateDocsMap: Record<UsersCreateEndpoints, MethodDecorator[]> = {}; | ||
|
||
export const UsersCreateDocs = applyDocs(UsersCreateDocsMap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { MethodNames } from '@/common/types/method'; | ||
import { applyDocs } from '@/utils/docs.utils'; | ||
import { ApiNoContentResponse, ApiOperation } from '@nestjs/swagger'; | ||
import { ApiAuthResponse } from '@/common/decorators/api-auth-response.dto'; | ||
import { ApiResponseFromMetadata } from '@/common/decorators/api-response-from-metadata.decorator'; | ||
import { UsersDeleteController } from '../controllers/users-delete.controller'; | ||
import { UsersDeleteService } from '../services/users-delete.service'; | ||
import { HttpCode } from '@nestjs/common'; | ||
|
||
type UsersDeleteEndpoints = MethodNames<UsersDeleteController>; | ||
|
||
const UsersDeleteDocsMap: Record<UsersDeleteEndpoints, MethodDecorator[]> = { | ||
deleteUser: [ | ||
ApiOperation({ | ||
summary: '회원 탈퇴(soft delete)', | ||
description: '회원을 탈퇴하고 연동된 게시글과 댓글을 soft delete한다.', | ||
}), | ||
ApiAuthResponse(), | ||
HttpCode(204), | ||
ApiNoContentResponse(), | ||
ApiResponseFromMetadata([ | ||
{ service: UsersDeleteService, methodName: 'deleteUser' }, | ||
]), | ||
], | ||
}; | ||
|
||
export const UsersDeleteDocs = applyDocs(UsersDeleteDocsMap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { MethodNames } from '@/common/types/method'; | ||
import { applyDocs } from '@/utils/docs.utils'; | ||
import { ApiOkResponse, ApiOperation } from '@nestjs/swagger'; | ||
import { ApiAuthResponse } from '@/common/decorators/api-auth-response.dto'; | ||
import { ApiResponseFromMetadata } from '@/common/decorators/api-response-from-metadata.decorator'; | ||
import { UsersReadController } from '../controllers/users-read.controller'; | ||
import { UserFollowingResponseDto } from '../dtos/response/user-following-response.dto'; | ||
import { HttpCode } from '@nestjs/common'; | ||
import { UsersReadService } from '../services/users-read.service'; | ||
import { UserDto } from '../dtos/common/user.dto'; | ||
|
||
type UsersReadEndpoints = MethodNames<UsersReadController>; | ||
|
||
const UsersReadDocsMap: Record<UsersReadEndpoints, MethodDecorator[]> = { | ||
getUsersByName: [ | ||
ApiOperation({ | ||
summary: '이름이 포함된 유저 검색', | ||
description: '이름에 username이 포함된 유저를 검색한다.', | ||
}), | ||
ApiOkResponse({ | ||
description: '조회 성공', | ||
type: [UserFollowingResponseDto], | ||
}), | ||
HttpCode(200), | ||
ApiResponseFromMetadata([ | ||
{ service: UsersReadService, methodName: 'findUsersByName' }, | ||
]), | ||
], | ||
getUserById: [ | ||
ApiOperation({ | ||
summary: '특정 유저 프로필 조회(id)', | ||
description: 'id가 일치하는 유저 프로필을 조회한다.', | ||
}), | ||
ApiOkResponse({ description: '조회 성공', type: UserDto }), | ||
HttpCode(200), | ||
ApiResponseFromMetadata([ | ||
{ service: UsersReadService, methodName: 'findUserById' }, | ||
]), | ||
], | ||
getUserByHandle: [ | ||
ApiOperation({ | ||
summary: '특정 유저 프로필 조회(handle)', | ||
description: 'handle이 일치하는 유저 프로필을 조회한다.', | ||
}), | ||
ApiOkResponse({ description: '조회 성공', type: UserDto }), | ||
HttpCode(200), | ||
ApiResponseFromMetadata([ | ||
{ service: UsersReadService, methodName: 'findUserByHandle' }, | ||
]), | ||
], | ||
getMyProfile: [ | ||
ApiOperation({ | ||
summary: '로그인된 유저의 프로필 불러오기', | ||
description: '로그인된 유저의 프로필을 불러온다.', | ||
}), | ||
ApiAuthResponse(), | ||
ApiOkResponse({ description: '불러오기 완료', type: UserDto }), | ||
HttpCode(200), | ||
ApiResponseFromMetadata([ | ||
{ service: UsersReadService, methodName: 'findUserById' }, | ||
]), | ||
], | ||
}; | ||
|
||
export const UsersReadDocs = applyDocs(UsersReadDocsMap); |
Oops, something went wrong.