port-nimara-client-portal/server/plugins/eoi-reminders.ts

30 lines
943 B
TypeScript
Raw Normal View History

import { scheduleEOIReminders } from '~/server/tasks/eoi-reminders';
import { scheduleEmailProcessing } from '~/server/tasks/process-sales-emails';
export default defineNitroPlugin((nitroApp) => {
2025-06-10 14:05:09 +02:00
console.log('[Plugin] Initializing automated tasks...');
// Schedule EOI reminders when server starts
console.log('[Plugin] Initializing EOI reminder scheduler...');
// Add a small delay to ensure all services are ready
2025-06-10 14:05:09 +02:00
setTimeout(async () => {
try {
await scheduleEOIReminders();
} catch (error) {
console.error('[Plugin] Failed to schedule EOI reminders:', error);
}
}, 5000);
// Schedule email processing for EOI attachments
console.log('[Plugin] Initializing email processing scheduler...');
2025-06-10 14:05:09 +02:00
setTimeout(async () => {
try {
await scheduleEmailProcessing();
} catch (error) {
console.error('[Plugin] Failed to schedule email processing:', error);
}
}, 7000);
});