@yagisumi/groonga-http-client
Version: 
groonga http client with axios
28 lines (27 loc) • 1.34 kB
TypeScript
export { GroongaError } from './client_utils';
export declare type CommandCallback = (err: Error | undefined, data: any) => void;
export declare type ResponseType = 'arraybuffer' | 'json';
export interface AxiosRequestConfigLike {
    headers?: Record<string, string>;
    responseType?: ResponseType;
}
interface AxiosResponseLike<T = any> {
    data: T;
}
export interface AxiosLike {
    get<T = any, R = AxiosResponseLike<T>>(url: string, config?: AxiosRequestConfigLike): Promise<R>;
    post<T = any, R = AxiosResponseLike<T>>(url: string, data?: any, config?: AxiosRequestConfigLike): Promise<R>;
}
export declare class GroongaHttpClient {
    readonly axios: AxiosLike;
    readonly host: string;
    constructor(axios: AxiosLike, host: string);
    command(command: string, options: Record<string, unknown>, callback: CommandCallback): void;
    command(command: string, callback: CommandCallback): void;
    commandAsync(command: string, options: Record<string, unknown>): Promise<any>;
    commandAsync(command: string): Promise<any>;
}
export declare function createGroongaClient(axios: AxiosLike, host: string): GroongaHttpClient;
export declare const createClient: typeof createGroongaClient;
export declare type GroongaHttpClientClass = typeof GroongaHttpClient;
export declare type GroongaHttpClientInstance = GroongaHttpClient;