fp/services/scout/src/config.ts

36 lines
740 B
TypeScript

import 'dotenv/config'
const requiredEnvVars = [
'HTTP_PROXY',
'POSTGREST_URL',
'NODE_ENV',
'WORKER_CONNECTION_STRING',
'PORT',
] as const;
const getEnvVar = (key: typeof requiredEnvVars[number]): string => {
const value = process.env[key];
if (!value) {
throw new Error(`Missing ${key} env var`);
}
return value;
};
export interface Config {
postgrestUrl: string;
httpProxy: string;
nodeEnv: string;
workerConnectionString: string;
port: number;
}
export const configs: Config = {
httpProxy: getEnvVar('HTTP_PROXY'),
postgrestUrl: getEnvVar('POSTGREST_URL'),
nodeEnv: getEnvVar('NODE_ENV'),
workerConnectionString: getEnvVar('WORKER_CONNECTION_STRING'),
port: parseInt(getEnvVar('PORT')),
}