Email Sorter Beta
Ich habe soweit automatisiert the Emails sortieren aber ich muss noch schauen was es fur bugs es gibt wenn die app online ist deswegen wurde ich mit diesen Commit die website veroffentlichen obwohjl es sein konnte das es noch nicht fertig ist und verkaufs bereit
This commit is contained in:
137
server/config/index.mjs
Normal file
137
server/config/index.mjs
Normal file
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* Application Configuration
|
||||
* Centralized configuration management
|
||||
*/
|
||||
|
||||
import { log } from '../middleware/logger.mjs'
|
||||
|
||||
/**
|
||||
* Environment configuration
|
||||
*/
|
||||
export const config = {
|
||||
// Server
|
||||
port: parseInt(process.env.PORT || '3000', 10),
|
||||
nodeEnv: process.env.NODE_ENV || 'development',
|
||||
isDev: process.env.NODE_ENV !== 'production',
|
||||
isProd: process.env.NODE_ENV === 'production',
|
||||
|
||||
// URLs
|
||||
baseUrl: process.env.BASE_URL || 'http://localhost:3000',
|
||||
frontendUrl: process.env.FRONTEND_URL || 'http://localhost:5173',
|
||||
|
||||
// Appwrite
|
||||
appwrite: {
|
||||
endpoint: process.env.APPWRITE_ENDPOINT,
|
||||
projectId: process.env.APPWRITE_PROJECT_ID,
|
||||
apiKey: process.env.APPWRITE_API_KEY,
|
||||
databaseId: process.env.APPWRITE_DATABASE_ID,
|
||||
},
|
||||
|
||||
// Stripe
|
||||
stripe: {
|
||||
secretKey: process.env.STRIPE_SECRET_KEY,
|
||||
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
|
||||
prices: {
|
||||
basic: process.env.STRIPE_PRICE_BASIC || 'price_basic_monthly',
|
||||
pro: process.env.STRIPE_PRICE_PRO || 'price_pro_monthly',
|
||||
business: process.env.STRIPE_PRICE_BUSINESS || 'price_business_monthly',
|
||||
},
|
||||
},
|
||||
|
||||
// Google OAuth
|
||||
google: {
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
redirectUri: process.env.GOOGLE_REDIRECT_URI || 'http://localhost:3000/api/oauth/gmail/callback',
|
||||
},
|
||||
|
||||
// Microsoft OAuth
|
||||
microsoft: {
|
||||
clientId: process.env.MICROSOFT_CLIENT_ID,
|
||||
clientSecret: process.env.MICROSOFT_CLIENT_SECRET,
|
||||
redirectUri: process.env.MICROSOFT_REDIRECT_URI || 'http://localhost:3000/api/oauth/outlook/callback',
|
||||
},
|
||||
|
||||
// Mistral AI
|
||||
mistral: {
|
||||
apiKey: process.env.MISTRAL_API_KEY,
|
||||
},
|
||||
|
||||
// Rate Limiting
|
||||
rateLimit: {
|
||||
windowMs: parseInt(process.env.RATE_LIMIT_WINDOW_MS || '60000', 10),
|
||||
max: parseInt(process.env.RATE_LIMIT_MAX || '100', 10),
|
||||
},
|
||||
|
||||
// CORS
|
||||
cors: {
|
||||
origin: process.env.CORS_ORIGIN || process.env.FRONTEND_URL || 'http://localhost:5173',
|
||||
credentials: true,
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Required environment variables
|
||||
*/
|
||||
const requiredVars = [
|
||||
'APPWRITE_ENDPOINT',
|
||||
'APPWRITE_PROJECT_ID',
|
||||
'APPWRITE_API_KEY',
|
||||
'APPWRITE_DATABASE_ID',
|
||||
'STRIPE_SECRET_KEY',
|
||||
'STRIPE_WEBHOOK_SECRET',
|
||||
]
|
||||
|
||||
/**
|
||||
* Optional but recommended variables
|
||||
*/
|
||||
const recommendedVars = [
|
||||
'MISTRAL_API_KEY',
|
||||
'GOOGLE_CLIENT_ID',
|
||||
'MICROSOFT_CLIENT_ID',
|
||||
]
|
||||
|
||||
/**
|
||||
* Validate configuration
|
||||
*/
|
||||
export function validateConfig() {
|
||||
const missing = []
|
||||
const warnings = []
|
||||
|
||||
// Check required variables
|
||||
for (const varName of requiredVars) {
|
||||
if (!process.env[varName]) {
|
||||
missing.push(varName)
|
||||
}
|
||||
}
|
||||
|
||||
if (missing.length > 0) {
|
||||
log.error(`Fehlende Umgebungsvariablen: ${missing.join(', ')}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Check recommended variables
|
||||
for (const varName of recommendedVars) {
|
||||
if (!process.env[varName]) {
|
||||
warnings.push(varName)
|
||||
}
|
||||
}
|
||||
|
||||
if (warnings.length > 0) {
|
||||
log.warn(`Optionale Variablen fehlen: ${warnings.join(', ')}`)
|
||||
}
|
||||
|
||||
log.success('Konfiguration validiert')
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature flags based on available config
|
||||
*/
|
||||
export const features = {
|
||||
gmail: () => Boolean(config.google.clientId && config.google.clientSecret),
|
||||
outlook: () => Boolean(config.microsoft.clientId && config.microsoft.clientSecret),
|
||||
ai: () => Boolean(config.mistral.apiKey),
|
||||
}
|
||||
|
||||
export default config
|
||||
Reference in New Issue
Block a user