-
Notifications
You must be signed in to change notification settings - Fork 1
[BE] swagger가 작성한 코드보다 길어질 때
Jungmin edited this page Dec 14, 2023
·
1 revision
| 작성자 : 정민
스웨거를 작성하다 기존 코드보다 길어지는 일이 발생했다.
NestJs에서 제공하는 applyDecorators
를 사용해 코드를 정리했다.
applyDecorators는 복수의 데코레이터를 전달받아 하나의 새로운 데코레이터를 전달하는 함수이다.
@UseGuards(TokenAuthGuard)
@Patch('/user-info')
@ApiBearerAuth('Authorization')
@ApiOperation({
summary: '유저 프로필 변경',
description: '유저의 프로필 정보를 변경합니다.(회원 가입 후 최초 로그인 시 무조건 수행해야함).',
})
@ApiOkResponse({
status: 200,
description: '변경된 정보로 새로운 토큰과 정보를 반환합니다. ',
type: UserInfoResponseDto,
})
@ApiBadRequestResponse({
status: 400,
description: '중복된 닉네임이 들어온 경우 (응답 ex. 중복된 닉네임 입니다.)',
type: String,
})
@ApiUnauthorizedResponse({ description: '유효하지 않은 토큰', type: UnauthorizedException })
async updateUserInfo(
....
}
export const UpdateUserInfoSwagger = () => {
return applyDecorators(
ApiBearerAuth('Authorization'),
ApiOperation({
summary: '유저 프로필 변경',
description:
'유저의 프로필 정보를 변경합니다.(회원 가입 후 최초 로그인 시 무조건 수행해야함).',
}),
ApiOkResponse({
status: 200,
description: '변경된 정보로 새로운 토큰과 정보를 반환합니다. ',
type: UserInfoResponseDto,
}),
ApiBadRequestResponse({
status: 400,
description: '중복된 닉네임이 들어온 경우 (응답 ex. 중복된 닉네임 입니다.)',
type: String,
}),
ApiUnauthorizedResponse({ description: '유효하지 않은 토큰', type: UnauthorizedException })
);
};
@UseGuards(TokenAuthGuard)
@Patch('/user-info')
@UpdateUserInfoSwagger()
async updateUserInfo(
....
}
- [FE] 성능 최적화(디바운스와 쓰로틀링)
- [FE] 채팅-1 채팅을 어떻게 저장할까?
- [FE] 채팅-2 읽지 않은 사람 수를 어떻게 계산할까?
- [FE] 채팅-3 프로필을 보여주는 경우
- [FE] 채팅-4 프로필을 보여주는 경우
- [FE] 채팅-5 프로필을 보여주는 경우
- [FE] 무한스크롤과 IntersectionObserver hook 만들기
- [FE] recoil의 atomFamily 사용하기
- [FE] 반응형 스켈레톤 UI 만들기
- [FE] svg파일을 React에서 컴포넌트처럼 사용하기
- [BE] 채팅방 이벤트 정리
- [BE] 안읽은 사람수 계산하기
- [BE] 크롤러 캐싱
- [BE] 네이버 소셜 로그인
- [BE] 테마 관련 API 캐싱적용
- [BE] S3을 사용해보았어요
- [BE] 성능테스트 환경 구축
- [BE] 채팅 아키텍처 구성하기
- [BE] swagger가 작성한 코드보다 길어질 때
- [BE] @OptionalGuard 데코레이터
4주차 회의록
5주차 회의록
6주차 회의록
- 12.09(토)