-
Notifications
You must be signed in to change notification settings - Fork 5
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
타입스크립트 컨벤션에 맞춰 리팩토링을 진행한다 #870
base: develop
Are you sure you want to change the base?
Conversation
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.
수고하셨습니다~ comment 날린것만 확인해주세요~
export const generateAxiosInstanceWithAccessToken = () => { | ||
const accessToken = localStorage.getItem(ACCESSTOKEN_KEY); | ||
const data = await axios.get<{ tag: string[] }>(`${HOME_URL}/api/tags`, { | ||
return axios.create({ | ||
baseURL: HOME_URL, | ||
headers: { | ||
'Access-Control-Allow-Origin': '*', | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
return data.data; | ||
}; |
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.
axios를 사용한다면 axios.create를 이용해서 할 수 있지 않을까요?
const axiosInstance = axios.create({
headers: {
Authorization : `Bearer ${localStorage.getItem("access_token")}`
}
}
})
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.
어떤 말인지 자세히 설명해 줄 수 있나요? accessToken을 분리하지 않고 인라인으로 하라는 걸까요? 이미 create를 사용하고 있어서🤔
import { MutableRefObject } from 'react'; | ||
|
||
import { postImageUrlConverter } from '@/api/article/image'; | ||
import { Editor } from '@toast-ui/react-editor'; | ||
|
||
export const takeToastImgEditor = (content: MutableRefObject<Editor | null>) => { | ||
if (content.current) { | ||
content.current.getInstance().removeHook('addImageBlobHook'); | ||
content.current.getInstance().addHook('addImageBlobHook', (blob, callback) => { | ||
(async () => { | ||
const formData = new FormData(); | ||
formData.append('imageFile', blob); | ||
const url = await postImageUrlConverter(formData); | ||
callback(url, 'alt-text'); | ||
})(); | ||
}); | ||
} | ||
}; |
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.
이것은 왜 있는거죠? 제가 따로 훅으로 만들어 둔게 있던거 같은데요
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.
스밍이 만든 훅이 맞는데, 현재 브랜치에는 반영이 안되어 있어 병합하는 과정에서 create로 되어 있는 것 같습니다.
frontend/src/api/article/article.ts
Outdated
category, | ||
sort, | ||
cursorId, | ||
cursorViews, | ||
cursorLikes, | ||
}: { | ||
category: string; | ||
sort: '추천순' | '조회순' | '최신순'; | ||
cursorId: string; | ||
cursorViews: string; | ||
cursorLikes: string; |
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.
외부 interface로 빼주세요!
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.
분리하였습니다!
frontend/src/api/article/article.ts
Outdated
category, | ||
sort, | ||
cursorId, | ||
cursorViews, | ||
}: { | ||
category: string; | ||
sort: '추천순' | '조회순' | '최신순'; | ||
cursorId: string; | ||
cursorViews: string; |
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.
얘도 빼주세요~
frontend/src/api/article/article.ts
Outdated
id: string; | ||
title: string; | ||
content: string; | ||
tag: string[]; |
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.
interface
frontend/src/api/article/article.ts
Outdated
category: string; | ||
cursorId: string; | ||
cursorLikes: string; |
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.
interface!
@@ -0,0 +1,12 @@ | |||
import { generateAxiosInstanceWithAccessToken } from '@/utils/generateAxiosInstance'; | |||
|
|||
export const postAddLikeArticle = (articleId: string) => { |
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.
articleId만 따로 타입을 빼서 만들수 있지 않을까요?
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.
어떤 말인지 자세히 설명해줄 수 있나요? interface로 분리하라는 건가...🤔
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.
이때의 나는 무슨 얘기를 했던것일까..🤨
frontend/src/api/comment/comments.ts
Outdated
id, | ||
content, | ||
isAnonymous, | ||
}: { | ||
id: string; | ||
content: string; | ||
isAnonymous: boolean; |
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.
interface로 빼주세요
테스트 작동시 아래와 같은 에러 발생 하면서 실패하네요 mock 서버가 잘못된 것 같은데 이유를 아시나요? |
api instance 적용에 따라서 test에서 base url이 localhost로 인식되어 이와 관련하여 수정 진행
api instance 적용 이후, test코드를 작동시 mocking의 서버가 localhost로 잡혀서 테스트가 진행되지 않았었습니다. |
Close #790