* fix: getEnv not returning fallback API_URL breaking examples app * refactor: use vite as the only way to build atoms * refactor: web use atoms from web.ts and rest from dist * refactor: update atoms version, description and set privacy to public * fix: lib and ui import from web atoms * refactor: rename @calcom/platform-atoms to @calcom/atoms * feat: atoms as npm works with example app outside monorepo * start atoms from v1.0.0 * refactor: monorepo atoms for internal use * document atoms publishing * refactor: remove unused import in v2 * fix: mistakes made during main merge * refactor: move back examples app while still having it in atoms-examples repo * refactor: monorepo examples readme * feat: atoms yarn publish command * refactor: atoms css file simplify * fix: mocking atoms in ui unit test * fix: mocking atoms in app-store unit test
29 lines
692 B
TypeScript
29 lines
692 B
TypeScript
import { logLevels } from "@/lib/logger";
|
|
|
|
export type Environment = {
|
|
NODE_ENV: "development" | "production";
|
|
API_PORT: string;
|
|
API_URL: string;
|
|
DATABASE_READ_URL: string;
|
|
DATABASE_WRITE_URL: string;
|
|
NEXTAUTH_SECRET: string;
|
|
DATABASE_URL: string;
|
|
JWT_SECRET: string;
|
|
SENTRY_DNS: string;
|
|
LOG_LEVEL: keyof typeof logLevels;
|
|
REDIS_URL: string;
|
|
};
|
|
|
|
export const getEnv = <K extends keyof Environment>(key: K, fallback?: Environment[K]): Environment[K] => {
|
|
const value = process.env[key] as Environment[K] | undefined;
|
|
|
|
if (!value) {
|
|
if (fallback) {
|
|
return fallback;
|
|
}
|
|
throw new Error(`Missing environment variable: ${key}.`);
|
|
}
|
|
|
|
return value;
|
|
};
|