An open API service indexing awesome lists of open source software.

https://github.com/delight-rpc/http-client

🌲 The HTTP client library of delight-rpc.
https://github.com/delight-rpc/http-client

browser esm library nodejs npm-package typescript

Last synced: 2 months ago
JSON representation

🌲 The HTTP client library of delight-rpc.

Awesome Lists containing this project

README

          

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

[delight-rpc]: https://www.npmjs.com/package/delight-rpc
[@delight-rpc/http-server]: https://www.npmjs.com/package/@delight-rpc/http-server

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

## Usage
```ts
interface IAPI {
echo(message: string): string
}

const [client] = createClient({
server: 'http://localhost:8080'
, keepalive: true
})

await client.echo('hello')
```

## API
```ts
interface IClientOptions {
server: string
timeout?: number
keepalive?: boolean
basicAuth?: {
username: string
password: string
}
}
```

### createClient
```ts
function createClient(
clientOptions: IClientOptions
, options?: {
parameterValidators?: DelightRPC.ParameterValidators
expectedVersion?: string
channel?: string
}
): [client: DelightRPC.ClientProxy, close: () => void]
```

### createBatchClient
```ts
function createBatchClient(
clientOptions: IClientOptions
, options?: {
expectedVersion?: string
channel?: string
}
): [client: DelightRPC.BatchClient, close: () => void]