27 lines
1 KiB
TypeScript
27 lines
1 KiB
TypeScript
// @ts-nocheck
|
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
import { type ClientOptions, type Config, createClient, createConfig } from "./client";
|
|
import type { ClientOptions as ClientOptions2 } from "./types.gen";
|
|
import { getRequestClient } from "../../lib/request-client";
|
|
|
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
|
|
override?: Config<ClientOptions & T>,
|
|
) => Config<Required<ClientOptions> & T>;
|
|
|
|
const fallbackClient = createClient(createConfig<ClientOptions2>({ baseUrl: "http://localhost:4096" }));
|
|
|
|
/**
|
|
* Proxy client that automatically uses the per-request client from request-scoped server storage.
|
|
* Falls back to a default client if no request context is available.
|
|
*/
|
|
export const client = new Proxy(fallbackClient, {
|
|
get(target, prop, receiver) {
|
|
try {
|
|
const requestClient = getRequestClient();
|
|
return Reflect.get(requestClient, prop, receiver);
|
|
} catch {
|
|
// No request context available, use fallback
|
|
return Reflect.get(target, prop, receiver);
|
|
}
|
|
},
|
|
});
|