@goatlab/typesense
Version:
Modern TypeScript wrapper for Typesense search engine API
51 lines (50 loc) • 1.7 kB
TypeScript
import type { KyInstance } from '@goatlab/js-utils';
export interface HttpClientOptions {
prefixUrl: string;
token: string;
searchTimeout?: number;
importTimeout?: number;
defaultTimeout?: number;
beforeRequest?: Array<(request: Request) => void | Promise<void>>;
afterResponse?: any[];
beforeError?: Array<(error: any) => any | Promise<any>>;
kyInstance?: KyInstance;
enforceTLS?: boolean;
}
export declare class TypesenseHttpClient {
private kyInstance;
private readonly enforceTLS;
private readonly options;
constructor(options: HttpClientOptions);
private createDefaultClient;
private sanitizeHeaders;
request<T>(endpoint: string, options?: {
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
body?: any;
searchParams?: Record<string, any>;
timeout?: number;
signal?: AbortSignal;
}): Promise<T>;
requestText(endpoint: string, options?: {
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
body?: any;
searchParams?: Record<string, any>;
timeout?: number;
signal?: AbortSignal;
}): Promise<string>;
requestTextWithRawBody(endpoint: string, options?: {
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
body?: any;
searchParams?: Record<string, any>;
timeout?: number;
signal?: AbortSignal;
}): Promise<string>;
stream(endpoint: string, options?: {
method?: 'GET' | 'POST';
body?: any;
searchParams?: Record<string, any>;
signal?: AbortSignal;
}): Promise<ReadableStream>;
getClient(): KyInstance;
getOptions(): HttpClientOptions;
}