@remcostoeten/fync
Version:
Unified TypeScript library for 9 popular APIs with consistent functional architecture
31 lines • 1.15 kB
TypeScript
import type { TBaseConfig } from "./types";
export type TApiConfig = TBaseConfig & {
baseUrl: string;
headers?: Record<string, string>;
auth?: {
type: "bearer" | "basic" | "apikey" | "oauth2";
token?: string;
credentials?: {
username: string;
password: string;
};
key?: string;
};
};
type THttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
type TRequestOptions = {
params?: Record<string, any>;
body?: any;
headers?: Record<string, string>;
};
export type TApiClient = {
request<T>(method: THttpMethod, path: string, options?: TRequestOptions): Promise<T>;
get<T>(path: string, options?: TRequestOptions): Promise<T>;
post<T>(path: string, body?: any, options?: TRequestOptions): Promise<T>;
put<T>(path: string, body?: any, options?: TRequestOptions): Promise<T>;
delete<T>(path: string, options?: TRequestOptions): Promise<T>;
patch<T>(path: string, body?: any, options?: TRequestOptions): Promise<T>;
};
export declare function createFyncApi(config: TApiConfig): TApiClient;
export {};
//# sourceMappingURL=api-factory.d.ts.map