Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
23dbe48
feat: 스토리북 초기 설정
Hys-Lee May 21, 2025
698ed91
chore: 로컬 환경 설정 gitignore에 추가
Hys-Lee May 21, 2025
b6cb35d
feat: 디자인 토큰 tailwind 적용 설정
Hys-Lee May 22, 2025
55f4a75
Merge branch 'main' of upstream
Hys-Lee May 22, 2025
2763cf3
Merge branch 'main' into design
Hys-Lee May 22, 2025
cf2157a
feat: 스토리북 배포용 공용 컴포넌트 설정
Hys-Lee May 22, 2025
4ec8eaf
feat: tailwind설정에 postcss관련 설정 임시 복원 및 storybook 배포 설정
Hys-Lee May 22, 2025
2b3894e
feat: 스토리북 배포 관련 설정 추가
Hys-Lee May 22, 2025
d1ca615
feat: 디자인 시스템 스토리북 초기 및 테스트용 설정
Hys-Lee May 22, 2025
0a0ea18
feat: 프리티어 및 린트 설치 및 설정 (임시)
Hys-Lee May 22, 2025
eda3e43
style: 린트 및 프리티어로 인한 코드 스타일 변경
Hys-Lee May 22, 2025
86acdfe
feat: 디자인 시스템 스토리북 배포 설정 수정
Hys-Lee May 22, 2025
978b3aa
feat: token 변환 설정파일 수정
Hys-Lee May 24, 2025
a16fd87
docs: 디자인 시스템 관련 리드미 템플릿 수정
Hys-Lee May 24, 2025
ee6afc7
feat: 디자인 시스템 패키지 배포 테스트 성공
Hys-Lee May 24, 2025
70ebaa3
chore: tailwind/postcss 버전 복구
Hys-Lee May 24, 2025
bcc1cd5
feat: 스토리북 스타일 autodocs처리
Hys-Lee May 24, 2025
7d5250b
docs: 디자인 시스템 관련 문서들 정리(임시)
Hys-Lee May 24, 2025
02b17e6
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee May 24, 2025
7041351
pull main
Hys-Lee May 24, 2025
5bf678b
feat: 토큰 설정 및 스토리북 배포 설정 수정
Hys-Lee May 24, 2025
5104f2a
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee May 25, 2025
df656bb
Merge branch 'main' into design
Hys-Lee May 25, 2025
a5446c8
feat: 빌드 관련 tailwindcss/postcss 버전 수정 및 gitignore 포함
Hys-Lee May 25, 2025
fabde4e
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee May 25, 2025
68ce4ea
feat: ci linux환경에서의 스토리북 빌드 관련 패키지 설정 수정
Hys-Lee May 26, 2025
21316d4
Merge branch 'design' into main
Hys-Lee May 26, 2025
272432d
Merge branch 'design'
Hys-Lee May 26, 2025
2e05c03
feat: 디자인 시스템 스토리북 예시 수정
Hys-Lee May 26, 2025
583c613
feat: zustand설치
Hys-Lee May 26, 2025
d29eeff
feat: 상현 개인 레포에서 스토리북 배포 동작하도록 수정
Hys-Lee May 26, 2025
7a7a68a
feat: deploy-storybook path에 자기자신 포함해, 변경 시 동작하도록 수정
Hys-Lee May 26, 2025
3136c68
fix: deploy-storybook path경로 수정
Hys-Lee May 26, 2025
8801660
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 5, 2025
7c3e9c2
feat: TodoItem 임시 제작
Hys-Lee Jun 8, 2025
f6ba2e6
feat: GoalMenu 임시 제작
Hys-Lee Jun 8, 2025
e40ad7b
feat: GoalInfo 임시 제작
Hys-Lee Jun 8, 2025
3f07377
feat: Calendar 임시 제작
Hys-Lee Jun 8, 2025
5c7a59d
feat: Chromatic UI 테스팅 github action 실험 적용
Hys-Lee Jun 8, 2025
3dc406c
feat: chromatic 설치
Hys-Lee Jun 8, 2025
b2629d4
feat: chromatic ci 관련 yarn->npm으로 변경
Hys-Lee Jun 8, 2025
dfac342
feat: chromatic 실험용 Test 컴폰너트 ui 변경
Hys-Lee Jun 8, 2025
f065d94
feat: chromatic github action 패키지 버전 수정
Hys-Lee Jun 8, 2025
525b888
feat: chromatic ci 중단 옵션 수정
Hys-Lee Jun 8, 2025
8bf61b6
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 8, 2025
f08aa2a
Merge branch 'main' into design
Hys-Lee Jun 8, 2025
08b4560
feat: upstream PR에 대해 작동하도록 수정
Hys-Lee Jun 8, 2025
ee7a20e
feat: 크로마틱 연동 테스트
Hys-Lee Jun 10, 2025
1eb042b
feat: 스토리북 plop통한 템플릿 생성 기능 추가
Hys-Lee Jun 10, 2025
396aab4
docs: 스토리북 Intro 문서 수정
Hys-Lee Jun 10, 2025
9387475
feat: 크로마틱 연동 upstream에 적용하도록 수정
Hys-Lee Jun 10, 2025
ab5fa12
docs: 스토리북 Intro 문구 수정
Hys-Lee Jun 10, 2025
8ee477b
docs: 스토리북 intro 스타일 다듬기
Hys-Lee Jun 10, 2025
d294635
docs: 스토리북 버전 및 change log관련 문구 수정
Hys-Lee Jun 10, 2025
55a220a
feat: 스토리북 배포 주소 추가
Hys-Lee Jun 10, 2025
f07a016
docs: 스토리북 intro 문서 스타일 수정.
Hys-Lee Jun 10, 2025
e1b6af9
docs: 프로젝트 README에 디자인시스템 배포 페이지 추가
Hys-Lee Jun 10, 2025
891c5e5
docs: 스토리북 Intro 스타일 수정
Hys-Lee Jun 10, 2025
c2f7bec
docs: 프로젝트 README에 디자인시스템 배포 페이지 추가
Hys-Lee Jun 10, 2025
08de64e
Merge branch 'design'
Hys-Lee Jun 11, 2025
3f3ad2d
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 11, 2025
841ce46
Merge branch 'main' into shared-components
Hys-Lee Jun 11, 2025
3d64154
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 12, 2025
a63168c
Merge branch 'main' into shared-components
Hys-Lee Jun 12, 2025
c24eb66
feat: svg처리를 위해 설정 수정
Hys-Lee Jun 12, 2025
c06b809
feat: 디자인 토큰 primitive도 추가
Hys-Lee Jun 12, 2025
7735aac
feat: Calendar 완성
Hys-Lee Jun 12, 2025
b0e2d99
feat: Calendar 컴포넌트 prop 수정 및 타입 정리 스토리에 상호작용 가능하게 처리
Hys-Lee Jun 12, 2025
57e718b
feat: GoalInfo 컴포넌트 제작 완료
Hys-Lee Jun 13, 2025
99ac5b6
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 13, 2025
e459ea9
Merge branch 'main' into shared-components
Hys-Lee Jun 13, 2025
46a633e
feat: Calendar 화살표 기능 수정
Hys-Lee Jun 13, 2025
1589563
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 13, 2025
6a2f808
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 13, 2025
3378eba
Merge branch 'main' into shared-components
Hys-Lee Jun 13, 2025
88cdf21
feat: TodoItem 제출 시의 표정 정리 제외 완성
Hys-Lee Jun 14, 2025
886683a
feat: 커스텀 체크박스 완성
Hys-Lee Jun 14, 2025
6d1f920
feat: GoalMenu 수정 및 완성
Hys-Lee Jun 14, 2025
f1962b4
feat: GoalMenu 스토리북 설명 추가
Hys-Lee Jun 14, 2025
25b16f7
feat: TodoItem 비동기 고려 수정
Hys-Lee Jun 14, 2025
5ecb6a1
feat: ToolTip 완성
Hys-Lee Jun 14, 2025
81ce28d
feat: Tooltip 스토리북 사이드바 경로 변경
Hys-Lee Jun 14, 2025
b303a5a
feat: Moti svg 크기 변하도록 수정
Hys-Lee Jun 14, 2025
02a378e
feat: Banner 컴포넌트 완성
Hys-Lee Jun 14, 2025
f5d3ce0
feat: Banner 스토리북 사이드바 경로 수정
Hys-Lee Jun 14, 2025
4bd07bb
feat: svg 크기 변경 가능하도록 수정 및 기존 TodoItem에서 크기 적용
Hys-Lee Jun 14, 2025
081e628
feat: FloatingButton 컴포넌트 완성
Hys-Lee Jun 14, 2025
ad55d80
feat: FloatingButton 스토리 사이드바 경로 수정
Hys-Lee Jun 14, 2025
25a404b
Trigger CI/CD for redeploy
Hys-Lee Jun 15, 2025
23bc5da
Trigger CI/CD for storybook redeploy
Hys-Lee Jun 15, 2025
b1b54d8
Merge branch 'main' into shared-components
Hys-Lee Jun 15, 2025
af4bcf6
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 15, 2025
7c97603
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 15, 2025
dbd560f
Merge branch 'main' into shared-components
Hys-Lee Jun 15, 2025
a5dbc27
feat: Toggle 컴포넌트 완성
Hys-Lee Jun 15, 2025
35ed3e7
feat: Checkbox 컴포넌트 호버링 케이스 추가
Hys-Lee Jun 15, 2025
d494c02
feat: 스토리북 배포 ci 관련 캐싱 삭제 및 cleanup 동작 추가
Hys-Lee Jun 15, 2025
70f4784
Merge branch 'main' into shared-components
Hys-Lee Jun 15, 2025
429d95a
feat: ProgressBar 완성
Hys-Lee Jun 15, 2025
16086b3
feat: ProgressBar 스토리 사이드바 경로 변경
Hys-Lee Jun 15, 2025
f8a02ca
feat: TextField 컴포넌트 완성
Hys-Lee Jun 16, 2025
fa8fa26
feat: TextField 스토리북 불필요 부분 삭제
Hys-Lee Jun 16, 2025
a9ba7b5
fix: shared components 빌드 에러 수정
Hys-Lee Jun 16, 2025
bf28c96
feat: PR 관련 안정성 수정
Hys-Lee Jun 16, 2025
29b3084
feat: 공통 컴포넌트들 중 일부 RCC로 수정 및 lint관련 빌드 에러 수정
Hys-Lee Jun 17, 2025
bcf29c9
feat: TodoItem 라벨 클릭 이벤트 수정
Hys-Lee Jun 18, 2025
6618578
feat: TodoItem 스토리 '오늘날짜' 고정 값으로 변경
Hys-Lee Jun 18, 2025
7048996
feat: TodoItem 스토리 날짜 고정
Hys-Lee Jun 18, 2025
d313a9c
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 18, 2025
6650769
feat: TodoList 모달 및 fetch제외 완성
Hys-Lee Jun 18, 2025
dc5d6c6
feat: 메인 페이지 제작중
Hys-Lee Jun 20, 2025
180e722
feat: 메인 페이지 제작에 필요한 컴포넌트 추가 제작
Hys-Lee Jun 20, 2025
049b50d
feat: 일부 공유 컴포넌트 반응형으로 수정
Hys-Lee Jun 20, 2025
5d0dc3d
feat: 메인페이지 추가 컴포넌트 AppBar 제작
Hys-Lee Jun 20, 2025
2daeacb
Merge branch 'main-components' into main-page
Hys-Lee Jun 20, 2025
97d306a
Merge branch 'main' into shared-components
Hys-Lee Jun 20, 2025
dea5eb8
Merge branch 'shared-components' into main-page
Hys-Lee Jun 20, 2025
66c0a63
feat: msw 적용하기
Hys-Lee Jun 20, 2025
e76c667
feat: 메인 페이지 제작 관련 컴포넌트 수정
Hys-Lee Jun 20, 2025
4b103f6
feat: 배너 컴포넌트 반응형으로 수정
Hys-Lee Jun 20, 2025
287da9f
feat: 모달 컴포넌트 및 관련 훅과 스토어 생성 (진행중)
Hys-Lee Jun 23, 2025
efb0a6a
Merge branch 'shared-components' into main-page
Hys-Lee Jun 23, 2025
059e897
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 25, 2025
189c38e
feat: TodoList 접힌 상황 추가 및 api에 대한 추상화 타입 적용. 비동기 미처리.
Hys-Lee Jun 25, 2025
15c7ec4
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 26, 2025
2e7f446
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 26, 2025
c95b9dc
Merge branch 'main' into main-components
Hys-Lee Jun 26, 2025
02b81e2
feat: AppBar삭제 및 패키지 재설치
Hys-Lee Jun 26, 2025
ba2a556
Merge branch 'main-components' into main-page
Hys-Lee Jun 26, 2025
b2f3216
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 26, 2025
8c8e2b4
Merge branch 'main' into main-page
Hys-Lee Jun 26, 2025
c9811d9
feat: 불필요 컴포넌트 제거(ModalAddingSubGoal겹침)
Hys-Lee Jun 26, 2025
3f31add
feat: 모달 버튼 공용 컴포넌트의 것으로 수정
Hys-Lee Jun 26, 2025
19d8442
feat: 메인 페이지 TodoList 모달 연결
Hys-Lee Jun 27, 2025
f503a80
feat: todoList관련 데이터 페칭 연결 임시
Hys-Lee Jun 28, 2025
5f81d91
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 28, 2025
9862186
Merge branch 'main' into main-page
Hys-Lee Jun 28, 2025
c4a0e97
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 28, 2025
b7c9b3a
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 28, 2025
074ebf4
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jun 28, 2025
69c1f61
Merge branch 'main' into main-page
Hys-Lee Jun 28, 2025
ec0dd77
feat: api generation 스크립트 수정 및 재생성
Hys-Lee Jun 28, 2025
8d051fe
feat: 날짜 타입 문자열로 변환하는 유틸 함수 제작
Hys-Lee Jun 28, 2025
b7306d9
feat: todo와 subGoal관련 fetching 함수 제작
Hys-Lee Jun 28, 2025
7cc886b
feat: api generator fetch기반으로 변경 후 재생성
Hys-Lee Jun 28, 2025
8d3b7e6
feat: todo, todolist관련 swr 훅 제작
Hys-Lee Jun 28, 2025
73a085e
feat: TodoItem 체크에 대한 낙관적 업데이트위한 훅 제작
Hys-Lee Jun 28, 2025
29e8b84
feat: TodoList 비동기 onEdit제외 연결
Hys-Lee Jun 28, 2025
31910cb
feat: TodoList subGoal추가 관련 비동기 수정
Hys-Lee Jun 28, 2025
8d72f6e
feat: 스토리북 generation 예외 추가
Hys-Lee Jun 28, 2025
b8ae611
feat: shared 모노레포 구조에서 react 관련 버전 프로젝트 루트와 일치
Hys-Lee Jun 28, 2025
2a66352
feat: check svg 수정 관련 연관 컴포넌트 TodoItem 수정
Hys-Lee Jun 28, 2025
fd7c5fb
feat: TodoBottomSheet 완성
Hys-Lee Jun 28, 2025
3dba3c4
Merge branch 'bottom-sheet' into main-page
Hys-Lee Jun 28, 2025
f9c031c
feat: 데이터 페칭 이후 타입 변환의 책임을 비동기 훅으로 변경
Hys-Lee Jun 28, 2025
ed391d9
feat: goal 관련 fetching함수 제작
Hys-Lee Jun 28, 2025
103d7a2
feat: TodoBottomSheet 동작 수정
Hys-Lee Jul 2, 2025
d3ea1bb
feat: todo, goal, subGoal에 대한 fethcing과 쿼리 훅 생성
Hys-Lee Jul 2, 2025
16bb26e
feat: TodoBottomSheet활성화, 선택된 goal관련 zustand store생성
Hys-Lee Jul 2, 2025
a1903c0
feat: msw모킹 위한 api 및 db 생성
Hys-Lee Jul 2, 2025
f5a68db
feat: 메인 페이지 goal관련 데이터 갖는 GoalCard 컴포넌트 생성 (진행중)
Hys-Lee Jul 2, 2025
4342d9c
feat: 메인 페이지에 필요한 컴포넌트 생성 및 수정 MainHeader, GoalMenuContainer (임시)
Hys-Lee Jul 2, 2025
6def3ab
feat: 메인 페이지 연결을 위한 자잘한 수정
Hys-Lee Jul 2, 2025
1fef49f
feat: TodoList 메인페이지 api연결을 위한 수정
Hys-Lee Jul 2, 2025
8e51ade
fix: 바텀 시트 todo추가 동작 수정, 바텀시트 선택된 subgoal 버튼에 보이도록 수정
Hys-Lee Jul 2, 2025
e82590f
fix: TodoBottomSheet 상태 초기화 수정
Hys-Lee Jul 2, 2025
94357ad
feat: GoalCard 모달이 존재하면 바텀시트 닫도록 수정.
Hys-Lee Jul 3, 2025
7e7d048
feat: useModal 수정
Hys-Lee Jul 3, 2025
7372118
feat: TodoList에서 ModalAddingSubGoal 동작 관련 연결
Hys-Lee Jul 3, 2025
b198db6
fix: 자잘한 UI 에러 수정
Hys-Lee Jul 3, 2025
d6d1be1
feat: 페칭 및 훅 자잘한 수정
Hys-Lee Jul 3, 2025
1907456
feat: useTodoList undefined도 가능하도록 수정.
Hys-Lee Jul 3, 2025
e8d99d3
feat: cheer, point 관련 fetching 제작
Hys-Lee Jul 3, 2025
a748eae
feat: 모킹 구조 변경 및 points, cheer 핸들러 추가
Hys-Lee Jul 3, 2025
e8a0e2f
feat: 불필요 부분 삭제
Hys-Lee Jul 3, 2025
62abd44
feat: fetch 동작에서 헤더 설정 수정
Hys-Lee Jul 4, 2025
291696c
feat: 목표 추가 버튼 제작
Hys-Lee Jul 4, 2025
21e9566
feat: GoalCard와 useGoalWithSubGoalTodo대해 타입 및 props명 변경에 따른 수정
Hys-Lee Jul 4, 2025
5861887
feat: BottomTabBar Link추가로 페이지 이동할 수 있도록 함.
Hys-Lee Jul 4, 2025
9a2825a
feat: main페이지에 BottomTabBar추가에 따른 UI수정
Hys-Lee Jul 4, 2025
24c7cb3
feat: main page에서 bottom tab bar관련 불필요 패딩 제거.
Hys-Lee Jul 4, 2025
6889e7a
feat: 로컬 개발 시 msw사용하도록 수정
Hys-Lee Jul 4, 2025
4f0aeb6
feat: 시연 전 ui 수정사항 반영
Hys-Lee Jul 4, 2025
d44cb32
feat: 스토리북 빌드 에러 수정
Hys-Lee Jul 5, 2025
bc22043
Merge branch 'main' of https://github.com/prography/10th-Motimo-FE
Hys-Lee Jul 5, 2025
d41a521
Merge branch 'main' into main-page
Hys-Lee Jul 7, 2025
f030985
feat: shared 모노 레포 관련 유틸 함수 처리
Hys-Lee Jul 7, 2025
b02d996
feat: 페이지 이동 관련 수정
Hys-Lee Jul 7, 2025
eb32626
fix: PR 전 정리
Hys-Lee Jul 7, 2025
3b74f0c
feat: AppBar 상단 고정 및 관련해 z-index 수정
Hys-Lee Jul 7, 2025
0622490
feat: 메인페이지 bottom tab bar추가 및 bottom sheet와 함께 모바일 넓이에 맞게 조정
Hys-Lee Jul 8, 2025
b4fd95a
fix: TodoBottomSheet 버그 수정
Hys-Lee Jul 9, 2025
4aaf135
fix: fetching 반환값 반환하도록 해서 이후 동작 연결되도록 수정
Hys-Lee Jul 9, 2025
df2ed11
feat: dev서버 배포 전 프록시 및 msw수정
Hys-Lee Jul 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 181 additions & 101 deletions api/generated/motimo/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ export interface TodoResultRs {
fileUrl?: string;
}

export interface ErrorResponse {
/** @format int32 */
statusCode?: number;
message?: string;
}

export interface PointRs {
/**
* 사용자가 현재 획득한 포인트
Expand Down Expand Up @@ -380,18 +386,10 @@ export enum TodoResultRsEmotionEnum {
GROWN = "GROWN",
}

import type {
AxiosInstance,
AxiosRequestConfig,
HeadersDefaults,
ResponseType,
} from "axios";
import axios from "axios";

export type QueryParamsType = Record<string | number, any>;
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;

export interface FullRequestParams
extends Omit<AxiosRequestConfig, "data" | "params" | "url" | "responseType"> {
export interface FullRequestParams extends Omit<RequestInit, "body"> {
/** set parameter to `true` for call `securityWorker` for this request */
secure?: boolean;
/** request path */
Expand All @@ -401,157 +399,239 @@ export interface FullRequestParams
/** query params */
query?: QueryParamsType;
/** format of response (i.e. response.json() -> format: "json") */
format?: ResponseType;
format?: ResponseFormat;
/** request body */
body?: unknown;
/** base url */
baseUrl?: string;
/** request cancellation token */
cancelToken?: CancelToken;
}

export type RequestParams = Omit<
FullRequestParams,
"body" | "method" | "query" | "path"
>;

export interface ApiConfig<SecurityDataType = unknown>
extends Omit<AxiosRequestConfig, "data" | "cancelToken"> {
export interface ApiConfig<SecurityDataType = unknown> {
baseUrl?: string;
baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
securityWorker?: (
securityData: SecurityDataType | null,
) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
secure?: boolean;
format?: ResponseType;
) => Promise<RequestParams | void> | RequestParams | void;
customFetch?: typeof fetch;
}

export interface HttpResponse<D extends unknown, E extends unknown = unknown>
extends Response {
data: D;
error: E;
}

type CancelToken = Symbol | string | number;

export enum ContentType {
Json = "application/json",
JsonApi = "application/vnd.api+json",
FormData = "multipart/form-data",
UrlEncoded = "application/x-www-form-urlencoded",
Text = "text/plain",
}

export class HttpClient<SecurityDataType = unknown> {
public instance: AxiosInstance;
public baseUrl: string = "http://158.179.175.134:8080";
private securityData: SecurityDataType | null = null;
private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
private secure?: boolean;
private format?: ResponseType;
private abortControllers = new Map<CancelToken, AbortController>();
private customFetch = (...fetchParams: Parameters<typeof fetch>) =>
fetch(...fetchParams);

constructor({
securityWorker,
secure,
format,
...axiosConfig
}: ApiConfig<SecurityDataType> = {}) {
this.instance = axios.create({
...axiosConfig,
baseURL: axiosConfig.baseURL || "http://158.179.175.134:8080",
});
this.secure = secure;
this.format = format;
this.securityWorker = securityWorker;
private baseApiParams: RequestParams = {
credentials: "same-origin",
headers: {},
redirect: "follow",
referrerPolicy: "no-referrer",
};

constructor(apiConfig: ApiConfig<SecurityDataType> = {}) {
Object.assign(this, apiConfig);
}

public setSecurityData = (data: SecurityDataType | null) => {
this.securityData = data;
};

protected mergeRequestParams(
params1: AxiosRequestConfig,
params2?: AxiosRequestConfig,
): AxiosRequestConfig {
const method = params1.method || (params2 && params2.method);
protected encodeQueryParam(key: string, value: any) {
const encodedKey = encodeURIComponent(key);
return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
}

protected addQueryParam(query: QueryParamsType, key: string) {
return this.encodeQueryParam(key, query[key]);
}

protected addArrayQueryParam(query: QueryParamsType, key: string) {
const value = query[key];
return value.map((v: any) => this.encodeQueryParam(key, v)).join("&");
}

protected toQueryString(rawQuery?: QueryParamsType): string {
const query = rawQuery || {};
const keys = Object.keys(query).filter(
(key) => "undefined" !== typeof query[key],
);
return keys
.map((key) =>
Array.isArray(query[key])
? this.addArrayQueryParam(query, key)
: this.addQueryParam(query, key),
)
.join("&");
}

protected addQueryParams(rawQuery?: QueryParamsType): string {
const queryString = this.toQueryString(rawQuery);
return queryString ? `?${queryString}` : "";
}

private contentFormatters: Record<ContentType, (input: any) => any> = {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string")
? JSON.stringify(input)
: input,
[ContentType.JsonApi]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string")
? JSON.stringify(input)
: input,
[ContentType.Text]: (input: any) =>
input !== null && typeof input !== "string"
? JSON.stringify(input)
: input,
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
? property
: typeof property === "object" && property !== null
? JSON.stringify(property)
: `${property}`,
);
return formData;
}, new FormData()),
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
};

protected mergeRequestParams(
params1: RequestParams,
params2?: RequestParams,
): RequestParams {
return {
...this.instance.defaults,
...this.baseApiParams,
...params1,
...(params2 || {}),
headers: {
...((method &&
this.instance.defaults.headers[
method.toLowerCase() as keyof HeadersDefaults
]) ||
{}),
...(this.baseApiParams.headers || {}),
...(params1.headers || {}),
...((params2 && params2.headers) || {}),
},
};
}

protected stringifyFormItem(formItem: unknown) {
if (typeof formItem === "object" && formItem !== null) {
return JSON.stringify(formItem);
} else {
return `${formItem}`;
protected createAbortSignal = (
cancelToken: CancelToken,
): AbortSignal | undefined => {
if (this.abortControllers.has(cancelToken)) {
const abortController = this.abortControllers.get(cancelToken);
if (abortController) {
return abortController.signal;
}
return void 0;
}
}

protected createFormData(input: Record<string, unknown>): FormData {
if (input instanceof FormData) {
return input;
}
return Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
const propertyContent: any[] =
property instanceof Array ? property : [property];
const abortController = new AbortController();
this.abortControllers.set(cancelToken, abortController);
return abortController.signal;
};

for (const formItem of propertyContent) {
const isFileType = formItem instanceof Blob || formItem instanceof File;
formData.append(
key,
isFileType ? formItem : this.stringifyFormItem(formItem),
);
}
public abortRequest = (cancelToken: CancelToken) => {
const abortController = this.abortControllers.get(cancelToken);

return formData;
}, new FormData());
}
if (abortController) {
abortController.abort();
this.abortControllers.delete(cancelToken);
}
};

public request = async <T = any, _E = any>({
public request = async <T = any, E = any>({
body,
secure,
path,
type,
query,
format,
body,
baseUrl,
cancelToken,
...params
}: FullRequestParams): Promise<T> => {
const secureParams =
((typeof secure === "boolean" ? secure : this.secure) &&
((typeof secure === "boolean" ? secure : this.baseApiParams.secure) &&
this.securityWorker &&
(await this.securityWorker(this.securityData))) ||
{};
const requestParams = this.mergeRequestParams(params, secureParams);
const responseFormat = format || this.format || undefined;

if (
type === ContentType.FormData &&
body &&
body !== null &&
typeof body === "object"
) {
body = this.createFormData(body as Record<string, unknown>);
}

if (
type === ContentType.Text &&
body &&
body !== null &&
typeof body !== "string"
) {
body = JSON.stringify(body);
}
const queryString = query && this.toQueryString(query);
const payloadFormatter = this.contentFormatters[type || ContentType.Json];
const responseFormat = format || requestParams.format;

return this.instance
.request({
return this.customFetch(
`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
{
...requestParams,
headers: {
...(requestParams.headers || {}),
...(type ? { "Content-Type": type } : {}),
...(type && type !== ContentType.FormData
? { "Content-Type": type }
: {}),
},
params: query,
responseType: responseFormat,
data: body,
url: path,
})
.then((response) => response.data);
signal:
(cancelToken
? this.createAbortSignal(cancelToken)
: requestParams.signal) || null,
body:
typeof body === "undefined" || body === null
? null
: payloadFormatter(body),
},
).then(async (response) => {
const r = response.clone() as HttpResponse<T, E>;
r.data = null as unknown as T;
r.error = null as unknown as E;

const data = !responseFormat
? r
: await response[responseFormat]()
.then((data) => {
if (r.ok) {
r.data = data;
} else {
r.error = data;
}
return r;
})
.catch((e) => {
r.error = e;
return r;
});

if (cancelToken) {
this.abortControllers.delete(cancelToken);
}

if (!response.ok) throw data;
return data.data;
});
};
}

Expand Down Expand Up @@ -881,14 +961,14 @@ export class Api<SecurityDataType extends unknown> {
* @summary 세부 목표별 TODO 목록 조회
* @request GET:/v1/sub-goals/{subGoalId}/todos/incomplete-or-date
* @secure
* @response `200` `CustomSlice` TODO 목록 조회 성공
* @response `400` `(TodoRs)[]` 잘못된 요청 데이터
* @response `200` `(TodoRs)[]` TODO 목록 조회 성공
* @response `400` `ErrorResponse` 잘못된 요청 데이터
*/
getIncompleteOrTodayTodos: (
subGoalId: string,
params: RequestParams = {},
) =>
this.http.request<CustomSlice, TodoRs[]>({
this.http.request<TodoRs[], ErrorResponse>({
path: `/v1/sub-goals/${subGoalId}/todos/incomplete-or-date`,
method: "GET",
secure: true,
Expand Down
2 changes: 1 addition & 1 deletion api/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const generate = async (domain, url) => {
generateApi({
output: PATH_TO_OUTPUT_DIR,
url,
httpClientType: "axios", // or "fetch"
httpClientType: "fetch", // or "fetch"
defaultResponseAsSuccess: false,
generateClient: true,
generateRouteTypes: false,
Expand Down
Loading