The minimalistic document archiving platform.
import type { ApiClient } from '../api/api.client';
import type { ServerConfig } from './config.types';
import { httpClient } from '../api/http.client';
export async function fetchServerConfig({ apiClient }: { apiClient: ApiClient }) {
return apiClient<{
config: ServerConfig;
}>({
path: '/api/config',
});
}
export async function pingServer({
url,
headers,
}: {
url: string;
headers?: Record<string, string>;
}): Promise<true> {
const response = await httpClient<{ status: 'ok' }>({
url: `/api/ping`,
baseUrl: url,
headers,
})
.then(({ status }) => status === 'ok')
.catch(() => false);
if (!response) {
throw new Error('Could not reach the server');
}
return true;
}