@kurrent/kurrentdb-client
Version:
KurrentDB gRPC NodeJS Client SDK
26 lines (25 loc) • 1.27 kB
TypeScript
import { IncomingMessage } from "http";
import type { Credentials, BaseOptions } from "../types";
import type { ChannelCredentialOptions, Client } from "./";
type TransformError = (statusCode: number, statusMessage: string, res: IncomingMessage) => Error | undefined;
export interface HTTPRequestOptions extends BaseOptions {
headers?: Record<string, string>;
searchParams?: Record<string, string | undefined>;
transformError?: TransformError;
}
type HTTPMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH";
/**
* Resolve the verbatim `Authorization` header for an HTTP fallback request,
* given an optional per-call credential. Returning `undefined` skips the
* header entirely (e.g. insecure mode).
*/
export type ResolveAuthorizationHeader = (perCallCredentials?: Credentials) => Promise<string | undefined>;
export declare class HTTP {
#private;
constructor(client: Client, channelCredentials: ChannelCredentialOptions, resolveAuthorizationHeader: ResolveAuthorizationHeader);
request: <T = unknown>(method: HTTPMethod, path: string, { searchParams, ...options }: HTTPRequestOptions, body?: string) => Promise<T>;
private makeRequest;
private createURL;
private getChannel;
}
export {};