-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Redux to Zustand and RTK Query to Server Actions
- Loading branch information
Showing
106 changed files
with
2,617 additions
and
3,042 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
324 changes: 162 additions & 162 deletions
324
.yarn/releases/yarn-4.1.0.cjs → .yarn/releases/yarn-4.1.1.cjs
Large diffs are not rendered by default.
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 |
---|---|---|
|
@@ -7,22 +7,22 @@ | |
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint", | ||
"lint:css": "stylelint 'src/**/*.tsx'", | ||
"lint:style": "stylelint 'src/**/*.tsx'", | ||
"postinstall": "husky install", | ||
"storybook": "storybook dev -p 6006", | ||
"build-storybook": "storybook build" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.11.1", | ||
"@emotion/styled": "^11.11.0", | ||
"@reduxjs/toolkit": "^1.9.7", | ||
"jsonwebtoken": "^9.0.2", | ||
"lodash": "^4.17.21", | ||
"next": "^14.1.0", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"react-redux": "^8.1.3", | ||
"return-fetch": "^0.4.5", | ||
"swiper": "^11.0.5" | ||
"swiper": "^11.0.5", | ||
"zustand": "^4.5.2" | ||
}, | ||
"devDependencies": { | ||
"@emotion/babel-plugin": "^11.11.0", | ||
|
@@ -37,6 +37,7 @@ | |
"@storybook/react": "^8.0.0-alpha.8", | ||
"@storybook/test": "^8.0.0-alpha.8", | ||
"@svgr/webpack": "^8.1.0", | ||
"@types/jsonwebtoken": "^9", | ||
"@types/lodash": "^4", | ||
"@types/node": "^20", | ||
"@types/react": "^18", | ||
|
@@ -60,7 +61,7 @@ | |
"typescript": "5.3.2", | ||
"webpack": "^5.89.0" | ||
}, | ||
"packageManager": "[email protected].0", | ||
"packageManager": "[email protected].1", | ||
"lint-staged": { | ||
"*.{ts,tsx}": [ | ||
"eslint --fix", | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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
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,65 @@ | ||
'use server'; | ||
|
||
import { cookies } from 'next/headers'; | ||
|
||
// import jwt from 'jsonwebtoken'; | ||
|
||
import { AuthTokens } from '#/types/auth-tokens'; | ||
// import { fitFetch } from '../utilities/fetch'; | ||
|
||
const SESSION_KEY = 'session'; | ||
|
||
// async function refreshTokens(refreshToken: string): Promise<AuthTokens> { | ||
// const response = await fitFetch('/v1/auth/refresh', { | ||
// method: 'POST', | ||
// headers: { | ||
// 'Content-Type': 'application/json', | ||
// }, | ||
// body: JSON.stringify({ refreshToken }), | ||
// }); | ||
// const json = await response.json(); | ||
// return json; | ||
// } | ||
|
||
// function checkTokenExpiration(token: string): boolean { | ||
// try { | ||
// const decoded = jwt.decode(token) as { exp: number }; | ||
// return decoded.exp * 1000 > Date.now() + 60 * 1000; // 60 second buffer | ||
// } catch { | ||
// return false; | ||
// } | ||
// } | ||
|
||
export async function getToken(): Promise<string | null> { | ||
const sessionData = cookies().get(SESSION_KEY)?.value; | ||
if (!sessionData) { | ||
return null; | ||
} | ||
|
||
try { | ||
const { accessToken, refreshToken } = JSON.parse(atob(sessionData)); | ||
// if (checkTokenExpiration(accessToken)) { | ||
// const newTokens = await refreshTokens(refreshToken); | ||
// setTokens(newTokens); | ||
// return newTokens.accessToken; | ||
// } | ||
return accessToken; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
|
||
export async function setTokens(tokens: AuthTokens | null) { | ||
if (!tokens) { | ||
cookies().delete(SESSION_KEY); | ||
return; | ||
} | ||
|
||
const sessionData = btoa(JSON.stringify(tokens)); | ||
cookies().set(SESSION_KEY, sessionData, { | ||
httpOnly: true, | ||
secure: process.env.NODE_ENV === 'production', | ||
maxAge: 60 * 60 * 24 * 7, // One week | ||
path: '/', | ||
}); | ||
} |
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 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
Oops, something went wrong.