Split oversized frontend API client, email service, and admin/booking pages into focused modules while preserving import surfaces, and add Redis-backed queues, stale booking cleanup, stronger auth, and scale deployment configs. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
// Email service for Spanglish platform
|
|
// Supports multiple email providers: Resend, SMTP (Nodemailer)
|
|
//
|
|
// This module is a thin facade. The implementation is split across ./email/*:
|
|
// - transport: provider config, SMTP, low-level sendEmail, diagnostics
|
|
// - formatting: common variables, timezone, date/time/currency helpers
|
|
// - templateService: template DB access, seeding, template/custom send + logging
|
|
// - bookingEmails: booking confirmation
|
|
// - paymentEmails: receipt, instructions, rejection, reminder, payment config
|
|
// - bulkEmails: event-wide queued sends
|
|
|
|
import { sendEmail, getProviderInfo, testConnection } from './email/transport.js';
|
|
import {
|
|
getCommonVariables,
|
|
getSiteTimezone,
|
|
formatDate,
|
|
formatTime,
|
|
formatCurrency,
|
|
} from './email/formatting.js';
|
|
import {
|
|
getTemplate,
|
|
seedDefaultTemplates,
|
|
sendTemplateEmail,
|
|
sendCustomEmail,
|
|
resendFromLog,
|
|
} from './email/templateService.js';
|
|
import { sendBookingConfirmation } from './email/bookingEmails.js';
|
|
import {
|
|
sendPaymentReceipt,
|
|
getPaymentConfig,
|
|
sendPaymentInstructions,
|
|
sendPaymentRejectionEmail,
|
|
sendPaymentReminder,
|
|
} from './email/paymentEmails.js';
|
|
import { queueEventEmails } from './email/bulkEmails.js';
|
|
|
|
export const emailService = {
|
|
// Diagnostics
|
|
getProviderInfo,
|
|
testConnection,
|
|
// Formatting / variables
|
|
getCommonVariables,
|
|
getSiteTimezone,
|
|
formatDate,
|
|
formatTime,
|
|
formatCurrency,
|
|
// Templates + core sending
|
|
getTemplate,
|
|
seedDefaultTemplates,
|
|
sendTemplateEmail,
|
|
sendCustomEmail,
|
|
resendFromLog,
|
|
// Domain senders
|
|
sendBookingConfirmation,
|
|
sendPaymentReceipt,
|
|
getPaymentConfig,
|
|
sendPaymentInstructions,
|
|
sendPaymentRejectionEmail,
|
|
sendPaymentReminder,
|
|
// Bulk
|
|
queueEventEmails,
|
|
};
|
|
|
|
// Export the main sendEmail function for direct use
|
|
export { sendEmail };
|
|
|
|
export default emailService;
|