- 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
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
// Mailgun Configuration
|
|
// This file handles Mailgun credentials and configuration
|
|
|
|
import { getEnv } from '../utils/env';
|
|
|
|
export interface MailgunConfig {
|
|
apiKey: string;
|
|
domain: string;
|
|
baseUrl: string;
|
|
fromName: string;
|
|
fromEmail: string;
|
|
}
|
|
|
|
// Default configuration for development
|
|
const defaultConfig: MailgunConfig = {
|
|
apiKey: 'demo-key',
|
|
domain: 'demo.mailgun.org',
|
|
baseUrl: 'https://api.mailgun.net/v3',
|
|
fromName: 'Medication Reminder',
|
|
fromEmail: 'noreply@demo.mailgun.org',
|
|
};
|
|
|
|
// Load configuration from environment variables or use defaults
|
|
export const getMailgunConfig = (): MailgunConfig => {
|
|
const env = getEnv();
|
|
|
|
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)
|
|
export const isMailgunConfigured = (): boolean => {
|
|
const config = getMailgunConfig();
|
|
return (
|
|
config.apiKey !== 'demo-key' &&
|
|
config.domain !== 'demo.mailgun.org' &&
|
|
config.apiKey.length > 0
|
|
);
|
|
};
|
|
|
|
// Development mode check
|
|
export const isDevelopmentMode = (): boolean => {
|
|
return !isMailgunConfigured();
|
|
};
|