Refactor API code and simplify billing display

The code in the webhook API has been refactored to move the DatabaseWebhookHandlerService instance out of the POST function scope. Furthermore, the display of renewal plan details on the billing page has been simplified and certain parts deemed superfluous have been removed. Numerous types and interfaces in the database.types.ts file have also been corrected and formatted for consistency and improved readability.
This commit is contained in:
giancarlo
2024-03-31 15:13:44 +08:00
parent 2c0c616a2d
commit aa12ecd5a2
10 changed files with 1133 additions and 1026 deletions

View File

@@ -6,18 +6,18 @@
create trigger "accounts_memberships_insert" after insert
on "public"."accounts_memberships" for each row
execute function "supabase_functions"."http_request"(
'http://localhost:3000/api/database/webhook',
'http://host.docker.internal:3000/api/database/webhook',
'POST',
'{"Content-Type":"application/json", "X-Supabase-Event-Signature":"WEBHOOKSECRET"}',
'{}',
'1000'
);
-- this webhook will be triggered after every insert on the accounts_memberships table
create trigger "account_membership_delete" after insert
-- this webhook will be triggered after every delete on the accounts_memberships table
create trigger "account_membership_delete" after delete
on "public"."accounts_memberships" for each row
execute function "supabase_functions"."http_request"(
'http://localhost:3000/api/database/webhook',
'http://host.docker.internal:3000/api/database/webhook',
'POST',
'{"Content-Type":"application/json", "X-Supabase-Event-Signature":"WEBHOOKSECRET"}',
'{}',
@@ -29,7 +29,19 @@ execute function "supabase_functions"."http_request"(
create trigger "account_delete" after delete
on "public"."subscriptions" for each row
execute function "supabase_functions"."http_request"(
'http://localhost:3000/api/database/webhook',
'http://host.docker.internal:3000/api/database/webhook',
'POST',
'{"Content-Type":"application/json", "X-Supabase-Event-Signature":"WEBHOOKSECRET"}',
'{}',
'1000'
);
-- this webhook will be triggered after every insert on the invitations table
-- which should happen when a user invites someone to their account
create trigger "invitations_insert" after insert
on "public"."invitations" for each row
execute function "supabase_functions"."http_request"(
'http://host.docker.internal:3000/api/database/webhook',
'POST',
'{"Content-Type":"application/json", "X-Supabase-Event-Signature":"WEBHOOKSECRET"}',
'{}',