"chore: update frontend dev script to include lint checks and add ESLint config file"

This commit is contained in:
louiscklaw
2025-06-04 02:35:32 +08:00
parent c0fad42f0a
commit 22fb620eef
48 changed files with 3315 additions and 97 deletions

View File

@@ -17,6 +17,8 @@ export type SignUpParams = {
lastName: string;
};
const ERR_ACCESS_TOKEN_NOT_FOUND = `Access token not found in response`;
/** **************************************
* Sign in
*************************************** */
@@ -29,7 +31,7 @@ export const signInWithPassword = async ({ email, password }: SignInParams): Pro
const { accessToken } = res.data;
if (!accessToken) {
throw new Error('Access token not found in response');
throw new Error(ERR_ACCESS_TOKEN_NOT_FOUND);
}
setSession(accessToken);

View File

@@ -69,6 +69,8 @@ export function tokenExpired(exp: number) {
// ----------------------------------------------------------------------
const INVALID_ACCESS_TOKEN = 'Invalid access token!';
export async function setSession(accessToken: string | null) {
try {
if (accessToken) {
@@ -81,7 +83,7 @@ export async function setSession(accessToken: string | null) {
if (decodedToken && 'exp' in decodedToken) {
tokenExpired(decodedToken.exp);
} else {
throw new Error('Invalid access token!');
throw new Error(INVALID_ACCESS_TOKEN);
}
} else {
sessionStorage.removeItem(JWT_STORAGE_KEY);