Carnero.Dev uses Supabase as its backend-as-a-service layer for persisting team registration data. The Supabase client is initialized once as a singleton inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/moradoadrian/carneroDev/llms.txt
Use this file to discover all available pages before exploring further.
src/lib/supabase.ts and imported directly by the server-side API route. This keeps database access centralized and avoids creating redundant connections across the application.
Client Initialization
The Supabase client is created withcreateClient from @supabase/supabase-js, passing the project URL and the publishable anon key. The resulting supabase instance is exported as a named singleton so any server-side module can import it without re-initializing the connection.
src/lib/supabase.ts
In production, the URL and key should be read from environment variables (
SUPABASE_URL and SUPABASE_ANON_KEY) rather than hardcoded. See the Environment Setup guide.Database Schema
The registration endpoint inserts records into aregistrations table. Each row captures the team identity, the representative contact, the team size, and a server-generated timestamp. The members_count column enforces a check constraint so only values between 1 and 4 are accepted at the database level, providing a second line of defense after the server-side validation in the API route.
Inserting a Registration
After all server-side validation passes, the API route callssupabase.from('registrations').insert() with the parsed payload. The operation is destructured to capture only the error field — a null error means the row was committed successfully. If dbError is truthy, the server logs the raw Supabase error object and immediately returns a 500 response to the client; no email is sent in that case.
Error Handling
When Supabase returns an error on insert, the API route takes three steps:- Logs the raw error to the server console with the
[SUPABASE_DB_INSERT_ERROR]prefix, making it easy to filter in production logs. - Returns a
500response whose JSON body contains anerrorstring prefixed with[ERROR_DE_SISTEMA]:followed by the Supabase error message. - Halts the request pipeline — the Resend email step is never reached, so no confirmation is dispatched for a registration that was not saved.
RegisterModal.astro script catches any non-2xx response and renders the error string inside the modal’s red error panel (#registration-error), surfacing the failure message directly to the user without a page reload.