Files
familienarchiv/frontend/src/lib/shared/api.server.ts
Marcel 567612761d refactor: move lib-root files to lib/shared/ and finalize domain structure
- Move api.server.ts, errors.ts, types.ts, utils.ts, relativeTime.ts to lib/shared/
- Move person relationship components to lib/person/relationship/
- Move Stammbaum components to lib/person/genealogy/
- Move HelpPopover to lib/shared/primitives/
- Update all import paths across routes, specs, and lib files
- Update vi.mock() paths in server-project test files
- Remove now-empty legacy directories (components/, hooks/, server/, etc.)
- Update vite.config.ts coverage include paths for new structure
- Update frontend/CLAUDE.md to reflect domain-based lib/ layout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 14:53:31 +02:00

26 lines
783 B
TypeScript

/**
* Typed API client for the Familienarchiv backend.
*
* Types are generated from the OpenAPI spec — run `npm run generate:api`
* (with the backend running in dev mode) to regenerate src/lib/generated/api.ts.
*
* Usage in +page.server.ts:
*
* export async function load({ fetch }) {
* const api = createApiClient(fetch);
* const { data, error } = await api.GET('/api/documents/{id}', {
* params: { path: { id } }
* });
* }
*/
import createClient from 'openapi-fetch';
import { env } from '$env/dynamic/private';
import type { paths } from '$lib/generated/api';
export function createApiClient(fetch: typeof globalThis.fetch) {
return createClient<paths>({
baseUrl: env.API_INTERNAL_URL || 'http://localhost:8080',
fetch
});
}