From 2e9a3f4e03f6302fa6951be3ad9959f113053006 Mon Sep 17 00:00:00 2001 From: "dongind.oct" Date: Tue, 12 Mar 2024 07:55:37 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[feat]=20Login=20:=20accessToken=20?= =?UTF-8?q?=EB=B0=8F=20refresh=20=EC=B2=98=EB=A6=AC=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. accessToken을 저장하는 코드 작성 2. axios interceptor를 통해 accessToken을 전달하고, refresh 처리 코드 작성 --- frontend/src/apis/api/loginAPI.ts | 4 +- frontend/src/apis/utils/authAPI.ts | 68 ++++++++++++++++++++++++++++++ frontend/src/constants/path.ts | 3 +- frontend/src/index.css | 2 +- frontend/src/types/authDTO.ts | 2 +- 5 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 frontend/src/apis/utils/authAPI.ts diff --git a/frontend/src/apis/api/loginAPI.ts b/frontend/src/apis/api/loginAPI.ts index da598f6..e6696b5 100644 --- a/frontend/src/apis/api/loginAPI.ts +++ b/frontend/src/apis/api/loginAPI.ts @@ -1,6 +1,6 @@ import { baseAPI } from "../utils"; import { API_URL, ROUTER_URL } from "../../constants/path"; -import { AuthenticatoinDTO, GithubOauthUrlDTO, TempIdTokenResponse } from "../../types/authDTO"; +import { AuthenticationDTO, GithubOauthUrlDTO, TempIdTokenResponse } from "../../types/authDTO"; import { useNavigate } from "react-router-dom"; export const getLoginURL = async () => { @@ -10,7 +10,7 @@ export const getLoginURL = async () => { export const postAuthCode = async (authCode: string) => { const navitage = useNavigate(); - const response = await baseAPI.post(API_URL.AUTH, { authCode }); + const response = await baseAPI.post(API_URL.AUTH, { authCode }); if (response.status === 201) { return; } diff --git a/frontend/src/apis/utils/authAPI.ts b/frontend/src/apis/utils/authAPI.ts new file mode 100644 index 0000000..89e6f19 --- /dev/null +++ b/frontend/src/apis/utils/authAPI.ts @@ -0,0 +1,68 @@ +import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from "axios"; +import { API_URL, BASE_URL } from "../../constants/path"; +import { AccessTokenResponse } from "../../types/authDTO"; + +let accessToken: string | undefined; + +const setAccessToken = (newAccessToken: string) => { + accessToken = newAccessToken; +}; + +const authAPI = axios.create({ + baseURL: BASE_URL, + timeout: 1000, + responseType: "json", + headers: { "Content-Type": "application/json" }, + withCredentials: true, +}); + +authAPI.interceptors.request.use((config) => { + if (accessToken) { + config.headers["Authorization"] = `Bearer ${accessToken}`; + } + return config; +}); + +let unauthorizedErrorRetry = 0; + +const successResponse = (response: AxiosResponse) => { + unauthorizedErrorRetry = 0; + return response; +}; + +const failResponse = async (error: AxiosError) => { + if (error.status == 401) { + unauthorizedErrorRetry++; + console.log("unauthorizedErrorRetry count :", unauthorizedErrorRetry); + + if (unauthorizedErrorRetry >= 3) { + return Promise.reject(error); + } + + try { + const response = await authAPI.post(API_URL.REFRESH); + successRefresh(response.data.accessToken, error.config); + } catch { + return Promise.reject(error); + } + } + return Promise.reject(error); +}; + +const successRefresh = async ( + newAccessToken: string, + config: InternalAxiosRequestConfig | undefined +) => { + setAccessToken(newAccessToken); + + if (config) { + config.headers["Authorization"] = `Bearer ${newAccessToken}`; + const newResponse = await authAPI(config); + + return newResponse; + } +}; + +authAPI.interceptors.response.use(successResponse, failResponse); + +export { authAPI, setAccessToken }; diff --git a/frontend/src/constants/path.ts b/frontend/src/constants/path.ts index 2310753..f05657e 100644 --- a/frontend/src/constants/path.ts +++ b/frontend/src/constants/path.ts @@ -1,10 +1,11 @@ -export const BASE_URL = "http://dev.lesser-project.site/api"; +export const BASE_URL = "https://dev.lesser-project.site/api"; export const API_URL = { GITHUB_OAUTH_URL: "/auth/github/authorization-server", AUTH: "/auth/github/authentication", SIGN_UP: "/auth/github/signup", LOG_OUT: "/auth/logout", + REFRESH: "/auth/refresh", }; export const ROUTER_URL = { diff --git a/frontend/src/index.css b/frontend/src/index.css index ed3f6cf..eee7e32 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -12,5 +12,5 @@ html, body, #root { - font-family: "pretendard"; + font-family: "pretendard", sans-serif; } diff --git a/frontend/src/types/authDTO.ts b/frontend/src/types/authDTO.ts index 4898828..1df949d 100644 --- a/frontend/src/types/authDTO.ts +++ b/frontend/src/types/authDTO.ts @@ -6,4 +6,4 @@ export interface AccessTokenResponse { export interface TempIdTokenResponse { tempIdToken: string; } -export type AuthenticatoinDTO = AccessTokenResponse | TempIdTokenResponse; +export type AuthenticationDTO = AccessTokenResponse | TempIdTokenResponse; \ No newline at end of file From 0797ddc79ec5e9572cd51259d8844d1ba8813923 Mon Sep 17 00:00:00 2001 From: "dongind.oct" Date: Tue, 12 Mar 2024 08:29:55 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[feat]=20Login=20:=20accessToken=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - accessToken 저장하는 코드를 호출하고 response에 accessToken을 저장 - accessToken이 정상적으로 저장되는 것을 확인 --- frontend/src/AppRouter.tsx | 5 +++++ frontend/src/apis/api/loginAPI.ts | 15 ++++++++++++--- frontend/src/apis/utils/authAPI.ts | 4 ++-- frontend/src/constants/path.ts | 1 + frontend/src/pages/projects/ProjectsPage.tsx | 13 +++++++++++++ 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 frontend/src/pages/projects/ProjectsPage.tsx diff --git a/frontend/src/AppRouter.tsx b/frontend/src/AppRouter.tsx index 745943a..7e6d5b0 100644 --- a/frontend/src/AppRouter.tsx +++ b/frontend/src/AppRouter.tsx @@ -1,6 +1,7 @@ import { RouterProvider, createBrowserRouter } from "react-router-dom"; import { LoginPage, SignupPage, AuthPage, TempHomepage } from "./pages"; import { ROUTER_URL } from "./constants/path"; +import ProjectsPage from "./pages/projects/ProjectsPage"; const router = createBrowserRouter([ { @@ -19,6 +20,10 @@ const router = createBrowserRouter([ path: ROUTER_URL.AUTH, element: , }, + { + path: ROUTER_URL.PROJECTS, + element: , + }, ]); const AppRouter = () => { diff --git a/frontend/src/apis/api/loginAPI.ts b/frontend/src/apis/api/loginAPI.ts index e6696b5..fb14d31 100644 --- a/frontend/src/apis/api/loginAPI.ts +++ b/frontend/src/apis/api/loginAPI.ts @@ -1,7 +1,13 @@ import { baseAPI } from "../utils"; import { API_URL, ROUTER_URL } from "../../constants/path"; -import { AuthenticationDTO, GithubOauthUrlDTO, TempIdTokenResponse } from "../../types/authDTO"; +import { + AccessTokenResponse, + AuthenticationDTO, + GithubOauthUrlDTO, + TempIdTokenResponse, +} from "../../types/authDTO"; import { useNavigate } from "react-router-dom"; +import { setAccessToken } from "../utils/authAPI"; export const getLoginURL = async () => { const response = await baseAPI.get(API_URL.GITHUB_OAUTH_URL); @@ -9,14 +15,17 @@ export const getLoginURL = async () => { }; export const postAuthCode = async (authCode: string) => { - const navitage = useNavigate(); + const navigate = useNavigate(); const response = await baseAPI.post(API_URL.AUTH, { authCode }); if (response.status === 201) { + const body = response.data as AccessTokenResponse; + setAccessToken(body.accessToken); + navigate(ROUTER_URL.PROJECTS); return; } if (response.status === 209) { const body = response.data as TempIdTokenResponse; - navitage(ROUTER_URL.SIGNUP, { state: { tempIdToken: body.tempIdToken } }); + navigate(ROUTER_URL.SIGNUP, { state: { tempIdToken: body.tempIdToken } }); return; } }; diff --git a/frontend/src/apis/utils/authAPI.ts b/frontend/src/apis/utils/authAPI.ts index 89e6f19..b1490c0 100644 --- a/frontend/src/apis/utils/authAPI.ts +++ b/frontend/src/apis/utils/authAPI.ts @@ -31,11 +31,11 @@ const successResponse = (response: AxiosResponse) => { }; const failResponse = async (error: AxiosError) => { - if (error.status == 401) { + if (error.status === 401 && error.message === "Expired:accessToken") { unauthorizedErrorRetry++; - console.log("unauthorizedErrorRetry count :", unauthorizedErrorRetry); if (unauthorizedErrorRetry >= 3) { + unauthorizedErrorRetry = 0; return Promise.reject(error); } diff --git a/frontend/src/constants/path.ts b/frontend/src/constants/path.ts index f05657e..f4caf9b 100644 --- a/frontend/src/constants/path.ts +++ b/frontend/src/constants/path.ts @@ -13,4 +13,5 @@ export const ROUTER_URL = { LOGIN: "/login", SIGNUP: "/signup", AUTH: "/auth/github/callback", + PROJECTS: "/projects", }; diff --git a/frontend/src/pages/projects/ProjectsPage.tsx b/frontend/src/pages/projects/ProjectsPage.tsx new file mode 100644 index 0000000..8a096e4 --- /dev/null +++ b/frontend/src/pages/projects/ProjectsPage.tsx @@ -0,0 +1,13 @@ +import { Link } from "react-router-dom"; +import { ROUTER_URL } from "../../constants/path"; + +const ProjectsPage = () => { + return ( +
+ this is ProjectsPage + +
+ ); +}; + +export default ProjectsPage; From 49a34624d3dce77ef911cd436387e37960b6ae45 Mon Sep 17 00:00:00 2001 From: "dongind.oct" Date: Tue, 12 Mar 2024 08:33:43 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix=20:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=95=AD=EB=AA=A9=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/test/sample.test.ts | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 frontend/src/test/sample.test.ts diff --git a/frontend/src/test/sample.test.ts b/frontend/src/test/sample.test.ts deleted file mode 100644 index 4d3aa3b..0000000 --- a/frontend/src/test/sample.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { sampleFunction } from "../utils/sampleFunction"; - -describe("sample Test", () => { - it("number test", () => { - expect(3 + 4).toBe(7); - }); - - it("import test", () => { - expect(sampleFunction(3, 4)).toBe(7); - }); -}); - -// describe("MSW 테스트") -describe("MSW test", () => { - it("msw test", async () => { - const response = await fetch("http://localhost:5173/test"); - const data = await response.json(); - - expect(data).toStrictEqual(["This", "is", "test"]); - }); -}); From f1e51c0bbd084984523a10b28e21338109b97357 Mon Sep 17 00:00:00 2001 From: "dongind.oct" Date: Tue, 12 Mar 2024 09:04:38 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix=20:=20getLoginURL=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기존의 코드는 객체를 받는 형태로 전달되었으나 authURL 자체를 코드를 비교하는 형태로 수정 - authCode가 client_id를 전달받는 형태의 코드를 비교하는 형태로 수정 --- frontend/coverage/clover.xml | 116 ++++--- frontend/coverage/coverage-final.json | 12 +- .../coverage/lcov-report/apis/api/index.html | 42 +-- .../lcov-report/apis/api/loginAPI.ts.html | 214 ++++++++----- .../lcov-report/apis/utils/authAPI.ts.html | 289 ++++++++++++++++++ .../lcov-report/apis/utils/baseAPI.ts.html | 4 +- .../lcov-report/apis/utils/index.html | 35 ++- .../lcov-report/apis/utils/index.ts.html | 2 +- .../coverage/lcov-report/constants/index.html | 10 +- .../lcov-report/constants/path.ts.html | 161 ++++++---- .../hooks/common/dropdown/index.html | 2 +- .../common/dropdown/useDropdown.tsx.html | 2 +- .../hooks/common/modal/ModalProvider.tsx.html | 2 +- .../lcov-report/hooks/common/modal/index.html | 2 +- .../hooks/common/modal/useModal.tsx.html | 2 +- frontend/coverage/lcov-report/index.html | 116 +++---- .../lcov-report/mocks/handlers.ts.html | 66 ++-- .../coverage/lcov-report/mocks/index.html | 34 +-- .../coverage/lcov-report/mocks/node.ts.html | 8 +- frontend/coverage/lcov.info | 166 ++++++---- frontend/src/test/api.test.tsx | 4 +- 21 files changed, 870 insertions(+), 419 deletions(-) create mode 100644 frontend/coverage/lcov-report/apis/utils/authAPI.ts.html diff --git a/frontend/coverage/clover.xml b/frontend/coverage/clover.xml index 5f6f7a2..8c139b7 100644 --- a/frontend/coverage/clover.xml +++ b/frontend/coverage/clover.xml @@ -1,20 +1,69 @@ - - - + + + - + - + - - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -28,11 +77,12 @@ - + - + + @@ -110,44 +160,20 @@ - + - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/frontend/coverage/coverage-final.json b/frontend/coverage/coverage-final.json index f79a741..17d0628 100644 --- a/frontend/coverage/coverage-final.json +++ b/frontend/coverage/coverage-final.json @@ -1,13 +1,11 @@ -{"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/api/loginAPI.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/api/loginAPI.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":48}},"2":{"start":{"line":4,"column":27},"end":{"line":7,"column":1}},"3":{"start":{"line":5,"column":19},"end":{"line":5,"column":63}},"4":{"start":{"line":6,"column":2},"end":{"line":6,"column":23}},"5":{"start":{"line":4,"column":13},"end":{"line":4,"column":27}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":4,"column":27},"end":{"line":4,"column":32}},"loc":{"start":{"line":4,"column":38},"end":{"line":7,"column":1}}}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1},"b":{}} +{"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/api/loginAPI.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/api/loginAPI.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":59}},"2":{"start":{"line":9,"column":0},"end":{"line":9,"column":47}},"3":{"start":{"line":10,"column":0},"end":{"line":10,"column":50}},"4":{"start":{"line":12,"column":27},"end":{"line":15,"column":1}},"5":{"start":{"line":13,"column":19},"end":{"line":13,"column":81}},"6":{"start":{"line":14,"column":2},"end":{"line":14,"column":31}},"7":{"start":{"line":12,"column":13},"end":{"line":12,"column":27}},"8":{"start":{"line":17,"column":28},"end":{"line":31,"column":1}},"9":{"start":{"line":18,"column":19},"end":{"line":18,"column":32}},"10":{"start":{"line":19,"column":19},"end":{"line":19,"column":84}},"11":{"start":{"line":20,"column":2},"end":{"line":25,"column":3}},"12":{"start":{"line":21,"column":17},"end":{"line":21,"column":53}},"13":{"start":{"line":22,"column":4},"end":{"line":22,"column":37}},"14":{"start":{"line":23,"column":4},"end":{"line":23,"column":34}},"15":{"start":{"line":24,"column":4},"end":{"line":24,"column":11}},"16":{"start":{"line":26,"column":2},"end":{"line":30,"column":3}},"17":{"start":{"line":27,"column":17},"end":{"line":27,"column":53}},"18":{"start":{"line":28,"column":4},"end":{"line":28,"column":78}},"19":{"start":{"line":29,"column":4},"end":{"line":29,"column":11}},"20":{"start":{"line":17,"column":13},"end":{"line":17,"column":28}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":12,"column":27},"end":{"line":12,"column":32}},"loc":{"start":{"line":12,"column":38},"end":{"line":15,"column":1}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":17,"column":28},"end":{"line":17,"column":33}},"loc":{"start":{"line":17,"column":55},"end":{"line":31,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":2},"end":{"line":25,"column":3}},"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":25,"column":3}}]},"1":{"loc":{"start":{"line":26,"column":2},"end":{"line":30,"column":3}},"type":"if","locations":[{"start":{"line":26,"column":2},"end":{"line":30,"column":3}}]}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":1},"f":{"0":1,"1":0},"b":{"0":[0],"1":[0]}} +,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/utils/authAPI.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/utils/authAPI.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":85}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":57}},"2":{"start":{"line":7,"column":23},"end":{"line":9,"column":1}},"3":{"start":{"line":8,"column":2},"end":{"line":8,"column":31}},"4":{"start":{"line":68,"column":18},"end":{"line":68,"column":32}},"5":{"start":{"line":11,"column":16},"end":{"line":17,"column":2}},"6":{"start":{"line":68,"column":9},"end":{"line":68,"column":16}},"7":{"start":{"line":19,"column":0},"end":{"line":24,"column":3}},"8":{"start":{"line":20,"column":2},"end":{"line":22,"column":3}},"9":{"start":{"line":21,"column":4},"end":{"line":21,"column":62}},"10":{"start":{"line":23,"column":2},"end":{"line":23,"column":16}},"11":{"start":{"line":26,"column":29},"end":{"line":26,"column":30}},"12":{"start":{"line":28,"column":24},"end":{"line":31,"column":1}},"13":{"start":{"line":29,"column":2},"end":{"line":29,"column":29}},"14":{"start":{"line":30,"column":2},"end":{"line":30,"column":18}},"15":{"start":{"line":33,"column":21},"end":{"line":50,"column":1}},"16":{"start":{"line":34,"column":2},"end":{"line":48,"column":3}},"17":{"start":{"line":35,"column":4},"end":{"line":35,"column":29}},"18":{"start":{"line":37,"column":4},"end":{"line":40,"column":5}},"19":{"start":{"line":38,"column":6},"end":{"line":38,"column":33}},"20":{"start":{"line":39,"column":6},"end":{"line":39,"column":35}},"21":{"start":{"line":42,"column":4},"end":{"line":47,"column":5}},"22":{"start":{"line":43,"column":23},"end":{"line":43,"column":79}},"23":{"start":{"line":44,"column":6},"end":{"line":44,"column":62}},"24":{"start":{"line":46,"column":6},"end":{"line":46,"column":35}},"25":{"start":{"line":49,"column":2},"end":{"line":49,"column":31}},"26":{"start":{"line":52,"column":23},"end":{"line":64,"column":1}},"27":{"start":{"line":56,"column":2},"end":{"line":56,"column":33}},"28":{"start":{"line":58,"column":2},"end":{"line":63,"column":3}},"29":{"start":{"line":59,"column":4},"end":{"line":59,"column":65}},"30":{"start":{"line":60,"column":24},"end":{"line":60,"column":45}},"31":{"start":{"line":62,"column":4},"end":{"line":62,"column":23}},"32":{"start":{"line":66,"column":0},"end":{"line":66,"column":65}}},"fnMap":{"0":{"name":"(anonymous_1)","decl":{"start":{"line":7,"column":23},"end":{"line":7,"column":24}},"loc":{"start":{"line":7,"column":50},"end":{"line":9,"column":1}}},"1":{"name":"(anonymous_2)","decl":{"start":{"line":19,"column":33},"end":{"line":19,"column":34}},"loc":{"start":{"line":19,"column":44},"end":{"line":24,"column":1}}},"2":{"name":"(anonymous_3)","decl":{"start":{"line":28,"column":24},"end":{"line":28,"column":25}},"loc":{"start":{"line":28,"column":52},"end":{"line":31,"column":1}}},"3":{"name":"(anonymous_4)","decl":{"start":{"line":33,"column":21},"end":{"line":33,"column":26}},"loc":{"start":{"line":33,"column":49},"end":{"line":50,"column":1}}},"4":{"name":"(anonymous_5)","decl":{"start":{"line":52,"column":23},"end":{"line":52,"column":28}},"loc":{"start":{"line":55,"column":4},"end":{"line":64,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":2},"end":{"line":22,"column":3}},"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":22,"column":3}}]},"1":{"loc":{"start":{"line":34,"column":2},"end":{"line":48,"column":3}},"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":48,"column":3}}]},"2":{"loc":{"start":{"line":34,"column":6},"end":{"line":34,"column":69}},"type":"binary-expr","locations":[{"start":{"line":34,"column":6},"end":{"line":34,"column":26}},{"start":{"line":34,"column":30},"end":{"line":34,"column":69}}]},"3":{"loc":{"start":{"line":37,"column":4},"end":{"line":40,"column":5}},"type":"if","locations":[{"start":{"line":37,"column":4},"end":{"line":40,"column":5}}]},"4":{"loc":{"start":{"line":58,"column":2},"end":{"line":63,"column":3}},"type":"if","locations":[{"start":{"line":58,"column":2},"end":{"line":63,"column":3}}]}},"s":{"0":1,"1":1,"2":1,"3":0,"4":1,"5":1,"6":1,"7":1,"8":0,"9":0,"10":0,"11":1,"12":1,"13":0,"14":0,"15":1,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":1,"27":0,"28":0,"29":0,"30":0,"31":0,"32":1},"f":{"0":0,"1":0,"2":0,"3":0,"4":0},"b":{"0":[0],"1":[0],"2":[0,0],"3":[0],"4":[0]}} ,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/utils/baseAPI.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/utils/baseAPI.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":48}},"2":{"start":{"line":4,"column":16},"end":{"line":10,"column":2}},"3":{"start":{"line":12,"column":0},"end":{"line":12,"column":23}}},"fnMap":{},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1},"f":{},"b":{}} ,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/utils/index.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/apis/utils/index.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}},"1":{"start":{"line":1,"column":9},"end":{"line":1,"column":27}}},"fnMap":{"0":{"name":"(anonymous_1)","decl":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}},"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":27}}}},"branchMap":{},"s":{"0":1,"1":2},"f":{"0":1},"b":{}} -,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/constants/path.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/constants/path.ts","statementMap":{"0":{"start":{"line":1,"column":13},"end":{"line":1,"column":61}},"1":{"start":{"line":3,"column":13},"end":{"line":8,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1,"1":1},"f":{},"b":{}} +,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/constants/path.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/constants/path.ts","statementMap":{"0":{"start":{"line":1,"column":13},"end":{"line":1,"column":62}},"1":{"start":{"line":3,"column":13},"end":{"line":9,"column":2}},"2":{"start":{"line":11,"column":13},"end":{"line":17,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1,"1":1,"2":1},"f":{},"b":{}} ,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/hooks/common/dropdown/useDropdown.tsx": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/hooks/common/dropdown/useDropdown.tsx","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":52}},"1":{"start":{"line":14,"column":20},"end":{"line":74,"column":1}},"2":{"start":{"line":15,"column":46},"end":{"line":15,"column":66}},"3":{"start":{"line":16,"column":26},"end":{"line":16,"column":50}},"4":{"start":{"line":17,"column":22},"end":{"line":17,"column":53}},"5":{"start":{"line":19,"column":19},"end":{"line":45,"column":null}},"6":{"start":{"line":24,"column":4},"end":{"line":44,"column":null}},"7":{"start":{"line":35,"column":12},"end":{"line":36,"column":null}},"8":{"start":{"line":37,"column":33},"end":{"line":37,"column":58}},"9":{"start":{"line":48,"column":28},"end":{"line":50,"column":3}},"10":{"start":{"line":49,"column":4},"end":{"line":49,"column":39}},"11":{"start":{"line":49,"column":27},"end":{"line":49,"column":37}},"12":{"start":{"line":52,"column":28},"end":{"line":55,"column":3}},"13":{"start":{"line":53,"column":4},"end":{"line":53,"column":30}},"14":{"start":{"line":54,"column":4},"end":{"line":54,"column":19}},"15":{"start":{"line":57,"column":29},"end":{"line":61,"column":3}},"16":{"start":{"line":58,"column":4},"end":{"line":60,"column":5}},"17":{"start":{"line":59,"column":6},"end":{"line":59,"column":21}},"18":{"start":{"line":63,"column":2},"end":{"line":71,"column":13}},"19":{"start":{"line":64,"column":4},"end":{"line":66,"column":5}},"20":{"start":{"line":65,"column":6},"end":{"line":65,"column":63}},"21":{"start":{"line":68,"column":4},"end":{"line":70,"column":6}},"22":{"start":{"line":69,"column":6},"end":{"line":69,"column":66}},"23":{"start":{"line":73,"column":2},"end":{"line":73,"column":38}},"24":{"start":{"line":76,"column":0},"end":{"line":76,"column":27}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":14,"column":20},"end":{"line":14,"column":21}},"loc":{"start":{"line":14,"column":68},"end":{"line":74,"column":1}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":19,"column":19},"end":{"line":19,"column":20}},"loc":{"start":{"line":24,"column":4},"end":{"line":44,"column":null}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":34,"column":23},"end":{"line":34,"column":24}},"loc":{"start":{"line":35,"column":12},"end":{"line":36,"column":null}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":37,"column":27},"end":{"line":37,"column":30}},"loc":{"start":{"line":37,"column":33},"end":{"line":37,"column":58}}},"4":{"name":"(anonymous_4)","decl":{"start":{"line":48,"column":28},"end":{"line":48,"column":31}},"loc":{"start":{"line":48,"column":33},"end":{"line":50,"column":3}}},"5":{"name":"(anonymous_5)","decl":{"start":{"line":49,"column":12},"end":{"line":49,"column":13}},"loc":{"start":{"line":49,"column":27},"end":{"line":49,"column":37}}},"6":{"name":"(anonymous_6)","decl":{"start":{"line":52,"column":28},"end":{"line":52,"column":29}},"loc":{"start":{"line":52,"column":47},"end":{"line":55,"column":3}}},"7":{"name":"(anonymous_7)","decl":{"start":{"line":57,"column":29},"end":{"line":57,"column":30}},"loc":{"start":{"line":57,"column":56},"end":{"line":61,"column":3}}},"8":{"name":"(anonymous_8)","decl":{"start":{"line":63,"column":12},"end":{"line":63,"column":15}},"loc":{"start":{"line":63,"column":17},"end":{"line":71,"column":3}}},"9":{"name":"(anonymous_9)","decl":{"start":{"line":68,"column":11},"end":{"line":68,"column":14}},"loc":{"start":{"line":68,"column":16},"end":{"line":70,"column":5}}}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":4},"end":{"line":20,"column":24}},"type":"default-arg","locations":[{"start":{"line":20,"column":22},"end":{"line":20,"column":24}}]},"1":{"loc":{"start":{"line":21,"column":4},"end":{"line":21,"column":27}},"type":"default-arg","locations":[{"start":{"line":21,"column":25},"end":{"line":21,"column":27}}]},"2":{"loc":{"start":{"line":22,"column":4},"end":{"line":22,"column":22}},"type":"default-arg","locations":[{"start":{"line":22,"column":20},"end":{"line":22,"column":22}}]},"3":{"loc":{"start":{"line":30,"column":9},"end":{"line":30,"column":38}},"type":"binary-expr","locations":[{"start":{"line":30,"column":9},"end":{"line":30,"column":23}},{"start":{"line":30,"column":27},"end":{"line":30,"column":38}}]},"4":{"loc":{"start":{"line":32,"column":7},"end":{"line":43,"column":null}},"type":"binary-expr","locations":[{"start":{"line":32,"column":7},"end":{"line":32,"column":11}},{"start":{"line":33,"column":8},"end":{"line":42,"column":null}}]},"5":{"loc":{"start":{"line":58,"column":4},"end":{"line":60,"column":5}},"type":"if","locations":[{"start":{"line":58,"column":4},"end":{"line":60,"column":5}}]},"6":{"loc":{"start":{"line":58,"column":8},"end":{"line":58,"column":76}},"type":"binary-expr","locations":[{"start":{"line":58,"column":8},"end":{"line":58,"column":27}},{"start":{"line":58,"column":31},"end":{"line":58,"column":76}}]},"7":{"loc":{"start":{"line":64,"column":4},"end":{"line":66,"column":5}},"type":"if","locations":[{"start":{"line":64,"column":4},"end":{"line":66,"column":5}}]}},"s":{"0":1,"1":1,"2":8,"3":8,"4":8,"5":8,"6":8,"7":9,"8":1,"9":8,"10":4,"11":4,"12":8,"13":1,"14":1,"15":8,"16":1,"17":1,"18":8,"19":8,"20":3,"21":8,"22":8,"23":8,"24":1},"f":{"0":8,"1":8,"2":9,"3":1,"4":4,"5":4,"6":1,"7":1,"8":8,"9":8},"b":{"0":[8],"1":[8],"2":[8],"3":[8,7],"4":[8,3],"5":[1],"6":[1,1],"7":[3]}} ,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/hooks/common/modal/ModalProvider.tsx": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/hooks/common/modal/ModalProvider.tsx","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":null}},"2":{"start":{"line":15,"column":13},"end":{"line":18,"column":16}},"3":{"start":{"line":20,"column":29},"end":{"line":53,"column":1}},"4":{"start":{"line":21,"column":42},"end":{"line":22,"column":null}},"5":{"start":{"line":25,"column":16},"end":{"line":31,"column":8}},"6":{"start":{"line":26,"column":4},"end":{"line":30,"column":7}},"7":{"start":{"line":27,"column":21},"end":{"line":27,"column":42}},"8":{"start":{"line":28,"column":6},"end":{"line":28,"column":30}},"9":{"start":{"line":29,"column":6},"end":{"line":29,"column":20}},"10":{"start":{"line":33,"column":18},"end":{"line":39,"column":8}},"11":{"start":{"line":34,"column":4},"end":{"line":38,"column":7}},"12":{"start":{"line":35,"column":21},"end":{"line":35,"column":42}},"13":{"start":{"line":36,"column":6},"end":{"line":36,"column":24}},"14":{"start":{"line":37,"column":6},"end":{"line":37,"column":20}},"15":{"start":{"line":41,"column":18},"end":{"line":41,"column":71}},"16":{"start":{"line":41,"column":33},"end":{"line":41,"column":51}},"17":{"start":{"line":43,"column":2},"end":{"line":52,"column":4}},"18":{"start":{"line":48,"column":10},"end":{"line":48,"column":36}},"19":{"start":{"line":20,"column":13},"end":{"line":20,"column":29}}},"fnMap":{"0":{"name":"(anonymous_1)","decl":{"start":{"line":20,"column":29},"end":{"line":20,"column":30}},"loc":{"start":{"line":20,"column":66},"end":{"line":53,"column":1}}},"1":{"name":"(anonymous_2)","decl":{"start":{"line":25,"column":28},"end":{"line":25,"column":29}},"loc":{"start":{"line":25,"column":63},"end":{"line":31,"column":3}}},"2":{"name":"(anonymous_3)","decl":{"start":{"line":26,"column":20},"end":{"line":26,"column":21}},"loc":{"start":{"line":26,"column":37},"end":{"line":30,"column":5}}},"3":{"name":"(anonymous_4)","decl":{"start":{"line":33,"column":30},"end":{"line":33,"column":31}},"loc":{"start":{"line":33,"column":45},"end":{"line":39,"column":3}}},"4":{"name":"(anonymous_5)","decl":{"start":{"line":34,"column":20},"end":{"line":34,"column":21}},"loc":{"start":{"line":34,"column":37},"end":{"line":38,"column":5}}},"5":{"name":"(anonymous_6)","decl":{"start":{"line":41,"column":26},"end":{"line":41,"column":29}},"loc":{"start":{"line":41,"column":33},"end":{"line":41,"column":51}}},"6":{"name":"(anonymous_7)","decl":{"start":{"line":47,"column":41},"end":{"line":47,"column":42}},"loc":{"start":{"line":48,"column":10},"end":{"line":48,"column":36}}}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":5,"5":5,"6":2,"7":2,"8":2,"9":2,"10":5,"11":3,"12":1,"13":1,"14":1,"15":5,"16":2,"17":5,"18":2,"19":1},"f":{"0":5,"1":2,"2":2,"3":3,"4":1,"5":2,"6":2},"b":{}} ,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/hooks/common/modal/useModal.tsx": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/hooks/common/modal/useModal.tsx","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":76}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":47}},"2":{"start":{"line":4,"column":16},"end":{"line":4,"column":17}},"3":{"start":{"line":6,"column":24},"end":{"line":38,"column":1}},"4":{"start":{"line":7,"column":15},"end":{"line":7,"column":50}},"5":{"start":{"line":7,"column":30},"end":{"line":7,"column":49}},"6":{"start":{"line":9,"column":18},"end":{"line":9,"column":42}},"7":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"8":{"start":{"line":12,"column":4},"end":{"line":14,"column":6}},"9":{"start":{"line":17,"column":29},"end":{"line":17,"column":36}},"10":{"start":{"line":19,"column":2},"end":{"line":25,"column":20}},"11":{"start":{"line":20,"column":4},"end":{"line":24,"column":5}},"12":{"start":{"line":21,"column":6},"end":{"line":23,"column":8}},"13":{"start":{"line":22,"column":8},"end":{"line":22,"column":20}},"14":{"start":{"line":27,"column":2},"end":{"line":37,"column":4}},"15":{"start":{"line":28,"column":11},"end":{"line":35,"column":6}},"16":{"start":{"line":30,"column":8},"end":{"line":30,"column":32}},"17":{"start":{"line":33,"column":8},"end":{"line":33,"column":20}},"18":{"start":{"line":6,"column":13},"end":{"line":6,"column":24}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":24},"end":{"line":6,"column":25}},"loc":{"start":{"line":6,"column":48},"end":{"line":38,"column":1}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":7,"column":24},"end":{"line":7,"column":27}},"loc":{"start":{"line":7,"column":30},"end":{"line":7,"column":49}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":19,"column":12},"end":{"line":19,"column":15}},"loc":{"start":{"line":19,"column":17},"end":{"line":25,"column":3}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":21,"column":13},"end":{"line":21,"column":16}},"loc":{"start":{"line":21,"column":18},"end":{"line":23,"column":7}}},"4":{"name":"(anonymous_4)","decl":{"start":{"line":28,"column":4},"end":{"line":28,"column":7}},"loc":{"start":{"line":28,"column":11},"end":{"line":35,"column":6}}},"5":{"name":"(anonymous_5)","decl":{"start":{"line":29,"column":12},"end":{"line":29,"column":13}},"loc":{"start":{"line":29,"column":40},"end":{"line":31,"column":7}}},"6":{"name":"(anonymous_6)","decl":{"start":{"line":32,"column":13},"end":{"line":32,"column":16}},"loc":{"start":{"line":32,"column":18},"end":{"line":34,"column":7}}}},"branchMap":{"0":{"loc":{"start":{"line":6,"column":25},"end":{"line":6,"column":44}},"type":"default-arg","locations":[{"start":{"line":6,"column":40},"end":{"line":6,"column":44}}]},"1":{"loc":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"type":"if","locations":[{"start":{"line":11,"column":2},"end":{"line":15,"column":3}}]},"2":{"loc":{"start":{"line":20,"column":4},"end":{"line":24,"column":5}},"type":"if","locations":[{"start":{"line":20,"column":4},"end":{"line":24,"column":5}}]}},"s":{"0":1,"1":1,"2":1,"3":1,"4":7,"5":6,"6":6,"7":6,"8":4,"9":2,"10":2,"11":2,"12":2,"13":2,"14":2,"15":2,"16":2,"17":1,"18":1},"f":{"0":7,"1":6,"2":2,"3":2,"4":2,"5":2,"6":1},"b":{"0":[7],"1":[4],"2":[2]}} -,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/handlers.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/handlers.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":36}},"2":{"start":{"line":4,"column":13},"end":{"line":15,"column":2}},"3":{"start":{"line":6,"column":20},"end":{"line":6,"column":23}},"4":{"start":{"line":7,"column":4},"end":{"line":7,"column":12}},"5":{"start":{"line":8,"column":4},"end":{"line":8,"column":49}},"6":{"start":{"line":11,"column":20},"end":{"line":11,"column":24}},"7":{"start":{"line":12,"column":4},"end":{"line":12,"column":12}},"8":{"start":{"line":13,"column":4},"end":{"line":13,"column":52}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":41},"end":{"line":5,"column":42}},"loc":{"start":{"line":5,"column":59},"end":{"line":9,"column":3}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":10,"column":33},"end":{"line":10,"column":34}},"loc":{"start":{"line":10,"column":52},"end":{"line":14,"column":3}}}},"branchMap":{},"s":{"0":4,"1":4,"2":4,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1},"f":{"0":1,"1":1},"b":{}} -,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/node.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/node.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":38}},"2":{"start":{"line":4,"column":13},"end":{"line":4,"column":47}}},"fnMap":{},"branchMap":{},"s":{"0":4,"1":4,"2":4},"f":{},"b":{}} -,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/responses/index.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/responses/index.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}},"1":{"start":{"line":1,"column":9},"end":{"line":1,"column":25}}},"fnMap":{"0":{"name":"(anonymous_1)","decl":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}},"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":25}}}},"branchMap":{},"s":{"0":4,"1":9},"f":{"0":5},"b":{}} -,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/responses/login.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/responses/login.ts","statementMap":{"0":{"start":{"line":1,"column":14},"end":{"line":8,"column":2}},"1":{"start":{"line":10,"column":0},"end":{"line":10,"column":21}}},"fnMap":{},"branchMap":{},"s":{"0":4,"1":4},"f":{},"b":{}} -,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/utils/sampleFunction.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/utils/sampleFunction.ts","statementMap":{"0":{"start":{"line":1,"column":30},"end":{"line":3,"column":1}},"1":{"start":{"line":2,"column":2},"end":{"line":2,"column":15}},"2":{"start":{"line":1,"column":13},"end":{"line":1,"column":30}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":1,"column":30},"end":{"line":1,"column":31}},"loc":{"start":{"line":1,"column":55},"end":{"line":3,"column":1}}}},"branchMap":{},"s":{"0":1,"1":1,"2":1},"f":{"0":1},"b":{}} +,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/handlers.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/handlers.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},"1":{"start":{"line":3,"column":13},"end":{"line":19,"column":2}},"2":{"start":{"line":5,"column":20},"end":{"line":5,"column":23}},"3":{"start":{"line":6,"column":4},"end":{"line":6,"column":12}},"4":{"start":{"line":7,"column":4},"end":{"line":7,"column":49}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":4,"column":41},"end":{"line":4,"column":42}},"loc":{"start":{"line":4,"column":59},"end":{"line":8,"column":3}}}},"branchMap":{},"s":{"0":3,"1":3,"2":0,"3":0,"4":0},"f":{"0":0},"b":{}} +,"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/node.ts": {"path":"/Users/dongind.oct/Documents/LESSER/PJT/frontend/src/mocks/node.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":38}},"2":{"start":{"line":4,"column":13},"end":{"line":4,"column":47}}},"fnMap":{},"branchMap":{},"s":{"0":3,"1":3,"2":3},"f":{},"b":{}} } diff --git a/frontend/coverage/lcov-report/apis/api/index.html b/frontend/coverage/lcov-report/apis/api/index.html index 32083d5..efe61cc 100644 --- a/frontend/coverage/lcov-report/apis/api/index.html +++ b/frontend/coverage/lcov-report/apis/api/index.html @@ -23,30 +23,30 @@

All files apis/api

- 100% + 47.61% Statements - 6/6 + 10/21
- 100% + 0% Branches - 0/0 + 0/2
- 100% + 50% Functions - 1/1 + 1/2
- 100% + 42.1% Lines - 5/5 + 8/19
@@ -61,7 +61,7 @@

All files apis/api

-
+
@@ -79,18 +79,18 @@

All files apis/api

- - + - - - - - - - - + + + + + + + + @@ -101,7 +101,7 @@

All files apis/api

- - - - +
+ + + + + + + + \ No newline at end of file diff --git a/frontend/coverage/lcov-report/apis/utils/authAPI.ts.html b/frontend/coverage/lcov-report/apis/utils/authAPI.ts.html new file mode 100644 index 0000000..0a89bf9 --- /dev/null +++ b/frontend/coverage/lcov-report/apis/utils/authAPI.ts.html @@ -0,0 +1,289 @@ + + + + + + Code coverage report for apis/utils/authAPI.ts + + + + + + + + + +
+
+

All files / apis/utils authAPI.ts

+
+ +
+ 36.36% + Statements + 12/33 +
+ + +
+ 0% + Branches + 0/6 +
+ + +
+ 0% + Functions + 0/5 +
+ + +
+ 34.37% + Lines + 11/32 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
loginAPI.ts -
+
loginAPI.ts +
100%6/6100%0/0100%1/1100%5/547.61%10/210%0/250%1/242.1%8/19
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +691x +1x +  +  +  +  +1x +  +  +  +1x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +1x +  +1x +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +1x + 
import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from "axios";
+import { API_URL, BASE_URL } from "../../constants/path";
+import { AccessTokenResponse } from "../../types/authDTO";
+ 
+let accessToken: string | undefined;
+ 
+const setAccessToken = (newAccessToken: string) => {
+  accessToken = newAccessToken;
+};
+ 
+const authAPI = axios.create({
+  baseURL: BASE_URL,
+  timeout: 1000,
+  responseType: "json",
+  headers: { "Content-Type": "application/json" },
+  withCredentials: true,
+});
+ 
+authAPI.interceptors.request.use((config) => {
+  Iif (accessToken) {
+    config.headers["Authorization"] = `Bearer ${accessToken}`;
+  }
+  return config;
+});
+ 
+let unauthorizedErrorRetry = 0;
+ 
+const successResponse = (response: AxiosResponse) => {
+  unauthorizedErrorRetry = 0;
+  return response;
+};
+ 
+const failResponse = async (error: AxiosError) => {
+  Iif (error.status === 401 && error.message === "Expired:accessToken") {
+    unauthorizedErrorRetry++;
+ 
+    Iif (unauthorizedErrorRetry >= 3) {
+      unauthorizedErrorRetry = 0;
+      return Promise.reject(error);
+    }
+ 
+    try {
+      const response = await authAPI.post<AccessTokenResponse>(API_URL.REFRESH);
+      successRefresh(response.data.accessToken, error.config);
+    } catch {
+      return Promise.reject(error);
+    }
+  }
+  return Promise.reject(error);
+};
+ 
+const successRefresh = async (
+  newAccessToken: string,
+  config: InternalAxiosRequestConfig | undefined
+) => {
+  setAccessToken(newAccessToken);
+ 
+  Iif (config) {
+    config.headers["Authorization"] = `Bearer ${newAccessToken}`;
+    const newResponse = await authAPI(config);
+ 
+    return newResponse;
+  }
+};
+ 
+authAPI.interceptors.response.use(successResponse, failResponse);
+ 
+export { authAPI, setAccessToken };
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/frontend/coverage/lcov-report/apis/utils/baseAPI.ts.html b/frontend/coverage/lcov-report/apis/utils/baseAPI.ts.html index f687bf7..c09bc0e 100644 --- a/frontend/coverage/lcov-report/apis/utils/baseAPI.ts.html +++ b/frontend/coverage/lcov-report/apis/utils/baseAPI.ts.html @@ -94,7 +94,7 @@

All files / apis/utilsAll files / apis/utils Code coverage generated by istanbul - at 2024-03-04T07:58:47.946Z + at 2024-03-11T23:59:36.704Z - - - - +
+ + + + + + + + \ No newline at end of file diff --git a/frontend/coverage/lcov-report/hooks/common/dropdown/index.html b/frontend/coverage/lcov-report/hooks/common/dropdown/index.html index e342add..d3d932a 100644 --- a/frontend/coverage/lcov-report/hooks/common/dropdown/index.html +++ b/frontend/coverage/lcov-report/hooks/common/dropdown/index.html @@ -101,7 +101,7 @@

All files hooks/common/dropdown