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-254]: 개발용 토큰 반환 API 구현 (0.5h / 0.5h) #106

Merged
merged 6 commits into from
Nov 25, 2023

Conversation

quiet-honey
Copy link
Collaborator

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

NDD-254 Powered by Pull Request Badge

Why

DX 향상을 위해 개발용 토큰을 반환하는 API를 구현할 필요가 있기 때문이다.
또한 아래의 API들은 Swagger에서 나타낼 필요가 없기에 제외하였다.

  • / (메인 Default API)
  • DB에 더미데이터를 저장하는 API
  • 개발용 토큰 반환 API

How

팀 구글 이메일로 저장되어 있는 회원은 DB에 1번으로 저장되어 있기에 이를 사용하여 JWT를 만들어 반환

async getDevToken() {
  return this.createToken(1); // 1번은 developndd 이메일로 가입한 개발자용 회원임
}

private async createToken(memberId: number) {
  const accessToken = await this.signToken(memberId, ACCESS_TOKEN_EXPIRES_IN);
  const refreshToken = await this.signToken(
    memberId,
    REFRESH_TOKEN_EXPIRES_IN,
  );
  const token = new Token(refreshToken, accessToken);
  await this.tokenRepository.save(token);
  return accessToken;
}

Result

아래 사진처럼 원하는 대로 Bearer + jwt의 형태로 반환됨을 알 수 있음
image

Prize

FE 개발자들의 DX 향상을 기대할 수 있음
Swagger API Docs에 꼭 필요한 API만 표시

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

cloudflare-workers-and-pages bot commented Nov 25, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: e5a31bf
Status: ✅  Deploy successful!
Preview URL: https://51378308.gomterview.pages.dev
Branch Preview URL: https://feature-ndd-254.gomterview.pages.dev

View logs

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.

LGTM!

@quiet-honey quiet-honey merged commit 97fb03e into dev Nov 25, 2023
2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the feature/NDD-254 branch November 25, 2023 05:07
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