Refactored classes according to new convention

This commit is contained in:
giancarlo
2024-04-23 00:10:12 +08:00
parent 70da6ef1fa
commit 17e0781581
30 changed files with 351 additions and 131 deletions

View File

@@ -1,5 +1,6 @@
import { SupabaseClient } from '@supabase/supabase-js';
import { createBillingWebhooksService } from '@kit/billing-gateway';
import { getLogger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database';
@@ -42,11 +43,11 @@ export class DatabaseWebhookRouterService {
}
private async handleInvitationsWebhook(body: RecordChange<'invitations'>) {
const { AccountInvitationsWebhookService } = await import(
const { createAccountInvitationsWebhookService } = await import(
'@kit/team-accounts/webhooks'
);
const service = new AccountInvitationsWebhookService(this.adminClient);
const service = createAccountInvitationsWebhookService(this.adminClient);
return service.handleInvitationWebhook(body.record);
}
@@ -54,22 +55,25 @@ export class DatabaseWebhookRouterService {
private async handleSubscriptionsWebhook(
body: RecordChange<'subscriptions'>,
) {
const { BillingWebhooksService } = await import('@kit/billing-gateway');
const service = new BillingWebhooksService();
if (body.type === 'DELETE' && body.old_record) {
const { createBillingWebhooksService } = await import(
'@kit/billing-gateway'
);
const service = createBillingWebhooksService();
return service.handleSubscriptionDeletedWebhook(body.old_record);
}
}
private async handleAccountsWebhook(body: RecordChange<'accounts'>) {
const { AccountWebhooksService } = await import(
'@kit/team-accounts/webhooks'
);
const service = new AccountWebhooksService();
if (body.type === 'DELETE' && body.old_record) {
const { createAccountWebhooksService } = await import(
'@kit/team-accounts/webhooks'
);
const service = createAccountWebhooksService();
return service.handleAccountDeletedWebhook(body.old_record);
}
}