UNPKG

@push.rocks/smartrequest

Version:

A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.

45 lines (44 loc) 959 B
/** * HTTP Methods supported by the client */ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'; /** * Response types supported by the client */ export type ResponseType = 'json' | 'text' | 'binary' | 'stream'; /** * Form field data for multipart/form-data requests */ export interface FormField { name: string; value: string | Buffer; filename?: string; contentType?: string; } /** * URL encoded form field */ export interface UrlEncodedField { key: string; value: string; } /** * Retry configuration */ export interface RetryConfig { attempts: number; initialDelay?: number; maxDelay?: number; factor?: number; statusCodes?: number[]; shouldRetry?: (error: Error, attemptCount: number) => boolean; } /** * Timeout configuration */ export interface TimeoutConfig { request?: number; connection?: number; socket?: number; response?: number; }