-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* config: axios 설치 * feat: axios 인스턴스 및 인터셉터 구현 * refactor: 엑세스 토큰 refresh remote 함수 분리 * refactor: 분리되지 않은 type, remote 함수 분리 * refactor: remote 함수의 fetcher 의존성 제거 및 인스턴스 적용 * refactor: 로그인 remote 함수 분리 * feat: 메인 페이지 장르별 fetch msw 구현 누락된 구현 추가 * chore: 불필요한 파일 제거 * chore: remote 함수 중복 래핑 hook 삭제 및 코드 이동 * refactor: remote 함수 query parameter 처리 방식 통일 * chore: import 방식 변경 * chore: auth 관련 remote함수 auth/하위로 이동 * fix: refresh 요청 API 명세에 맞게 로직 수정 * refactor: 최종 만료시 로그인 페이지 리다이렉트 처리 * refactor: 타입 분리 * refactor: 인터셉터 refresh 중복 요청 방지 기능 추가 * refactor: 에러응답 타입 분리 * chore: fetcher 및 토큰 만료 검증 파일 제거 * refactor: 함수 네이밍 개선 * chore: 주석 수정 * refactor: promise 변수 null 초기화 코드 위치 이동 * style: promise 변수 라인 변경 * refactor: config type 변경 및 린트 주석 제거
- Loading branch information
1 parent
5b336df
commit 7a7d161
Showing
34 changed files
with
370 additions
and
244 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,16 @@ | ||
import { client, clientBasic } from '@/shared/remotes/axios'; | ||
import type { AccessTokenRes } from '../types/auth.type'; | ||
|
||
export const getAccessToken = async (platform: string, code: string) => { | ||
const { data } = await client.get<AccessTokenRes>(`/login/${platform}`, { | ||
params: { code }, | ||
}); | ||
|
||
return data; | ||
}; | ||
|
||
export const postRefreshAccessToken = async () => { | ||
const { data } = await clientBasic.post<AccessTokenRes>('/reissue'); | ||
|
||
return data; | ||
}; |
This file contains 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,3 @@ | ||
export interface AccessTokenRes { | ||
accessToken: string; | ||
} |
This file contains 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 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 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,12 @@ | ||
import { client } from '@/shared/remotes/axios'; | ||
import type { Comment } from '../types/comment.type'; | ||
|
||
export const postComment = async (songId: number, partId: number, content: string) => { | ||
await client.post(`/songs/${songId}/parts/${partId}/comments`, { content }); | ||
}; | ||
|
||
export const getComments = async (songId: number, partId: number) => { | ||
const { data } = await client.get<Comment[]>(`/songs/${songId}/parts/${partId}/comments`); | ||
|
||
return data; | ||
}; |
This file contains 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,6 @@ | ||
export interface Comment { | ||
id: number; | ||
content: string; | ||
createdAt: string; | ||
writerNickname: string; | ||
} |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,18 @@ | ||
import { client } from '@/shared/remotes/axios'; | ||
import type { KillingPartPostRequest } from '@/shared/types/killingPart'; | ||
import type { SongInfo } from '@/shared/types/song'; | ||
|
||
// PartCollectingPage에 존재하던 remote 함수입니다. | ||
// useFetch<SongInfo>(() => fetcher(`/songs/${songId}`, 'GET')) 로직에서 분리하였습니다. | ||
// SongInfo type에는 killingPart[] 필드가 있는데, 마이파트 수집용 `노래 1개` 조회에서 해당 타입이 사용되고 있습니다. | ||
// 추후 수정되어야 합니다. | ||
|
||
export const getSong = async (songId: number) => { | ||
const { data } = await client.get<SongInfo>(`/songs/${songId}`); | ||
|
||
return data; | ||
}; | ||
|
||
export const postKillingPart = async (songId: number, body: KillingPartPostRequest) => { | ||
await client.post(`/songs/${songId}/member-parts`, body); | ||
}; |
8 changes: 0 additions & 8 deletions
8
frontend/src/features/killingParts/remotes/usePostKillingPart.ts
This file was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import { client } from '@/shared/remotes/axios'; | ||
|
||
export const deleteMember = (memberId: number | undefined) => () => { | ||
return fetcher(`/members/${memberId}`, 'DELETE'); | ||
export const deleteMember = async (memberId: number) => { | ||
await client.delete(`/members/${memberId}`); | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import { client } from '@/shared/remotes/axios'; | ||
|
||
export const deleteMemberParts = (partId: number) => fetcher(`/member-parts/${partId}`, 'DELETE'); | ||
export const deleteMemberParts = async (partId: number) => { | ||
await client.delete(`/member-parts/${partId}`); | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import { client } from '@/shared/remotes/axios'; | ||
import type { LikeKillingPart } from '../components/MyPartList'; | ||
|
||
export const getLikeParts = () => fetcher('/my-page/like-parts', 'GET'); | ||
export const getLikeParts = async () => { | ||
const { data } = await client.get<LikeKillingPart[]>('/my-page/like-parts'); | ||
|
||
export const getMyParts = () => fetcher('/my-page/my-parts', 'GET'); | ||
return data; | ||
}; | ||
|
||
export const getMyParts = async () => { | ||
const { data } = await client.get<LikeKillingPart[]>('/my-page/my-parts'); | ||
|
||
return data; | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import { client } from '@/shared/remotes/axios'; | ||
import type { SingerDetail } from '../../singer/types/singer.type'; | ||
import type { SingerSearchPreview } from '../types/search.type'; | ||
|
||
export const getSingerSearchPreview = async (query: string): Promise<SingerSearchPreview[]> => { | ||
const encodedQuery = encodeURIComponent(query); | ||
return await fetcher(`/search?keyword=${encodedQuery}&type=singer`, 'GET'); | ||
export const getSingerSearchPreview = async (query: string) => { | ||
const { data } = await client.get<SingerSearchPreview[]>(`/search`, { | ||
params: { | ||
keyword: query, | ||
type: 'singer', | ||
}, | ||
}); | ||
|
||
return data; | ||
}; | ||
|
||
export const getSingerSearch = async (query: string): Promise<SingerDetail[]> => { | ||
const encodedQuery = encodeURIComponent(query); | ||
return await fetcher(`/search?keyword=${encodedQuery}&type=singer&type=song`, 'GET'); | ||
export const getSingerSearch = async (query: string) => { | ||
const params = new URLSearchParams(); | ||
params.append('keyword', query); | ||
params.append('type', 'singer'); | ||
params.append('type', 'song'); | ||
|
||
const { data } = await client.get<SingerDetail[]>(`/search`, { params }); | ||
|
||
return data; | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import { client } from '@/shared/remotes/axios'; | ||
import type { SingerDetail } from '../types/singer.type'; | ||
|
||
export const getSingerDetail = async (singerId: number): Promise<SingerDetail> => { | ||
return await fetcher(`/singers/${singerId}`, 'GET'); | ||
export const getSingerDetail = async (singerId: number) => { | ||
const { data } = await client.get<SingerDetail>(`/singers/${singerId}`); | ||
|
||
return data; | ||
}; |
This file contains 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 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import { client } from '@/shared/remotes/axios'; | ||
|
||
export const putKillingPartLikes = async (songId: number, partId: number, likeStatus: boolean) => { | ||
return await fetcher(`/songs/${songId}/parts/${partId}/likes`, 'PUT', { likeStatus }); | ||
await client.put(`/songs/${songId}/parts/${partId}/likes`, { likeStatus }); | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import { client } from '@/shared/remotes/axios'; | ||
import type { Genre, Song } from '../types/Song.type'; | ||
import type { RecentSong } from '@/shared/types/song'; | ||
|
||
// 메인 케러셀 최신순 노래 n개 조회 api - 쿼리파람 없는경우, 응답 기본값은 5개입니다. | ||
export const getRecentSongs = async (songCount?: number): Promise<RecentSong[]> => { | ||
const query = songCount ? `?size=${songCount}` : ''; | ||
export const getRecentSongs = async (songCount?: number) => { | ||
const { data } = await client.get<RecentSong[]>(`/songs/recent`, { | ||
params: { size: songCount }, | ||
}); | ||
|
||
return await fetcher(`/songs/recent${query}`, 'GET'); | ||
return data; | ||
}; | ||
|
||
export const getHighLikedSongs = async (genre: Genre): Promise<Song[]> => { | ||
const query = genre === 'ALL' ? '' : `?genre=${genre}`; | ||
export const getHighLikedSongs = async (genre: Genre) => { | ||
const { data } = await client.get<Song[]>(`/songs/high-liked`, { | ||
params: { genre: genre === 'ALL' ? null : genre }, | ||
}); | ||
|
||
return await fetcher(`/songs/high-liked${query}`, 'GET'); | ||
return data; | ||
}; |
Oops, something went wrong.