Skip to content

delight-rpc/http-client

Repository files navigation

@delight-rpc/http-client

The HTTP client library of delight-rpc, it needs to be used with the server implementation @delight-rpc/http-server.

Install

npm install --save @delight-rpc/http-client
# or
yarn add @delight-rpc/http-client

Usage

interface IAPI {
  echo(message: string): string
}

const client = createClient<IAPI>({
  server: 'http://localhost:8080'
, keepalive: true
})

await client.echo('hello')

API

interface IClientOptions {
  server: string
  timeout?: number
  keepalive?: boolean
  basicAuth?: {
    username: string
    password: string
  }
}

createClient

function createClient<IAPI extends object>(
  clientOptions: IClientOptions
, options?: {
    parameterValidators?: DelightRPC.ParameterValidators<IAPI>
    expectedVersion?: string
    channel?: string
  }
): DelightRPC.ClientProxy<IAPI>

createBatchClient

function createBatchClient(
  clientOptions: IClientOptions
, options?: {
    expectedVersion?: string
    channel?: string
  }
): DelightRPC.BatchClient