diff --git a/frontend/src/app/[locale]/opportunity/[id]/page.tsx b/frontend/src/app/[locale]/opportunity/[id]/page.tsx index a9699fbe7..5c2e7c88e 100644 --- a/frontend/src/app/[locale]/opportunity/[id]/page.tsx +++ b/frontend/src/app/[locale]/opportunity/[id]/page.tsx @@ -1,9 +1,9 @@ import { Metadata } from "next"; import NotFound from "src/app/[locale]/not-found"; -import { fetchOpportunity } from "src/app/api/fetchers"; import { OPPORTUNITY_CRUMBS } from "src/constants/breadcrumbs"; import { ApiRequestError, parseErrorStatus } from "src/errors"; import withFeatureFlag from "src/hoc/withFeatureFlag"; +import { fetchOpportunity } from "src/services/fetch/fetchers/fetchers"; import { Opportunity } from "src/types/opportunity/opportunityResponseTypes"; import { WithFeatureFlagProps } from "src/types/uiTypes"; diff --git a/frontend/src/app/api/auth/logout/route.ts b/frontend/src/app/api/auth/logout/route.ts index f389b4dca..9ba2136df 100644 --- a/frontend/src/app/api/auth/logout/route.ts +++ b/frontend/src/app/api/auth/logout/route.ts @@ -1,5 +1,5 @@ -import { postLogout } from "src/app/api/userFetcher"; import { deleteSession, getSession } from "src/services/auth/session"; +import { postLogout } from "src/services/fetch/fetchers/userFetcher"; export async function POST() { try { diff --git a/frontend/src/components/search/SearchResults.tsx b/frontend/src/components/search/SearchResults.tsx index c4d35d2eb..bb688c9a3 100644 --- a/frontend/src/components/search/SearchResults.tsx +++ b/frontend/src/components/search/SearchResults.tsx @@ -1,4 +1,4 @@ -import { searchForOpportunities } from "src/app/api/searchFetcher"; +import { searchForOpportunities } from "src/services/fetch/fetchers/searchFetcher"; import { QueryParamData } from "src/types/search/searchRequestTypes"; import { Suspense } from "react"; diff --git a/frontend/src/services/auth/UserProvider.tsx b/frontend/src/services/auth/UserProvider.tsx index 5292e3133..eb55878e7 100644 --- a/frontend/src/services/auth/UserProvider.tsx +++ b/frontend/src/services/auth/UserProvider.tsx @@ -3,9 +3,9 @@ // note that importing these individually allows us to mock them, otherwise mocks don't work :shrug: import debounce from "lodash/debounce"; import noop from "lodash/noop"; -import { userFetcher } from "src/app/api/clientUserFetcher"; import { UserSession } from "src/services/auth/types"; import { UserContext } from "src/services/auth/useUser"; +import { userFetcher } from "src/services/fetch/fetchers/clientUserFetcher"; import { isSessionExpired } from "src/utils/authUtil"; import React, { useCallback, useEffect, useMemo, useState } from "react"; diff --git a/frontend/src/app/api/endpointConfigs.ts b/frontend/src/services/fetch/endpointConfigs.ts similarity index 91% rename from frontend/src/app/api/endpointConfigs.ts rename to frontend/src/services/fetch/endpointConfigs.ts index f8f8618f2..f107f8fd6 100644 --- a/frontend/src/app/api/endpointConfigs.ts +++ b/frontend/src/services/fetch/endpointConfigs.ts @@ -1,5 +1,5 @@ -import { ApiMethod } from "src/app/api/fetcherHelpers"; import { environment } from "src/constants/environments"; +import { ApiMethod } from "src/services/fetch/fetcherHelpers"; export interface EndpointConfig { basePath: string; diff --git a/frontend/src/app/api/fetcherHelpers.ts b/frontend/src/services/fetch/fetcherHelpers.ts similarity index 100% rename from frontend/src/app/api/fetcherHelpers.ts rename to frontend/src/services/fetch/fetcherHelpers.ts diff --git a/frontend/src/app/api/clientUserFetcher.ts b/frontend/src/services/fetch/fetchers/clientUserFetcher.ts similarity index 100% rename from frontend/src/app/api/clientUserFetcher.ts rename to frontend/src/services/fetch/fetchers/clientUserFetcher.ts diff --git a/frontend/src/app/api/fetchers.ts b/frontend/src/services/fetch/fetchers/fetchers.ts similarity index 95% rename from frontend/src/app/api/fetchers.ts rename to frontend/src/services/fetch/fetchers/fetchers.ts index e333d5463..731adb32e 100644 --- a/frontend/src/app/api/fetchers.ts +++ b/frontend/src/services/fetch/fetchers/fetchers.ts @@ -5,7 +5,7 @@ import { fetchOpportunityEndpoint, opportunitySearchEndpoint, userLogoutEndpoint, -} from "src/app/api/endpointConfigs"; +} from "src/services/fetch/endpointConfigs"; import { createRequestBody, createRequestUrl, @@ -13,7 +13,7 @@ import { HeadersDict, JSONRequestBody, sendRequest, -} from "src/app/api/fetcherHelpers"; +} from "src/services/fetch/fetcherHelpers"; import { APIResponse } from "src/types/apiResponseTypes"; import { OpportunityApiResponse } from "src/types/opportunity/opportunityResponseTypes"; import { QueryParamData } from "src/types/search/searchRequestTypes"; diff --git a/frontend/src/app/api/searchFetcher.ts b/frontend/src/services/fetch/fetchers/searchFetcher.ts similarity index 97% rename from frontend/src/app/api/searchFetcher.ts rename to frontend/src/services/fetch/fetchers/searchFetcher.ts index 8d0c8dc34..480cf97d6 100644 --- a/frontend/src/app/api/searchFetcher.ts +++ b/frontend/src/services/fetch/fetchers/searchFetcher.ts @@ -1,6 +1,6 @@ import "server-only"; -import { fetchOpportunitySearch } from "src/app/api/fetchers"; +import { fetchOpportunitySearch } from "src/services/fetch/fetchers/fetchers"; import { PaginationOrderBy, PaginationRequestBody, diff --git a/frontend/src/app/api/userFetcher.ts b/frontend/src/services/fetch/fetchers/userFetcher.ts similarity index 70% rename from frontend/src/app/api/userFetcher.ts rename to frontend/src/services/fetch/fetchers/userFetcher.ts index 5534aa889..7e8b6ff4a 100644 --- a/frontend/src/app/api/userFetcher.ts +++ b/frontend/src/services/fetch/fetchers/userFetcher.ts @@ -1,4 +1,4 @@ -import { postUserLogout } from "src/app/api/fetchers"; +import { postUserLogout } from "src/services/fetch/fetchers/fetchers"; export const postLogout = async (token: string) => { const jwtAuthHeader = { "X-SGG-Token": token }; diff --git a/frontend/tests/api/auth/logout/route.test.ts b/frontend/tests/api/auth/logout/route.test.ts index bef675ebd..89ce4330c 100644 --- a/frontend/tests/api/auth/logout/route.test.ts +++ b/frontend/tests/api/auth/logout/route.test.ts @@ -13,7 +13,7 @@ jest.mock("src/services/auth/session", () => ({ deleteSession: (): unknown => deleteSessionMock(), })); -jest.mock("src/app/api/userFetcher", () => ({ +jest.mock("src/services/fetch/fetchers/userFetcher", () => ({ postLogout: (token: string): unknown => postLogoutMock(token), })); diff --git a/frontend/tests/components/search/SearchResults.test.tsx b/frontend/tests/components/search/SearchResults.test.tsx index 675d6fec7..10da0a8f1 100644 --- a/frontend/tests/components/search/SearchResults.test.tsx +++ b/frontend/tests/components/search/SearchResults.test.tsx @@ -34,7 +34,7 @@ jest.mock("react", () => ({ cache: (fn: unknown) => fn, })); -jest.mock("src/app/api/searchFetcher", () => ({ +jest.mock("src/services/fetch/fetchers/searchFetcher", () => ({ searchForOpportunities: jest.fn(() => Promise.resolve()), })); diff --git a/frontend/tests/pages/search/page.test.tsx b/frontend/tests/pages/search/page.test.tsx index f3da02137..7d23a1d4b 100644 --- a/frontend/tests/pages/search/page.test.tsx +++ b/frontend/tests/pages/search/page.test.tsx @@ -29,7 +29,7 @@ jest.mock("src/hooks/useSearchParamUpdater", () => ({ // // currently, with Suspense mocked out below to always show fallback content, // // the components making the fetch calls are never being rendered so we do not need to mock them out // // uncomment this if we figure out a way to properly test the underlying async components -// jest.mock("src/app/api/fetchers", () => ({ +// jest.mock("src/services/fetch/fetchers", () => ({ // get searchOpportunityFetcher() { // return new MockSearchOpportunityAPI(); // }, diff --git a/frontend/tests/services/auth/useUser.test.tsx b/frontend/tests/services/auth/useUser.test.tsx index ff98496e9..d8d4c5aeb 100644 --- a/frontend/tests/services/auth/useUser.test.tsx +++ b/frontend/tests/services/auth/useUser.test.tsx @@ -5,7 +5,7 @@ import { useUser } from "src/services/auth/useUser"; const userFetcherMock = jest.fn(); -jest.mock("src/app/api/clientUserFetcher", () => ({ +jest.mock("src/services/fetch/fetchers/clientUserFetcher", () => ({ userFetcher: () => userFetcherMock() as unknown, })); diff --git a/frontend/tests/api/FetchHelpers.test.ts b/frontend/tests/services/fetch/FetchHelpers.test.ts similarity index 97% rename from frontend/tests/api/FetchHelpers.test.ts rename to frontend/tests/services/fetch/FetchHelpers.test.ts index 51a0bab61..d1d6da06d 100644 --- a/frontend/tests/api/FetchHelpers.test.ts +++ b/frontend/tests/services/fetch/FetchHelpers.test.ts @@ -1,7 +1,10 @@ import "server-only"; -import { createRequestUrl, sendRequest } from "src/app/api/fetcherHelpers"; import { ApiRequestError, NetworkError } from "src/errors"; +import { + createRequestUrl, + sendRequest, +} from "src/services/fetch/fetcherHelpers"; import { QueryParamData } from "src/types/search/searchRequestTypes"; const searchInputs: QueryParamData = { diff --git a/frontend/tests/api/Fetchers.test.ts b/frontend/tests/services/fetch/Fetchers.test.ts similarity index 92% rename from frontend/tests/api/Fetchers.test.ts rename to frontend/tests/services/fetch/Fetchers.test.ts index a0270231f..e651d6b58 100644 --- a/frontend/tests/api/Fetchers.test.ts +++ b/frontend/tests/services/fetch/Fetchers.test.ts @@ -1,5 +1,5 @@ -import { EndpointConfig } from "src/app/api/endpointConfigs"; -import { requesterForEndpoint } from "src/app/api/fetchers"; +import { EndpointConfig } from "src/services/fetch/endpointConfigs"; +import { requesterForEndpoint } from "src/services/fetch/fetchers/fetchers"; const createRequestUrlMock = jest.fn( (_method, _basePath, _version, _namespace, subPath: string, _body) => { @@ -15,7 +15,7 @@ const getDefaultHeadersMock = jest.fn(() => ({ "Content-Type": "application/json", })); -jest.mock("src/app/api/fetcherHelpers", () => ({ +jest.mock("src/services/fetch/fetcherHelpers", () => ({ createRequestUrl: ( _method: unknown, _basePath: unknown, diff --git a/frontend/tests/api/SearchFetcher.test.ts b/frontend/tests/services/fetch/fetchers/SearchFetcher.test.ts similarity index 98% rename from frontend/tests/api/SearchFetcher.test.ts rename to frontend/tests/services/fetch/fetchers/SearchFetcher.test.ts index 418b9aa8e..2aa314ca5 100644 --- a/frontend/tests/api/SearchFetcher.test.ts +++ b/frontend/tests/services/fetch/fetchers/SearchFetcher.test.ts @@ -2,7 +2,7 @@ import { buildFilters, buildPagination, searchForOpportunities, -} from "src/app/api/searchFetcher"; +} from "src/services/fetch/fetchers/searchFetcher"; import { QueryParamData, SearchFetcherActionType, @@ -29,7 +29,7 @@ jest.mock("react", () => ({ cache: (fn: unknown) => fn, })); -jest.mock("src/app/api/fetchers", () => ({ +jest.mock("src/services/fetch/fetchers/fetchers", () => ({ fetchOpportunitySearch: (params: QueryParamData) => { return mockfetchOpportunitySearch(params) as SearchAPIResponse; },