-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 15분마다 토큰 인증 post 요청하는 커스텀 훅 작성 #179
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 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,22 @@ | ||
import useRefreshToken from '@remote/queries/auth/useRefreshToken'; | ||
|
||
const JWT_EXPIRY_TIME = 15 * 60 * 1000; | ||
|
||
function useIntervalRefreshToken() { | ||
const { mutate: refresh } = useRefreshToken(); | ||
let refreshTokenInterval: NodeJS.Timeout; | ||
|
||
const startRefreshTokenInterval = () => { | ||
refreshTokenInterval = setInterval(() => { | ||
refresh(); | ||
}, JWT_EXPIRY_TIME); | ||
}; | ||
|
||
const refreshTokenClear = () => { | ||
clearInterval(refreshTokenInterval); | ||
}; | ||
|
||
return { startRefreshTokenInterval, refreshTokenClear }; | ||
} | ||
|
||
export default useIntervalRefreshToken; |