-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
91 changed files
with
1,696 additions
and
495 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
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,4 +1,6 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
echo "허스키가 돌아갑니다. 🐶" | ||
|
||
npx lint-staged |
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 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
echo "허스키가 돌아갑니다. 🐶" | ||
|
||
npm run lint |
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,55 @@ | ||
import axios from 'axios'; | ||
import nookies from 'nookies'; | ||
|
||
export const apiClient = axios.create({ | ||
baseURL: `${process.env.NEXT_PUBLIC_SERVER_URL}`, | ||
}); | ||
|
||
apiClient.interceptors.request.use( | ||
(config) => { | ||
const accessToken = nookies.get(null)['accessToken']; | ||
if (accessToken) { | ||
config.headers['Authorization'] = `Bearer ${accessToken}`; | ||
} | ||
return config; | ||
}, | ||
(error) => Promise.reject(error), | ||
); | ||
|
||
apiClient.interceptors.response.use( | ||
(response) => { | ||
return response; | ||
}, | ||
async (error) => { | ||
if ( | ||
error.response.status === 401 || | ||
error.response.status === 5000 || | ||
error.response.status === 5001 | ||
) { | ||
const refreshToken = nookies.get(null)['refreshToken']; | ||
const res = await apiClient.post( | ||
'/v1/user/accesstoken', | ||
{}, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${refreshToken}`, | ||
}, | ||
}, | ||
); | ||
|
||
const accessToken = res.data.accessToken; | ||
if (accessToken) { | ||
nookies.set(null, 'accessToken', accessToken, { | ||
path: '/', | ||
}); | ||
|
||
// 재시도 | ||
error.config.headers['Authorization'] = `Bearer ${accessToken}`; | ||
return apiClient.request(error.config); | ||
} | ||
} | ||
|
||
return Promise.reject(error); | ||
}, | ||
); |
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 { useMutation } from '@tanstack/react-query'; | ||
import { nicknameCheck } from './api'; | ||
|
||
// 닉네임 중복 체크하는 커스텀 훅 | ||
export const useCheckNickname = () => { | ||
const mutation = useMutation({ | ||
mutationKey: ['nicknameCheck'], | ||
mutationFn: (nickname: string) => nicknameCheck(nickname), | ||
}); | ||
|
||
return mutation; | ||
}; |
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
Oops, something went wrong.