32 lines
828 B
TypeScript
32 lines
828 B
TypeScript
/**
|
|||
|
|
* API client for the STA backend.
|
||
|
|
*
|
||
|
|
* This client is generated from the OpenAPI specification and provides
|
||
|
|
* type-safe access to all backend endpoints.
|
||
|
|
*
|
||
|
|
* Usage:
|
||
|
|
* ```typescript
|
||
|
|
* import { apiClient } from '@/api/client';
|
||
|
|
*
|
||
|
|
* const { data, error } = await apiClient.GET('/api/health');
|
||
|
|
* ```
|
||
|
|
*/
|
||
|
|
|
||
|
|
import createClient from 'openapi-fetch';
|
||
|
|
import type { paths } from './schema';
|
||
|
|
|
||
|
|
// Get the API base URL from environment variables or default to localhost
|
||
|
|
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:3100';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Typed API client instance.
|
||
|
|
*
|
||
|
|
* All requests are type-checked against the OpenAPI schema.
|
||
|
|
*/
|
||
|
|
export const apiClient = createClient<paths>({ baseUrl: API_BASE_URL });
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Re-export the types for convenience
|
||
|
|
*/
|
||
|
|
export type { paths, components } from './schema';
|