mirror of
https://github.com/harivansh-afk/betterNAS.git
synced 2026-04-15 18:01:26 +00:00
25 lines
620 B
TypeScript
25 lines
620 B
TypeScript
export interface ControlPlaneConfig {
|
|
port: number;
|
|
version: string;
|
|
nextcloudBaseUrl: string;
|
|
}
|
|
|
|
export function loadConfig(env: NodeJS.ProcessEnv = process.env): ControlPlaneConfig {
|
|
const portValue = env.PORT ?? "3000";
|
|
const port = Number.parseInt(portValue, 10);
|
|
|
|
if (Number.isNaN(port)) {
|
|
throw new Error(`Invalid PORT value: ${portValue}`);
|
|
}
|
|
|
|
return {
|
|
port,
|
|
version: env.betternas_VERSION ?? "0.1.0-dev",
|
|
nextcloudBaseUrl: normalizeBaseUrl(env.NEXTCLOUD_BASE_URL ?? "http://nextcloud")
|
|
};
|
|
}
|
|
|
|
function normalizeBaseUrl(url: string): string {
|
|
return url.replace(/\/+$/, "");
|
|
}
|
|
|