ft_transcendence/frontend/src/api/index.ts
2025-12-22 17:37:25 +01:00

24 lines
531 B
TypeScript

import { ensureWindowState } from '@app/utils';
import { Configuration, OpenapiOtherApi } from './generated';
export * from './generated'
ensureWindowState();
declare module 'ft_state' {
interface State {
client: OpenapiOtherApi;
}
}
const basePath = (() => {
let u = new URL(location.href);
u.pathname = "";
u.hash = "";
u.search = "";
return u.toString().replace(/\/+$/, '');
})();
export const client = new OpenapiOtherApi(new Configuration({ basePath }));
export default client;
window.__state.client ??= client;