Skip to content

Commit

Permalink
Merge pull request #826 from danskernesdigitalebibliotek/remove-accid…
Browse files Browse the repository at this point in the history
…entally-added-fbi-base-url-changes

Removing accidentally added work-in-progress fbi url changes
  • Loading branch information
spaceo authored Jan 2, 2024
2 parents f8e847a + 6ce9142 commit 5c31634
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 71 deletions.
13 changes: 6 additions & 7 deletions src/core/dbc-gateway/graphql-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { QueryFunctionContext } from "react-query";
import FetchFailedCriticalError from "../fetchers/FetchFailedCriticalError";
import { getToken, TOKEN_LIBRARY_KEY, TOKEN_USER_KEY } from "../token";
import {
getServiceBaseUrl,
serviceUrlKeys
} from "../utils/reduxMiddleware/extractServiceBaseUrls";
import DbcGateWayHttpError from "./DbcGateWayHttpError";
import { getQueryUrlFromContext } from "./helper";

export const fetcher = <TData, TVariables>(
query: string,
variables?: TVariables
) => {
return (context?: QueryFunctionContext): Promise<TData> => {
// Resolve the url based on the query name if present.
const url = getQueryUrlFromContext(context);

return (): Promise<TData> => {
// The whole concept of agency id, profile and and bearer token needs to be refined.
// First version is with a library token.
const token = getToken(TOKEN_USER_KEY) || getToken(TOKEN_LIBRARY_KEY);
Expand All @@ -23,7 +22,7 @@ export const fetcher = <TData, TVariables>(
? ({ Authorization: `Bearer ${token}` } as object)
: {};

return fetch(url, {
return fetch(getServiceBaseUrl(serviceUrlKeys.fbi), {
method: "POST",
...{
headers: {
Expand Down
33 changes: 0 additions & 33 deletions src/core/dbc-gateway/helper.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/core/storybook/serviceUrlArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,5 @@ export default {
name: "Base url for the FBI API",
defaultValue: "https://fbi-api.dbc.dk/next/graphql",
control: { type: "text" }
},
[serviceUrlKeys.fbiSearch]: {
name: "Base url for the FBI API (search)",
defaultValue: "https://fbi-api.dbc.dk/next/graphql",
control: { type: "text" }
},
[serviceUrlKeys.fbiMaterial]: {
name: "Base url for the FBI API (material)",
defaultValue: "https://fbi-api.dbc.dk/next/graphql",
control: { type: "text" }
}
};
24 changes: 5 additions & 19 deletions src/core/utils/reduxMiddleware/extractServiceBaseUrls.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@
import { EnhancedStore } from "@reduxjs/toolkit";
import { Middleware } from "redux";

type Api =
| "publizon"
| "fbs"
| "dplCms"
| "cover"
| "materialList"
| "fbi"
| "fbiSearch"
| "fbiMaterial";

type Api = "publizon" | "fbs" | "dplCms" | "cover" | "materialList" | "fbi";
export type ApiBaseUrlKey = `${Api}BaseUrl`;

export type ServiceBaseUrls =
| Record<Api, ApiBaseUrlKey>
| Record<string, never>;

type ServiceBaseUrlKey = keyof ServiceBaseUrls;

export const serviceUrlKeys: Record<Api, ApiBaseUrlKey> = {
fbs: "fbsBaseUrl",
publizon: "publizonBaseUrl",
dplCms: "dplCmsBaseUrl",
cover: "coverBaseUrl",
materialList: "materialListBaseUrl",
fbi: "fbiBaseUrl",
fbiSearch: "fbiSearchBaseUrl",
fbiMaterial: "fbiMaterialBaseUrl"
fbi: "fbiBaseUrl"
} as const;

type ServiceBaseUrls = Record<Api, ApiBaseUrlKey> | Record<string, never>;
type ServiceBaseUrlKey = keyof typeof serviceBaseUrls;

// ServiceBaseUrls "store". We use this to store the base urls for the different services.
let serviceBaseUrls: ServiceBaseUrls = {};

Expand Down
2 changes: 0 additions & 2 deletions src/core/utils/types/global-url-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ interface GlobalUrlEntryPropsInterface {
coverBaseUrl: string;
materialBaseUrl: string;
fbiBaseUrl: string;
fbiSearchBaseUrl: string;
fbiMaterialBaseUrl: string;
authUrl: string;
ereolenHomepageUrl: string;
}
Expand Down

0 comments on commit 5c31634

Please sign in to comment.