mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
28 lines
969 B
TypeScript
28 lines
969 B
TypeScript
import dotenv from 'dotenv';
|
|
|
|
export const getEnv = (env: string | undefined, defaultValue?: string, required?: boolean) => {
|
|
if (required && !env && !defaultValue) {
|
|
throw new Error(`Missing required environment variable: ${env}`);
|
|
}
|
|
|
|
return env ?? defaultValue;
|
|
}
|
|
|
|
export const getEnvBoolean = (env: string | undefined, defaultValue: boolean) => {
|
|
if (!env) {
|
|
return defaultValue;
|
|
}
|
|
return env === 'true' || env === '1';
|
|
}
|
|
|
|
dotenv.config({
|
|
path: './.env',
|
|
});
|
|
|
|
|
|
export const SOURCEBOT_LOG_LEVEL = getEnv(process.env.SOURCEBOT_LOG_LEVEL, 'info')!;
|
|
export const SOURCEBOT_TELEMETRY_DISABLED = getEnvBoolean(process.env.SOURCEBOT_TELEMETRY_DISABLED, false)!;
|
|
export const SOURCEBOT_INSTALL_ID = getEnv(process.env.SOURCEBOT_INSTALL_ID, 'unknown')!;
|
|
export const SOURCEBOT_VERSION = getEnv(process.env.SOURCEBOT_VERSION, 'unknown')!;
|
|
export const POSTHOG_PAPIK = getEnv(process.env.POSTHOG_PAPIK);
|
|
export const POSTHOG_HOST = getEnv(process.env.POSTHOG_HOST);
|