2024-06-29 12:43:56 +00:00
|
|
|
import { APIClient } from "./ApiClient";
|
|
|
|
|
|
|
|
export interface ServerConfig {
|
|
|
|
auth_disabled: boolean;
|
2024-07-22 20:19:48 +00:00
|
|
|
constraints: ServerConstraint;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ServerConstraint {
|
|
|
|
dev_name_len: LenConstraint;
|
|
|
|
dev_description_len: LenConstraint;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface LenConstraint {
|
|
|
|
min: number;
|
|
|
|
max: number;
|
2024-06-29 12:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|