UNPKG

@selfage/node_service_client

Version:

Http client to make remote call to services from Nodejs applications.

21 lines (20 loc) 908 B
import EventEmitter = require("events"); import { HttpError } from "@selfage/http_error"; import { ClientRequestInterface } from "@selfage/service_descriptor/client_request_interface"; export interface NodeClientOptions { retries?: number; timeout?: number; } export interface NodeServiceClient { on(event: "httpError", listener: (error: HttpError) => Promise<void> | void): this; on(event: "error", listener: (error: any) => Promise<void> | void): this; } export declare class NodeServiceClient extends EventEmitter { private origin; private setTimeout; static create(origin: string): NodeServiceClient; constructor(origin: string, setTimeout: (callback: Function, ms: number) => number); send<Response>(request: ClientRequestInterface<Response>, options?: NodeClientOptions): Promise<Response>; private sendOrThrowErrors; private requestWithTimeoutAndRetries; }