Files
pipu-music/packages/api-client/src/index.ts
T
mrleo1nid e78cab6ce6
ci / module boundaries / boundaries (push) Successful in 9s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m37s
ci / api / api (push) Successful in 58s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m22s
ci / db / db (push) Successful in 6m19s
ci / ts / ts (packages + web) (push) Failing after 27m2s
fix(uploads): serialize status filters and resize oversized covers
2026-10-29 12:14:49 +03:00

25 lines
974 B
TypeScript

import createClient, { type Client } from 'openapi-fetch';
import type { components, paths } from './generated/schema';
export type { components, paths };
export type ServerInfo = components['schemas']['ServerInfo'];
export type Problem = components['schemas']['Problem'];
export type ApiClient = Client<paths>;
export interface ApiClientOptions {
/** Адрес сервера без завершающего слеша; пусто — тот же origin (веб). */
baseUrl?: string;
fetch?: typeof globalThis.fetch;
}
/** Создаёт типизированный клиент публичного API (контракт — api/openapi.yaml). */
export function createApiClient(opts: ApiClientOptions = {}): ApiClient {
return createClient<paths>({
baseUrl: opts.baseUrl ?? '',
fetch: opts.fetch,
// OpenAPI query arrays (UploadStatusFilter) use form + explode: false.
querySerializer: { array: { style: 'form', explode: false } },
});
}