guardz-axios
Version:
Type-safe HTTP client built on top of Axios with runtime validation using guardz. Part of the guardz ecosystem for comprehensive TypeScript type safety.
27 lines • 1.32 kB
TypeScript
import type { TypeGuardFn } from "guardz";
import type { SafeRequestResult } from "../types/SafeRequestResult";
import type { ErrorContext } from "../types/ErrorContext";
import type { RetryConfig } from "../types/RetryConfig";
/**
* Pattern 3: Fluent API Builder
* Usage: const result = await safe().get('/users/1').guard(isUser).tolerance(false).execute();
*/
export declare class SafeRequestBuilder<T = unknown> {
private config;
private axiosConfig;
get(url: string): SafeRequestBuilder<T>;
post(url: string, data?: any): SafeRequestBuilder<T>;
put(url: string, data?: any): SafeRequestBuilder<T>;
patch(url: string, data?: any): SafeRequestBuilder<T>;
delete(url: string): SafeRequestBuilder<T>;
guard<U>(guardFn: TypeGuardFn<U>): SafeRequestBuilder<U>;
tolerance(enabled?: boolean): SafeRequestBuilder<T>;
identifier(id: string): SafeRequestBuilder<T>;
onTypeMismatch(callback: (error: string, context: ErrorContext) => void): SafeRequestBuilder<T>;
timeout(ms: number): SafeRequestBuilder<T>;
retry(config: RetryConfig): SafeRequestBuilder<T>;
headers(headers: Record<string, string>): SafeRequestBuilder<T>;
baseURL(url: string): SafeRequestBuilder<T>;
execute(): Promise<SafeRequestResult<T>>;
}
//# sourceMappingURL=SafeRequestBuilder.d.ts.map