-
Notifications
You must be signed in to change notification settings - Fork 2
[fix] api 엔드포인트 경로 수정 #101
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ export const postYouTubeVideoInfo = (payload: string[]) => { | |
|
|
||
| // 임시 플레이리스트 저장: 플레이리스트 최종 생성 전 본문 세션에 임시 저장 | ||
| export const postTempPlaylist = (payload: TempPlaylistPayload) => { | ||
| return api.post<null>('/main/mypage/playlists/temp', payload) | ||
| return api.post<null>('/main/playlist/temp', payload) | ||
| } | ||
|
|
||
| // cd 유저 커스텀 스티커 리스트 조회 | ||
|
|
@@ -39,10 +39,10 @@ export const postUserSticker = (payload: UserStickerPayload) => { | |
|
|
||
| // 플레이리스트 생성: 세션 임시본 사용 + cd 요청 | ||
| export const postFinalPlaylist = (payload: FinalPlaylistPayload) => { | ||
| return api.post<FinalPlaylistResponse>('/main/mypage/playlists/final', payload) | ||
| return api.post<FinalPlaylistResponse>('/main/playlist/final', payload) | ||
| } | ||
|
|
||
| // 플레이리스트 수정: 세션 임시본 사용 + cd 수정 | ||
| export const patchEditPlaylist = (payload: EditPlaylistPayload) => { | ||
| return api.patch<FinalPlaylistResponse>('/main/mypage/playlists/final', payload) | ||
| return api.patch<FinalPlaylistResponse>('/main/playlist/final', payload) | ||
|
Comment on lines
+42
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
이 경로를 파일 상단에 상수로 추출하여 중복을 제거하고 코드의 명확성을 높이는 것을 권장합니다. const FINAL_PLAYLIST_PATH = '/main/playlist/final';
// ...
// 플레이리스트 생성: 세션 임시본 사용 + cd 요청
export const postFinalPlaylist = (payload: FinalPlaylistPayload) => {
return api.post<FinalPlaylistResponse>(FINAL_PLAYLIST_PATH, payload)
}
// 플레이리스트 수정: 세션 임시본 사용 + cd 수정
export const patchEditPlaylist = (payload: EditPlaylistPayload) => {
return api.patch<FinalPlaylistResponse>(FINAL_PLAYLIST_PATH, payload)
}Style Guide ReferencesFootnotes |
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,13 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { api } from '@/shared/api/httpClient' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const postFollow = (playlistId: number) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.post(`/main/browse/playlists/${playlistId}/follow`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.post(`/main/follow/${playlistId}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const deleteFollow = (playlistId: number) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.delete(`/main/browse/playlists/${playlistId}/follow`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.delete(`/main/follow/${playlistId}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const getFollowStatus = (playlistId: number) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get(`/main/browse/playlists/${playlistId}/follow`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get(`/main/follow/${playlistId}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
3
to
13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 세 함수( 경로를 생성하는 헬퍼 함수를 만들어 중복을 제거하고, 코드의 일관성과 유지보수성을 높이는 것을 제안합니다.
Suggested change
Style Guide ReferencesFootnotes |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,13 +5,13 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { api } from '@/shared/api/httpClient' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const getRecommendationsByRecent = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get<RecommendationsResponse>('/main/playlists/recommendations/playlist') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get<RecommendationsResponse>('/main/recommendation/playlist') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const getRecommendationsByFollow = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get<RecommendationsResponse>('/main/playlists/recommendations/follow') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get<RecommendationsResponse>('/main/recommendation/follow') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const getRecommendedGenres = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get<RecommendedGenresResponse>('/main/playlists/recommendations/genres') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return api.get<RecommendedGenresResponse>('/main/recommendation/genres') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
7
to
17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API 엔드포인트들이 하드코딩된 문자열로 작성되어 있습니다. 이는 '매직 스트링' 사용에 해당하며, 유지보수를 어렵게 만듭니다.1 공통 경로인
Suggested change
Style Guide ReferencesFootnotes |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
이 파일 전체에 걸쳐 API 엔드포인트 경로가 하드코딩된 문자열('매직 스트링')로 사용되고 있습니다. 이는 스타일 가이드에 위배되며1, 향후 경로 변경 시 여러 곳을 수정해야 하는 유지보수 문제를 야기합니다.
API 경로들을 중앙에서 관리하는 상수 객체나 헬퍼 함수로 추출하는 것을 강력히 권장합니다. 예를 들어,
src/shared/api/paths.ts같은 파일을 만들어 경로를 관리할 수 있습니다.중복 예시:
deleteMyPagePlaylist와getPlaylistDetail함수에서'/main/playlist/${playlistId}'경로가 중복됩니다.리팩토링 제안:
이러한 접근 방식은 코드의 가독성, 일관성 및 유지보수성을 크게 향상시킬 것입니다. 이 PR에서 수정된 모든 API 파일에 이 패턴을 적용하는 것을 고려해보세요.
Style Guide References
Footnotes