35 lines
737 B
Markdown
35 lines
737 B
Markdown
|
|
# @serve.zone/api
|
||
|
|
|
||
|
|
Type-safe API client for Cloudly and the serve.zone control plane.
|
||
|
|
|
||
|
|
## Install
|
||
|
|
|
||
|
|
```bash
|
||
|
|
pnpm add @serve.zone/api
|
||
|
|
```
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { CloudlyApiClient } from '@serve.zone/api';
|
||
|
|
|
||
|
|
const client = new CloudlyApiClient({
|
||
|
|
registerAs: 'api',
|
||
|
|
cloudlyUrl: 'https://cloudly.example.com:443',
|
||
|
|
});
|
||
|
|
|
||
|
|
await client.start();
|
||
|
|
|
||
|
|
const identity = await client.getIdentityByToken('service-token', {
|
||
|
|
tagConnection: true,
|
||
|
|
statefullIdentity: true,
|
||
|
|
});
|
||
|
|
|
||
|
|
const clusterConfig = await client.getClusterConfigFromCloudlyByIdentity(identity);
|
||
|
|
```
|
||
|
|
|
||
|
|
## Notes
|
||
|
|
|
||
|
|
- The client uses TypedSocket for WebSocket RPC and TypedRequest for HTTP fallback in selected methods.
|
||
|
|
- Shared contracts are provided by `@serve.zone/interfaces`.
|