-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feat: webpack proxy 설정, axiosConfig 추가, api 추가 (#151)
- Loading branch information
1 parent
9d513cb
commit 4eea8bf
Showing
21 changed files
with
303 additions
and
79 deletions.
There are no files selected for viewing
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 @@ | ||
[{"/Users/jeongmingong/past-forward-frontend/webpack.config.js":"1"},{"size":1775,"mtime":1713187107202,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1el0hh9","/Users/jeongmingong/past-forward-frontend/webpack.config.js",[],[]] |
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
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,21 @@ | ||
//post | ||
export interface PostImageToS3Request { | ||
filename: string; | ||
method: string; | ||
} | ||
|
||
export interface PostImageToS3Response { | ||
filename: string; | ||
preSignedUrl: string; | ||
} | ||
|
||
// 유저 프로필 사진 | ||
export interface PutThumbnailRequest { | ||
thumbnail: string; | ||
} | ||
|
||
export interface PutThumbnailResponse { | ||
userId: number; | ||
email: string; | ||
thumbnail: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
// export const mockRetrospectiveTemplate: RetrospectivesTemplateResponse[] = [ | ||
// { id: 1, name: 'hee' }, | ||
// { | ||
// id: 2, | ||
// name: 'jung', | ||
// }, | ||
// ]; | ||
import { RetrospectivesTemplateResponse } from '../@types/RetrospectiveTemplates'; | ||
|
||
export const mockRetrospectiveTemplate: RetrospectivesTemplateResponse[] = [ | ||
// { id: 1, name: 'hee' }, | ||
// { | ||
// id: 2, | ||
// name: 'jung', | ||
// }, | ||
]; |
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,38 @@ | ||
import { fetchAuthSession } from 'aws-amplify/auth'; | ||
import axios from 'axios'; | ||
|
||
// Axios 인스턴스 생성 | ||
const axiosInstance = axios.create({ | ||
baseURL: 'https://api.pastforward.link/', | ||
headers: { | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
}, | ||
}); | ||
|
||
// Axios 요청을 보내기 전에 실행 | ||
axiosInstance.interceptors.request.use( | ||
async config => { | ||
try { | ||
// 현재 세션에서 토큰 가져오기 | ||
const { accessToken } = (await fetchAuthSession()).tokens || {}; | ||
|
||
// accessToken이 없으면 반환 | ||
if (!accessToken) { | ||
console.log('세션 토큰 없음'); | ||
return config; | ||
} | ||
|
||
// 헤더에 토큰 추가 | ||
config.headers['Authorization'] = `Bearer ${accessToken}`; | ||
return config; | ||
} catch (err) { | ||
console.error('에러', err); | ||
return config; | ||
} | ||
}, | ||
error => { | ||
return Promise.reject(error); | ||
}, | ||
); | ||
|
||
export default axiosInstance; |
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,15 @@ | ||
import axiosInstance from '../axiosConfig'; | ||
import { PostImageToS3Request, PostImageToS3Response } from '@/api/@types/Thumbnail'; | ||
|
||
// post 요청 | ||
const postImageToS3 = async (requestData: PostImageToS3Request): Promise<PostImageToS3Response> => { | ||
try { | ||
const response = await axiosInstance.post<PostImageToS3Response>('/s3/pre-signed-url', requestData); | ||
console.log('사진 s3 업로드 성공', response.data); | ||
return response.data; | ||
} catch (error) { | ||
throw new Error('실패'); | ||
} | ||
}; | ||
|
||
export default postImageToS3; |
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,15 @@ | ||
import axiosInstance from '../axiosConfig'; | ||
import { PutThumbnailRequest, PutThumbnailResponse } from '@/api/@types/Thumbnail'; | ||
|
||
// put 요청 | ||
const putUserThumbnail = async (requestData: PutThumbnailRequest): Promise<PutThumbnailResponse> => { | ||
try { | ||
const response = await axiosInstance.put<PutThumbnailResponse>('/users/{userId}/thumbnail', requestData); | ||
console.log('프로필 사진 등록 성공', response.data); | ||
return response.data; | ||
} catch (error) { | ||
throw new Error('실패'); | ||
} | ||
}; | ||
|
||
export default putUserThumbnail; |
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,14 @@ | ||
import axiosInstance from '../axiosConfig'; | ||
import { RetrospectivesTemplateResponse } from '@/api/@types/RetrospectiveTemplates'; | ||
|
||
const getTemplate = async () => { | ||
try { | ||
const response = await axiosInstance.get<RetrospectivesTemplateResponse>('/retrospective-templates'); | ||
console.log('템플릿 조회 성공', response.data); | ||
return response.data.data; | ||
} catch (error) { | ||
throw new Error('템플릿 조회 실패'); | ||
} | ||
}; | ||
|
||
export default getTemplate; |
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,15 @@ | ||
import axiosInstance from '../axiosConfig'; | ||
import { PostRetrospectivesRequest, PostRetrospectivesResponse } from '@/api/@types/Retrospectives'; | ||
|
||
// post 요청 | ||
const postRetrospective = async (requestData: PostRetrospectivesRequest): Promise<PostRetrospectivesResponse> => { | ||
try { | ||
const response = await axiosInstance.post<PostRetrospectivesResponse>('/retrospectives', requestData); | ||
console.log('회고 생성 성공', response.data); | ||
return response.data; | ||
} catch (error) { | ||
throw new Error('회고 생성 실패'); | ||
} | ||
}; | ||
|
||
export default postRetrospective; |
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
Oops, something went wrong.