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

issue#25 api 리팩토링 #60

Merged
merged 28 commits into from
Dec 25, 2024
Merged

Conversation

ppochaco
Copy link
Member

@ppochaco ppochaco commented Dec 23, 2024

📝 상세 내용

  • swagger-typescript-api 도입
  • next-safe-action 제거
  • query factory 구조 적용
  • /activity 하위의 불필요한 페이지를 제거하기위해, 활동 페이지의 구조를 일부 변경했습니다
    • semester 리다이렉트 페이지는 추후에 따로 이슈를 만들어 수정할 예정입니다
  • 토큰 재발급 로직 버그 수정

#️⃣ 이슈 번호

🔗 참고 자료

📷 스크린샷(선택)

업데이트 된 swagger 명세서 적용하는 방법

  1. npm run swagger-typescript-api 입력
  2. ./src/models에 도메인별로 생성된 class 확인
  3. 프로젝트에 적용할 API method를 주석 포함해서 ./src/service/models/도메인에 추가하기
    1. 새로운 도메인이라면 파일 전체를 붙여넣기
    2. extends HttpClient<SecurityDataType>extends CustomHttpClient<SecurityDataType>로 변경하기
    import { CustomHttpClient } from '../config'
    
    export class Users<
      SecurityDataType = unknown,
    > extends CustomHttpClient<SecurityDataType> {
    
    ...
    
    /**
     * No description
     *
     * @tags 유저 API
     * @name GetMe
     * @summary User Me 정보 조회
     * @request GET:/users/me
     * @secure
     * @response `200` `GetMeData` OK
     */
    getMe = (params: RequestParams = {}) =>
      this.request<GetMeData, any>({
        path: `/users/me`,
        method: 'GET',
        secure: true,
        ...params,
      })
    }
  4. ./src/service/api/도메인에 class로 API 호출하기
      const getUsersMe = async () => {
        const userClient = new Users(AUTHORIZATION_API)
        const response = await userClient.getMe()
      
        return response.data
      }
  5. ./src/models 모든 파일 제거하기

- axios instance를 swagger-typescript-api HttpClient로 생성
- next-safe-action 제거, useMutation 사용
- login api 호출 swagger-typescript-api 사용
- auth interceptor를 적용한 instance 사용가능하게 확장
- fail request가 여러 개 일 때를 대비해 queue로 request 관리
- reissue api 호출 부분 모듈화
- axios instance 자체를 넘기게 수정
- /activity/{activityName} 에서 /activity/{activityId}로 수정
- 규모가 커져서 따로 이슈 생성 후 진행할 예정
This was linked to issues Dec 23, 2024
Copy link
Collaborator

@Dobbymin Dobbymin left a comment

Choose a reason for hiding this comment

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

다시 보면서 생각해보니까 스웨거 관련 api 코드가 엄청 복잡한 느낌은 아니긴하네요. 고생많으셨습니다.

Copy link
Collaborator

@joojjang joojjang left a comment

Choose a reason for hiding this comment

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

확인했습니다~~ 수고하셨어요🌝
Merry Christmas🎅🏻

toast가 공통 컴포넌트군요
api 관련은 /service에서 임포트해서 쓰면 되는 거죠?

@ppochaco
Copy link
Member Author

확인했습니다~~ 수고하셨어요🌝 Merry Christmas🎅🏻

toast가 공통 컴포넌트군요 api 관련은 /service에서 임포트해서 쓰면 되는 거죠?

늦었지만 메리크리스마스🎄💝

toast도 shacn, radix 라이브러리를 사용한 컴포넌트입니당 자세한 사용법은 아래 공식문서 확인해주세욤

넹 맞습니다 /service 폴더가 api 관련 폴더라고 생각하면 됩니다!

@ppochaco
Copy link
Member Author

개발 진행을 위해 먼저 머지하겠습니당

@ppochaco ppochaco merged commit dbd904b into develop Dec 25, 2024
1 check passed
@ppochaco ppochaco deleted the feature/#25-swagger-typescript-api branch December 25, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api 구조 리팩토링 엑세스 토큰 리프레시 오류 수정
3 participants