Refactored Supabase Clients using the new recommended approach by Supabase by centralizing all clients around one single implementation. (#51)

The previous clients have been marked as deprecated and will be removed at some point.
This commit is contained in:
Giancarlo Buomprisco
2024-08-14 17:13:59 +08:00
committed by GitHub
parent 2f0c4b4ae3
commit ba6e649461
41 changed files with 209 additions and 168 deletions

View File

@@ -3,7 +3,7 @@
import { redirect } from 'next/navigation';
import { enhanceAction } from '@kit/next/actions';
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import featureFlagsConfig from '~/config/feature-flags.config';
@@ -30,7 +30,7 @@ export const createTeamAccountCheckoutSession = enhanceAction(
throw new Error('Team account billing is not enabled');
}
const client = getSupabaseServerActionClient();
const client = getSupabaseServerClient();
const service = createTeamBillingService(client);
return service.createCheckout(data);
@@ -53,7 +53,7 @@ export const createBillingPortalSession = enhanceAction(
const params = TeamBillingPortalSchema.parse(Object.fromEntries(formData));
const client = getSupabaseServerActionClient();
const client = getSupabaseServerClient();
const service = createTeamBillingService(client);
// get url to billing portal

View File

@@ -8,7 +8,7 @@ import { LineItemSchema } from '@kit/billing';
import { getBillingGatewayProvider } from '@kit/billing-gateway';
import { getLogger } from '@kit/shared/logger';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { createTeamAccountsApi } from '@kit/team-accounts/api';
import appConfig from '~/config/app.config';
@@ -150,7 +150,7 @@ class TeamBillingService {
accountId: string;
slug: string;
}) {
const client = getSupabaseServerActionClient();
const client = getSupabaseServerClient();
const logger = await getLogger();
logger.info(