Pierre HUBERT
b7720df305
All checks were successful
continuous-integration/drone/push Build is passing
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import { APIClient } from "./ApiClient";
|
|
|
|
export interface ServerConfig {
|
|
auth_disabled: boolean;
|
|
constraints: ServerConstraint;
|
|
unsecure_origin: string;
|
|
backend_version: string;
|
|
}
|
|
|
|
export interface ServerConstraint {
|
|
dev_name_len: LenConstraint;
|
|
dev_description_len: LenConstraint;
|
|
relay_name_len: LenConstraint;
|
|
relay_priority: LenConstraint;
|
|
relay_consumption: LenConstraint;
|
|
relay_minimal_uptime: LenConstraint;
|
|
relay_minimal_downtime: LenConstraint;
|
|
relay_daily_minimal_runtime: LenConstraint;
|
|
}
|
|
|
|
export interface LenConstraint {
|
|
min: number;
|
|
max: number;
|
|
}
|
|
|
|
let config: ServerConfig | null = null;
|
|
|
|
export class ServerApi {
|
|
/**
|
|
* Get server configuration
|
|
*/
|
|
static async LoadConfig(): Promise<void> {
|
|
config = (
|
|
await APIClient.exec({
|
|
uri: "/server/config",
|
|
method: "GET",
|
|
})
|
|
).data;
|
|
}
|
|
|
|
/**
|
|
* Get cached configuration
|
|
*/
|
|
static get Config(): ServerConfig {
|
|
if (config === null) throw new Error("Missing configuration!");
|
|
return config;
|
|
}
|
|
}
|