Genesis
This commit is contained in:
28
src/config/env.js
Normal file
28
src/config/env.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const REQUIRED_ENV_VARS = ['EXA_API_KEY', 'OPENROUTER_API_KEY'];
|
||||
|
||||
export function getConfig() {
|
||||
return {
|
||||
port: Number(process.env.PORT) || 3000,
|
||||
host: process.env.HOST || '0.0.0.0',
|
||||
exaApiKey: process.env.EXA_API_KEY,
|
||||
openRouterApiKey: process.env.OPENROUTER_API_KEY,
|
||||
};
|
||||
}
|
||||
|
||||
export function validateConfig(config) {
|
||||
const missing = REQUIRED_ENV_VARS.filter((name) => !process.env[name]);
|
||||
|
||||
if (missing.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const name of missing) {
|
||||
console.error(`Error: ${name} environment variable is not set.`);
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user