1- import { z } from 'zod' ;
2-
31export enum TierIds {
42 HOBBY = 'hobby-tier' ,
53 PRO = 'pro-tier' ,
@@ -8,38 +6,3 @@ export enum TierIds {
86
97export const DOCS_URL = 'https://docs.opensaas.sh' ;
108export const BLOG_URL = 'https://docs.opensaas.sh/blog' ;
11-
12- const isDevEnv = process . env . NODE_ENV !== 'production' ;
13- const customerPortalTestUrl = '<your-url-here>' ; // TODO: find your test url at https://dashboard.stripe.com/test/settings/billing/portal
14- const customerPortalProdUrl = '<your-url-here>' ; // TODO: add before deploying to production
15-
16- export const STRIPE_CUSTOMER_PORTAL_LINK = isDevEnv ? customerPortalTestUrl : customerPortalProdUrl ;
17-
18- checkStripePortalLinksExist ( { customerPortalTestUrl, customerPortalProdUrl } ) ;
19-
20- type StripePortalUrls = {
21- customerPortalTestUrl : string | undefined ;
22- customerPortalProdUrl : string | undefined ;
23- } ;
24-
25- function checkStripePortalLinksExist ( links : StripePortalUrls ) {
26- const schema = z . string ( ) . url ( ) ;
27- const testResult = schema . safeParse ( links . customerPortalTestUrl ) ;
28- const prodResult = schema . safeParse ( links . customerPortalProdUrl ) ;
29- let consoleMsg = {
30- color : '\x1b[33m%s\x1b[0m' ,
31- msg : '' ,
32- } ;
33-
34- if ( testResult . success && prodResult . success ) {
35- consoleMsg . color = '\x1b[32m%s\x1b[0m' ;
36- consoleMsg . msg = '✅ Both STRIPE_CUSTOMER_PORTAL_LINK links defined' ;
37- } else if ( ! testResult . success && ! prodResult . success ) {
38- consoleMsg . msg = '⛔️ STRIPE_CUSTOMER_PORTAL_LINK is not defined' ;
39- } else if ( ! testResult . success ) {
40- consoleMsg . msg = '⛔️ STRIPE_CUSTOMER_PORTAL_LINK is not defined for test env' ;
41- } else {
42- consoleMsg . msg = '⛔️ STRIPE_CUSTOMER_PORTAL_LINK is not defined for prod env' ;
43- }
44- console . log ( consoleMsg . color , consoleMsg . msg ) ;
45- }
0 commit comments