Skip to content

Fix imports to avoid client-side errors #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion template/app/src/payment/lemonSqueezy/paymentProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CreateCheckoutSessionArgs, FetchCustomerPortalUrlArgs, PaymentProcessor } from '../paymentProcessor';
import { requireNodeEnvVar } from '../../server/utils';
import { requireNodeEnvVar } from '../../server/envUtils';
import { createLemonSqueezyCheckoutSession } from './checkoutUtils';
import { lemonSqueezyWebhook, lemonSqueezyMiddlewareConfigFn } from './webhook';
import { lemonSqueezySetup } from '@lemonsqueezy/lemonsqueezy.js';
Expand Down
4 changes: 2 additions & 2 deletions template/app/src/payment/lemonSqueezy/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { paymentPlans, PaymentPlanId } from '../plans';
import { updateUserLemonSqueezyPaymentDetails } from './paymentDetails';
import { type Order, type Subscription, getCustomer } from '@lemonsqueezy/lemonsqueezy.js';
import crypto from 'crypto';
import { requireNodeEnvVar } from '../../server/utils';
import { requireNodeEnvVar } from '../../server/envUtils';


export const lemonSqueezyWebhook: PaymentsWebhook = async (request, response, context) => {
Expand Down Expand Up @@ -198,4 +198,4 @@ function getPlanIdByVariantId(variantId: string): PaymentPlanId {
throw new Error(`No plan with LemonSqueezy variant id ${variantId}`);
}
return planId;
}
}
2 changes: 1 addition & 1 deletion template/app/src/payment/plans.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { requireNodeEnvVar } from '../server/utils';
import { requireNodeEnvVar } from '../server/envUtils';

export type SubscriptionStatus = 'past_due' | 'cancel_at_period_end' | 'active' | 'deleted';

Expand Down
2 changes: 1 addition & 1 deletion template/app/src/payment/stripe/paymentProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PaymentPlanEffect } from '../plans';
import type { CreateCheckoutSessionArgs, FetchCustomerPortalUrlArgs, PaymentProcessor } from '../paymentProcessor'
import { fetchStripeCustomer, createStripeCheckoutSession } from './checkoutUtils';
import { requireNodeEnvVar } from '../../server/utils';
import { requireNodeEnvVar } from '../../server/envUtils';
import { stripeWebhook, stripeMiddlewareConfigFn } from './webhook';

export type StripeMode = 'subscription' | 'payment';
Expand Down
2 changes: 1 addition & 1 deletion template/app/src/payment/stripe/stripeClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Stripe from 'stripe';
import { requireNodeEnvVar } from '../../server/utils';
import { requireNodeEnvVar } from '../../server/envUtils';

export const stripe = new Stripe(requireNodeEnvVar('STRIPE_API_KEY'), {
// NOTE:
Expand Down
4 changes: 2 additions & 2 deletions template/app/src/payment/stripe/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { paymentPlans, PaymentPlanId, SubscriptionStatus } from '../plans';
import { updateUserStripePaymentDetails } from './paymentDetails';
import { emailSender } from 'wasp/server/email';
import { assertUnreachable } from '../../shared/utils';
import { requireNodeEnvVar } from '../../server/utils';
import { requireNodeEnvVar } from '../../server/envUtils';
import { z } from 'zod';

export const stripeWebhook: PaymentsWebhook = async (request, response, context) => {
Expand Down Expand Up @@ -174,4 +174,4 @@ function getPlanIdByPriceId(priceId: string): PaymentPlanId {
throw new Error(`No plan with Stripe price id ${priceId}`);
}
return planId;
}
}
8 changes: 8 additions & 0 deletions template/app/src/server/envUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function requireNodeEnvVar(name: string): string {
const value = process.env[name];
if (value === undefined) {
throw new Error(`Env var ${name} is undefined`);
} else {
return value;
}
}
8 changes: 0 additions & 8 deletions template/app/src/server/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
export function requireNodeEnvVar(name: string): string {
const value = process.env[name];
if (value === undefined) {
throw new Error(`Env var ${name} is undefined`);
} else {
return value;
}
}