refactor(#29): centralise stripe client

This commit is contained in:
OllyNicholass
2024-09-17 19:29:43 +01:00
parent 49a9b079ea
commit 9089aa270b
9 changed files with 20 additions and 31 deletions
+4
View File
@@ -0,0 +1,4 @@
import Stripe from 'stripe'
import { STRIPE_SECRET_KEY } from '$env/static/private'
export const stripe = new Stripe(STRIPE_SECRET_KEY)
+2 -2
View File
@@ -1,8 +1,9 @@
import { createClient } from '@supabase/supabase-js';
import stripe from 'stripe';
import type { Database, Tables, TablesInsert } from '$lib/types/supabase';
import { PUBLIC_SUPABASE_URL, PUBLIC_STRIPE_SECRET_KEY } from '$env/static/public';
import { PUBLIC_SUPABASE_URL } from '$env/static/public';
import { SUPABASE_SERVICE_ROLE_KEY } from '$env/static/private';
import { stripe as stripeClient } from '$lib/utils/stripe';
const toDateTime = (secs: number) => {
const t = new Date(+0); // Unix epoch start.
@@ -10,7 +11,6 @@ const toDateTime = (secs: number) => {
return t;
};
const stripeClient = new stripe(PUBLIC_STRIPE_SECRET_KEY);
type Product = Tables<'products'>;
type Price = Tables<'prices'>;