-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathconfig.js
More file actions
71 lines (61 loc) · 2.34 KB
/
config.js
File metadata and controls
71 lines (61 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import dotenv from 'dotenv';
// Load .env file only in development mode (not in production or test)
// In test/CI environments, rely on environment variables passed from the parent process
try {
dotenv.config();
console.log('✅ Loaded environment variables from .env file');
} catch (error) {
console.log('No .env file found, using environment variables directly');
}
// Debug: Log environment variable status
console.log('🔧 Backend environment variable status:');
console.log(` - NODE_ENV: ${process.env.NODE_ENV}`);
console.log(` - GEMINI_API_KEY: ${process.env.GEMINI_API_KEY ? '✅ Set' : '❌ Missing'}`);
console.log(` - PORT: ${process.env.PORT || 'default (3001)'}`);
// Validate required environment variables
const requiredEnvVars = [
'GEMINI_API_KEY',
];
const missingEnvVars = requiredEnvVars.filter(envVar => !process.env[envVar]);
if (missingEnvVars.length > 0) {
console.error('❌ Missing required environment variables:');
missingEnvVars.forEach(envVar => console.error(` - ${envVar}`));
console.error('Please check your .env file (for local development) or environment variables (for CI/production) and ensure all required variables are set.');
process.exit(1);
}
export const config = {
// OpenAI Configuration
openai: {
apiKey: process.env.OPENAI_API_KEY,
model: process.env.OPENAI_MODEL || 'gpt-4',
maxTokens: parseInt(process.env.OPENAI_MAX_TOKENS) || 1000,
temperature: parseFloat(process.env.OPENAI_TEMPERATURE) || 0.7
},
// Gemini Configuration
gemini: {
apiKey: process.env.GEMINI_API_KEY,
model: process.env.GEMINI_MODEL || 'gemini-1.5-pro',
maxTokens: parseInt(process.env.GEMINI_MAX_TOKENS) || 1000,
temperature: parseFloat(process.env.GEMINI_TEMPERATURE) || 0.7
},
// Notion Configuration
notion: {
apiKey: process.env.NOTION_API_KEY
},
// Firecrawl Configuration
firecrawl: {
apiKey: process.env.FIRECRAWL_API_KEY
},
// Server Configuration
server: {
port: parseInt(process.env.PORT) || 3001,
nodeEnv: process.env.NODE_ENV || 'development'
},
// CORS Configuration
cors: {
allowedOrigins: process.env.ALLOWED_ORIGINS?.split(',') || [
'http://localhost:5173',
'http://localhost:3000'
]
}
};