diff --git a/src/api/axios-instance.ts b/src/api/axios-instance.ts new file mode 100644 index 0000000..dd908ff --- /dev/null +++ b/src/api/axios-instance.ts @@ -0,0 +1,9 @@ +import axiosReal from "axios"; +import { wafIntercept } from "@madie/madie-util"; + +const axios = axiosReal.create(); +axios.interceptors.response.use((response) => { + return response; +}, wafIntercept); + +export default axios; diff --git a/src/api/useCqlLibraryServiceApi.tsx b/src/api/useCqlLibraryServiceApi.tsx index b011950..7585c18 100644 --- a/src/api/useCqlLibraryServiceApi.tsx +++ b/src/api/useCqlLibraryServiceApi.tsx @@ -1,4 +1,4 @@ -import axios from "axios"; +import axios from "./axios-instance"; import useServiceConfig from "./useServiceConfig"; import { ServiceConfig } from "./ServiceContext"; import { CqlLibrary } from "@madie/madie-models"; diff --git a/src/components/config/useGetServiceConfig.ts b/src/components/config/useGetServiceConfig.ts index f0e5154..133c4bc 100644 --- a/src/components/config/useGetServiceConfig.ts +++ b/src/components/config/useGetServiceConfig.ts @@ -1,4 +1,4 @@ -import axios from "axios"; +import axios from "../../api/axios-instance"; import { useEffect, useState } from "react"; export interface OktaConfig { diff --git a/src/components/editCqlLibrary/EditCqlLibrary.test.tsx b/src/components/editCqlLibrary/EditCqlLibrary.test.tsx index 0187807..5873d79 100644 --- a/src/components/editCqlLibrary/EditCqlLibrary.test.tsx +++ b/src/components/editCqlLibrary/EditCqlLibrary.test.tsx @@ -6,7 +6,7 @@ import { MemoryRouter, Route } from "react-router"; import userEvent from "@testing-library/user-event"; import { ApiContextProvider, ServiceConfig } from "../../api/ServiceContext"; import { Simulate } from "react-dom/test-utils"; -import axios from "axios"; +import axios from "../../api/axios-instance"; import { ElmTranslationExternalError, isUsingEmpty, @@ -77,7 +77,7 @@ const organizations = [ }, ]; -jest.mock("axios"); +jest.mock("../../api/axios-instance"); const mockedAxios = axios as jest.Mocked; // mocking useHistory diff --git a/src/types/madie-madie-util.d.ts b/src/types/madie-madie-util.d.ts index 8fde3c9..ecc5fa2 100644 --- a/src/types/madie-madie-util.d.ts +++ b/src/types/madie-madie-util.d.ts @@ -87,6 +87,8 @@ declare module "@madie/madie-util" { draft?: boolean ): boolean; + export function wafIntercept(): void; + export const bootstrap: LifeCycleFn; export const mount: LifeCycleFn; export const unmount: LifeCycleFn;