Skip to content

Commit 4d20bb9

Browse files
committed
Move suprabase admin method into pages/api utils directory and update imports
1 parent 8c2be24 commit 4d20bb9

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎src/pages/api/_utils/suprabase.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { createClient } from '@supabase/supabase-js'
2+
import { SUPABASE_URL } from 'astro:env/client'
3+
import { SUPABASE_SERVICE_ROLE_KEY } from 'astro:env/server'
4+
5+
// Admin client (server-side only, bypasses RLS)
6+
export const supabaseAdmin = createClient(
7+
SUPABASE_URL,
8+
SUPABASE_SERVICE_ROLE_KEY,
9+
{
10+
auth: {
11+
autoRefreshToken: false,
12+
persistSession: false
13+
}
14+
}
15+
)

‎src/pages/api/newsletter/_token.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Generates and validates confirmation tokens for GDPR-compliant newsletter signups
44
*/
55

6-
import { supabaseAdmin } from '@components/scripts/consent/db/supabase'
6+
import { supabaseAdmin } from '@pages/api/_utils'
77
import { ClientScriptError } from '@components/scripts/errors'
88

99
/**

‎src/pages/api/newsletter/confirm.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This is an Astro API route that runs server-side
55
*/
66
import type { APIRoute } from 'astro'
7-
import { supabaseAdmin } from '@components/scripts/consent/db/supabase'
7+
import { supabaseAdmin } from '@pages/api/_utils'
88

99
// These imports work in Astro API routes because they run server-side
1010
import { confirmSubscription } from './_token'

0 commit comments

Comments
 (0)