Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(website): show API URLs on API documentation page #3359

Merged
merged 3 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions website/src/pages/api-documentation/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -24,7 +26,7 @@ const BUTTON_CLASS =
<div class='container mx-auto p-8'>
<h1 class='title'>API Documentation</h1>

<div>
<div class='mb-10'>
<p class='mt-4 mb-4'>
There is a
<a
Expand Down Expand Up @@ -57,17 +59,21 @@ const BUTTON_CLASS =
</p>
</div>

<div class='mb-8 mt-10'>
<div class='mb-10'>
<h2 class='text-xl font-semibold text-primary-400 mb-4'>Backend Server</h2>
<div class='mb-4'>
Please note that Loculus is under continuous development and the endpoints are subject to change.
</div>
<a class={BUTTON_CLASS} href={clientConfig.backendUrl + '/swagger-ui/index.html'}>
View Backend API Documentation
</a>
<div class='mt-8'>
<span class='font-medium'>URL of Backend Server:</span>
<code>{clientConfig.backendUrl}</code>
</div>
</div>

<div>
<div class='mb-10'>
<h2 class='text-xl font-semibold text-primary-400 mb-4'>LAPIS Query Engines</h2>
<div class='space-y-4'>
{
Expand All @@ -78,6 +84,29 @@ const BUTTON_CLASS =
))
}
</div>
<div class='mt-8'>
<span class='font-medium'>URLs of LAPIS Query Engines:</span>
<ul class='list-disc ml-6'>
{
Object.entries(clientConfig.lapisUrls).map(([organism, url]) => (
<li>
{organismToDisplayName[organism]}: <code>{url}</code>
</li>
))
}
</ul>
</div>
</div>

<div>
<h2 class='text-xl font-semibold text-primary-400 mb-4'>Keycloak Server</h2>
<div>
We use the open source software <a href='https://www.keycloak.org/'>Keycloak</a> for authentication.
</div>
<div class='mt-2'>
<span class='font-medium'>URL of Keycloak Server:</span>
<code>{keycloakUrl}</code>
</div>
</div>
</div>
</BaseLayout>
9 changes: 9 additions & 0 deletions website/src/utils/getAuthUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Loading