mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 16:23:23 +00:00
Migrate dev server from MongoDB to SQLite
- Replace mongooseAdapter with sqliteAdapter in payload config - Update database configuration to use file:./dev.db - Remove MongoDB memory database helper and references - Simplify start script by removing verbose logging and MongoDB messaging - Fix email processing with immediate send support and proper queue handling - Restructure app with route groups for frontend/admin separation - Add dashboard and test pages for email management - Update API routes for improved email processing and testing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { getPayload } from 'payload'
|
||||
import config from '@payload-config'
|
||||
import { sendEmail } from '@xtr-dev/payload-mailing'
|
||||
import { sendEmail, processEmailById } from '@xtr-dev/payload-mailing'
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
@@ -41,10 +41,33 @@ export async function POST(request: Request) {
|
||||
|
||||
const result = await sendEmail(payload, emailOptions)
|
||||
|
||||
// If it's "send now" (not scheduled), process the email immediately
|
||||
if (type === 'send' && !scheduledAt) {
|
||||
try {
|
||||
await processEmailById(payload, String(result.id))
|
||||
return Response.json({
|
||||
success: true,
|
||||
emailId: result.id,
|
||||
message: 'Email sent successfully',
|
||||
status: 'sent'
|
||||
})
|
||||
} catch (processError) {
|
||||
// If immediate processing fails, return that it's queued
|
||||
console.warn('Failed to process email immediately, left in queue:', processError)
|
||||
return Response.json({
|
||||
success: true,
|
||||
emailId: result.id,
|
||||
message: 'Email queued successfully (immediate processing failed)',
|
||||
status: 'queued'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
success: true,
|
||||
emailId: result.id,
|
||||
message: scheduledAt ? 'Email scheduled successfully' : 'Email queued successfully',
|
||||
status: scheduledAt ? 'scheduled' : 'queued'
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Test email error:', error)
|
||||
|
||||
Reference in New Issue
Block a user