From 23a1c8c7c664d1a687d59184034fcf59ec6207fd Mon Sep 17 00:00:00 2001 From: Chaoran Chen Date: Sun, 29 Dec 2024 13:30:40 +0100 Subject: [PATCH] feat(website): show API URLs on API documentation page (#3359) --- .../src/pages/api-documentation/index.astro | 35 +++++++++++++++++-- website/src/utils/getAuthUrl.ts | 9 +++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/website/src/pages/api-documentation/index.astro b/website/src/pages/api-documentation/index.astro index fdce4687aa..b52f2ee0a4 100644 --- a/website/src/pages/api-documentation/index.astro +++ b/website/src/pages/api-documentation/index.astro @@ -3,8 +3,10 @@ import { authenticationApiDocsUrl } from './authenticationApiDocsUrl'; import { getRuntimeConfig, getWebsiteConfig } from '../../config'; import BaseLayout from '../../layouts/BaseLayout.astro'; import { routes } from '../../routes/routes.ts'; +import { getAuthBaseUrl } from '../../utils/getAuthUrl'; const clientConfig = getRuntimeConfig().public; +const keycloakUrl = getAuthBaseUrl(); const websiteConfig = getWebsiteConfig(); @@ -24,7 +26,7 @@ const BUTTON_CLASS =

API Documentation

-
+

There is a

-
+

Backend Server

-
+

LAPIS Query Engines

{ @@ -78,6 +84,29 @@ const BUTTON_CLASS = )) }
+
+ URLs of LAPIS Query Engines: +
    + { + Object.entries(clientConfig.lapisUrls).map(([organism, url]) => ( +
  • + {organismToDisplayName[organism]}: {url} +
  • + )) + } +
+
+
+ +
+

Keycloak Server

+
+ We use the open source software Keycloak for authentication. +
+
+ URL of Keycloak Server: + {keycloakUrl} +
diff --git a/website/src/utils/getAuthUrl.ts b/website/src/utils/getAuthUrl.ts index 24b30389c9..91a0b39ed8 100644 --- a/website/src/utils/getAuthUrl.ts +++ b/website/src/utils/getAuthUrl.ts @@ -20,3 +20,12 @@ export const getAuthUrl = async (redirectUrl: string) => { }); /* eslint-enable @typescript-eslint/naming-convention */ }; + +export const getAuthBaseUrl = async () => { + const authUrl = await getAuthUrl('/'); + const index = authUrl.indexOf('/realms'); + if (index === -1) { + return null; + } + return authUrl.substring(0, index); +};