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

GETP-179 refactor : 피플 프로필 등록 API 연동 및 리팩토링 #56

Merged
merged 17 commits into from
Aug 9, 2024

Conversation

toothlessdev
Copy link
Member

✨ 구현한 기능

  • 공통 타입을 BaseResponsePaginatedResponse 로 분리하였습니다
  • AxiosError 응답에 대한 에러 핸들링을 Builder 패턴을 통해 구현하였습니다
export const peopleService = {
    // ...
    registerPeopleInfo: async (body: RegisterPeopleInfoRequestBody) => {
        const request = async () => {
            if (!isRequestBodyValid(body)) throw new Error("모든 정보를 입력해주세요.");

            const response = await api.post<RegisterPeopleInfoRequestBody>("/people/me", body);

            return new ExceptionHandler.Builder(response)
                .addCase(400, "필수 항목을 입력해주세요")
                .addCase(404, "등록된 피플정보가 없습니다. 피플 정보를 먼저 등록해주세요")
                .addCase(409, "Conflict")
                .activate();
        };
        return toast.promise(request, {
            pending: "피플 정보 등록 중입니다.",
            success: "피플 정보 등록이 완료되었습니다.",
            error: {
                render({ data }: { data: Error }) {
                    return data.message;
                },
            },
        });
    },
    // ...
}

📢 논의하고 싶은 내용

🎸 기타

  • ExceptionFilter, isRequestValid 에 대한 jest 단위 테스트 코드를 작성하였습니다
  • jest 테스팅 툴을 Github Actions CI 파이프라인에 적용시켰습니다

@toothlessdev toothlessdev merged commit 15855d9 into develop Aug 9, 2024
2 checks passed
@toothlessdev toothlessdev deleted the refactor/GETP-179 branch August 26, 2024 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant