Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-23 20:56:28 +00:00
co-authored by renee-png
parent 4be30bb189
commit d8563bff2f
+7 -2
View File
@@ -2,6 +2,11 @@ import { sendLovableEmail } from '@lovable.dev/email-js'
import { createClient } from '@supabase/supabase-js'
import { createFileRoute } from '@tanstack/react-router'
// The email infra tables (email_send_log, email_send_state, etc.) are not in
// the generated Database types, so we use an untyped client throughout this
// route. Tables are created by the email infra migration.
type AnyClient = ReturnType<typeof createClient<any, any, any>>
const MAX_RETRIES = 5
const DEFAULT_BATCH_SIZE = 10
const DEFAULT_SEND_DELAY_MS = 200
@@ -37,7 +42,7 @@ function getRetryAfterSeconds(error: unknown): number {
// Move a message to the dead letter queue and log the reason.
async function moveToDlq(
supabase: ReturnType<typeof createClient>,
supabase: AnyClient,
queue: string,
msg: { msg_id: number; message: Record<string, unknown> },
reason: string
@@ -89,7 +94,7 @@ export const Route = createFileRoute("/lovable/email/queue/process")({
return Response.json({ error: 'Forbidden' }, { status: 403 })
}
const supabase = createClient(supabaseUrl, supabaseServiceKey)
const supabase = createClient<any, any, any>(supabaseUrl, supabaseServiceKey)
// 1. Check rate-limit cooldown and read queue config
const { data: state } = await supabase