Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NDD-178]: 회원 이름 반환 시 DTO로 반환하도록 변경 (0.3h / 1h) #63

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

quiet-honey
Copy link
Collaborator

@quiet-honey quiet-honey commented Nov 16, 2023

NDD-178 Powered by Pull Request Badge

Why

Response의 형태가 반드시 JSON의 형태여야 FE에서의 추가적인 설정이 필요없다는 얘기가 나와서 이를 반영하기 위해 로직 변경

How

원래 string으로 바로 반환했던 로직을 FE의 요청에 맞추어, MemberNicknameResponse라는 객체를 반환하도록 변경하여 최종적으로 JSON 형태의 응답을 FE가 받을 수 있도록 하였다.

// memerNicknameResponse.ts
export class MemberNicknameResponse {
  @ApiProperty(createPropertyOption('foobar', '회원의 닉네임', String))
  private nickname: string;

  constructor(nickname: string) {
    this.nickname = nickname;
  }
}

// member.service.ts
return new MemberNicknameResponse(
      (await this.getMemberByToken(getTokenValue(req))).nickname,
    );

Result

아래 사진처럼 응답이 JSON 형태로 넘어옴을 확인할 수 있다.
image

Prize

모든 응답을 JSON으로 통일함으로써 FE에서의 추가적인 작업을 방지

@quiet-honey quiet-honey self-assigned this Nov 16, 2023
@quiet-honey quiet-honey added BE 백엔드 코드 변경사항 feature 새로운 기능이 추가 된 경우 labels Nov 16, 2023
Copy link
Collaborator

@JangAJang JangAJang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

보통은 같은 이유로 객체형의, 혹은 객체형의 리스트의 응답도 전체적으로 응답 dto로 커버하는 경우도 있던 것 같습니다!! 고생하셨습니다!!

@quiet-honey quiet-honey merged commit 807b395 into dev Nov 17, 2023
1 check passed
@delete-merged-branch delete-merged-branch bot deleted the feature/NDD-178 branch November 17, 2023 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드 코드 변경사항 feature 새로운 기능이 추가 된 경우
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants