forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem-client.ts
More file actions
37 lines (33 loc) · 1.2 KB
/
Copy pathsystem-client.ts
File metadata and controls
37 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { HealthStatus, ServiceInfo } from '../models';
import type { SystemClientContract } from '../types/contracts';
import type { ResolvedLilySdkConfig } from '../config/types';
import type { HttpClient } from '../http/types';
import { BaseClient } from './base-client';
import { validateHealthStatus } from '../validation/health-status';
export class SystemClient extends BaseClient implements SystemClientContract {
private readonly validateResponses: boolean;
public constructor(httpClientOrConfig: HttpClient | ResolvedLilySdkConfig) {
super(httpClientOrConfig);
if ('validateResponses' in httpClientOrConfig) {
this.validateResponses = (httpClientOrConfig as ResolvedLilySdkConfig).validateResponses ?? false;
} else {
this.validateResponses = false;
}
}
public async health(): Promise<HealthStatus> {
const data = await this.request<HealthStatus>({
method: 'GET',
path: '/v1/system/health',
});
if (this.validateResponses) {
return validateHealthStatus(data) as unknown as HealthStatus;
}
return data;
}
public info(): Promise<ServiceInfo> {
return this.request({
method: 'GET',
path: '/v1/system/info',
});
}
}