Refactor Supabase client usage

Replaced various Supabase client imports with standardized admin and server clients across multiple files. This change ensures consistent and appropriate usage of admin and non-admin Supabase clients in server actions and services.
This commit is contained in:
gbuomprisco
2024-08-14 13:43:53 +02:00
parent ba6e649461
commit ff18a294ad
8 changed files with 29 additions and 32 deletions

View File

@@ -1,7 +1,7 @@
import 'server-only';
import { getLogger } from '@kit/shared/logger';
import { getSupabaseRouteHandlerClient } from '@kit/supabase/route-handler-client';
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
import { RecordChange, Tables } from '../record-change.type';
import { createDatabaseWebhookRouterService } from './database-webhook-router.service';
@@ -59,16 +59,12 @@ class DatabaseWebhookHandlerService {
await verifier.verifySignatureOrThrow(request);
// all good, handle the webhook
// all good, we can now the webhook
// create a client with admin access since we are handling webhooks
// and no user is authenticated
const client = getSupabaseRouteHandlerClient({
admin: true,
});
// create a client with admin access since we are handling webhooks and no user is authenticated
const adminClient = getSupabaseServerAdminClient();
// handle the webhook
const service = createDatabaseWebhookRouterService(client);
const service = createDatabaseWebhookRouterService(adminClient);
try {
// handle the webhook event based on the table