30 lines
695 B
JavaScript
30 lines
695 B
JavaScript
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,
|
|
maintenanceMode: process.env.MAINTENANCE_MODE === 'true',
|
|
};
|
|
}
|
|
|
|
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);
|
|
}
|