feat: get env variables safely
This commit is contained in:
8
server/src/utils/env.ts
Normal file
8
server/src/utils/env.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// Helper function to get environment variables and throw an error if they are not set
|
||||
export const getEnvVariable = (key: string, defaultValue?: string): string => {
|
||||
const value = process.env[key] || defaultValue;
|
||||
if (!value) {
|
||||
throw new Error(`Environment variable ${key} is not defined`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
Reference in New Issue
Block a user