-
Notifications
You must be signed in to change notification settings - Fork 0
fix(my): 마이페이지 목록 API 페이지 엔벨로프 응답 대응 #157
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * 목록 API 응답 형태 과도기 대응 유틸. | ||
| * | ||
| * 서버가 목록 응답을 배열에서 페이지 엔벨로프로 전환하는 중이다. | ||
| * | ||
| * - 배열: `[{...}, {...}]` | ||
| * - 엔벨로프: `{ votes: [...], page, size, hasNext }` | ||
| * | ||
| * 서버 `dev`에는 엔벨로프가 적용됐지만 `main`에는 아직 배열이라, | ||
| * 동일한 프론트 코드가 두 환경 모두에서 동작해야 한다. | ||
| * 서버 전환이 모든 환경에 끝나면 이 유틸을 제거하고 엔벨로프 타입만 남긴다. | ||
| */ | ||
|
|
||
| /** 페이지 엔벨로프 공통 메타 (서버 PaginationValidator 기준) */ | ||
| export type PageMeta = { | ||
| page: number | ||
| size: number | ||
| hasNext: boolean | ||
| } | ||
|
|
||
| /** 서버가 허용하는 최대 page size. 초과 시 400을 반환한다. */ | ||
| export const MAX_PAGE_SIZE = 50 | ||
|
|
||
| /** | ||
| * 배열 또는 페이지 엔벨로프를 항상 배열로 정규화한다. | ||
| * | ||
| * @param data 응답 본문 (배열 또는 엔벨로프) | ||
| * @param key 엔벨로프 안에서 목록이 담긴 키 (예: `votes`, `comments`) | ||
| */ | ||
| export function unwrapList<T>(data: unknown, key: string): T[] { | ||
| if (Array.isArray(data)) return data as T[] | ||
|
|
||
| if (data !== null && typeof data === 'object') { | ||
| const items = (data as Record<string, unknown>)[key] | ||
| if (Array.isArray(items)) return items as T[] | ||
| } | ||
|
|
||
| // 예상 밖의 형태는 빈 목록으로 처리한다. | ||
| // 배열을 가정한 컴포넌트에서 `.map is not a function`으로 터지는 것보다, | ||
| // 빈 상태 문구를 보여주는 편이 낫다. | ||
| return [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
표와 인용문 사이에 빈 줄을 추가하세요.
현재 형식은 markdownlint
MD058경고를 발생시킵니다.docs/screens/SCR-MY-COMMENT-001_my-comment.md#L74-L75: 표 종료 후 인용문 전에 빈 줄을 추가하세요.docs/screens/SCR-MY-CREATED-001_my-created.md#L51-L52: 표 종료 후 인용문 전에 빈 줄을 추가하세요.docs/screens/SCR-MY-VOTED-001_my-voted.md#L52-L53: 표 종료 후 인용문 전에 빈 줄을 추가하세요.🧰 Tools
🪛 markdownlint-cli2 (0.23.2)
[warning] 74-74: Tables should be surrounded by blank lines
(MD058, blanks-around-tables)
📍 Affects 3 files
docs/screens/SCR-MY-COMMENT-001_my-comment.md#L74-L75(this comment)docs/screens/SCR-MY-CREATED-001_my-created.md#L51-L52docs/screens/SCR-MY-VOTED-001_my-voted.md#L52-L53🤖 Prompt for AI Agents
Source: Linters/SAST tools