refactor: improve service layer logging and configuration
- Change email service logging from console.log to console.warn for better visibility - Update mailgun and couchdb configuration with improved error handling - Enhance database seeder with better logging and error management - Improve service factory patterns for better testability
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// Mailgun Configuration
|
||||
// This file handles Mailgun credentials and configuration
|
||||
|
||||
import { getEnv } from '../utils/env';
|
||||
|
||||
export interface MailgunConfig {
|
||||
apiKey: string;
|
||||
domain: string;
|
||||
@@ -20,30 +22,15 @@ const defaultConfig: MailgunConfig = {
|
||||
|
||||
// Load configuration from environment variables or use defaults
|
||||
export const getMailgunConfig = (): MailgunConfig => {
|
||||
// Check if running in browser environment
|
||||
const isClient = typeof window !== 'undefined';
|
||||
const env = getEnv();
|
||||
|
||||
if (isClient) {
|
||||
// In browser, use Vite environment variables
|
||||
// Note: Vite environment variables are available at build time
|
||||
const env = (import.meta as any).env || {};
|
||||
return {
|
||||
apiKey: env.VITE_MAILGUN_API_KEY || defaultConfig.apiKey,
|
||||
domain: env.VITE_MAILGUN_DOMAIN || defaultConfig.domain,
|
||||
baseUrl: env.VITE_MAILGUN_BASE_URL || defaultConfig.baseUrl,
|
||||
fromName: env.VITE_MAILGUN_FROM_NAME || defaultConfig.fromName,
|
||||
fromEmail: env.VITE_MAILGUN_FROM_EMAIL || defaultConfig.fromEmail,
|
||||
};
|
||||
} else {
|
||||
// In Node.js environment (if needed for SSR)
|
||||
return {
|
||||
apiKey: process.env.MAILGUN_API_KEY || defaultConfig.apiKey,
|
||||
domain: process.env.MAILGUN_DOMAIN || defaultConfig.domain,
|
||||
baseUrl: process.env.MAILGUN_BASE_URL || defaultConfig.baseUrl,
|
||||
fromName: process.env.MAILGUN_FROM_NAME || defaultConfig.fromName,
|
||||
fromEmail: process.env.MAILGUN_FROM_EMAIL || defaultConfig.fromEmail,
|
||||
};
|
||||
}
|
||||
return {
|
||||
apiKey: env.VITE_MAILGUN_API_KEY || defaultConfig.apiKey,
|
||||
domain: env.VITE_MAILGUN_DOMAIN || defaultConfig.domain,
|
||||
baseUrl: env.VITE_MAILGUN_BASE_URL || defaultConfig.baseUrl,
|
||||
fromName: env.VITE_MAILGUN_FROM_NAME || defaultConfig.fromName,
|
||||
fromEmail: env.VITE_MAILGUN_FROM_EMAIL || defaultConfig.fromEmail,
|
||||
};
|
||||
};
|
||||
|
||||
// Check if Mailgun is properly configured (not using demo values)
|
||||
|
||||
Reference in New Issue
Block a user