UNPKG

dood-stream-client

Version:

๐Ÿš€ A feature-rich client for the DoodStream API with caching, logging, and error handling

65 lines (64 loc) โ€ข 1.91 kB
import { AxiosRequestConfig } from "axios"; import { Logger } from "winston"; import { CacheManager } from "../cache/cache-manager"; import { ClientOptions } from "../interfaces/client-options"; /** * ๐ŸŒ Base HTTP client for making API requests */ export declare class HttpClient { /** * ๐Ÿ”„ Axios instance */ private client; /** * ๐Ÿ”‘ API key */ private apiKey; /** * ๐Ÿ“ Logger instance */ private logger; /** * ๐Ÿง  Cache manager */ private cacheManager; /** * Create a new HTTP client * * @param options - Client options * @param logger - Logger instance * @param cacheManager - Cache manager */ constructor(options: ClientOptions, logger: Logger, cacheManager: CacheManager); /** * ๐Ÿ” Send a GET request * * @param endpoint - API endpoint * @param params - Query parameters * @param config - Axios request config * @param enableCache - Whether to use caching for this request * @returns Promise with response data */ get<T>(endpoint: string, params?: Record<string, any>, config?: AxiosRequestConfig, enableCache?: boolean): Promise<T>; /** * ๐Ÿ“ค Send a POST request * * @param endpoint - API endpoint * @param data - Request body data * @param params - Query parameters * @param config - Axios request config * @returns Promise with response data */ post<T>(endpoint: string, data?: any, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<T>; /** * ๐Ÿงน Clear the cache for a specific endpoint * * @param endpoint - API endpoint * @param params - Query parameters (excluding API key) */ clearCache(endpoint: string, params?: Record<string, any>): void; /** * ๐Ÿงน Clear the entire cache */ clearAllCache(): void; }