Initial commit: Complete NodeJS-native setup
- Migrated from Python pre-commit to NodeJS-native solution - Reorganized documentation structure - Set up Husky + lint-staged for efficient pre-commit hooks - Fixed Dockerfile healthcheck issue - Added comprehensive documentation index
This commit is contained in:
62
services/mailgun.config.ts
Normal file
62
services/mailgun.config.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
// Mailgun Configuration
|
||||
// This file handles Mailgun credentials and configuration
|
||||
|
||||
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 => {
|
||||
// Check if running in browser environment
|
||||
const isClient = typeof window !== 'undefined';
|
||||
|
||||
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,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// 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();
|
||||
};
|
||||
Reference in New Issue
Block a user