mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-15 03:53:48 +00:00
feat(#32): Strongly type the price.type
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import { stripe as stripeClient } from '$lib/utils/stripe';
|
import { stripe as stripeClient } from '$lib/utils/stripe';
|
||||||
|
import Stripe from 'stripe';
|
||||||
|
|
||||||
export const GET = async ({ params }) => {
|
export const GET = async ({ params }) => {
|
||||||
const { productId } = params;
|
const { productId } = params;
|
||||||
@@ -7,7 +8,7 @@ export const GET = async ({ params }) => {
|
|||||||
|
|
||||||
const price = await stripeClient.prices.retrieve(product.default_price);
|
const price = await stripeClient.prices.retrieve(product.default_price);
|
||||||
|
|
||||||
const isSubscription = price.type === 'recurring';
|
const isSubscription = (price.type as Stripe.Price.type) === 'recurring';
|
||||||
product.isSubscription = isSubscription;
|
product.isSubscription = isSubscription;
|
||||||
return json(product);
|
return json(product);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user