Add Lemon Squeezy environment variable schema validation and removed NODE_ENV from production variables, as it causes issues in Vercel
- Implement `getLemonSqueezyEnv` function to validate required environment variables for Lemon Squeezy integration using `zod`. - Ensure `LEMON_SQUEEZY_SECRET_KEY`, `LEMON_SQUEEZY_SIGNING_SECRET`, and `LEMON_SQUEEZY_STORE_ID` are present and valid.
This commit is contained in:
@@ -5,9 +5,6 @@
|
||||
## AVOID PLACING SENSITIVE DATA IN THIS FILE.
|
||||
## PUBLIC KEYS OR CONFIGURATION ARE OKAY TO BE PLACED HERE.
|
||||
|
||||
# NODE ENV
|
||||
NODE_ENV=production
|
||||
|
||||
# SUPABASE
|
||||
NEXT_PUBLIC_SUPABASE_URL=
|
||||
|
||||
|
||||
@@ -1,11 +1,29 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* @name getLemonSqueezyEnv
|
||||
* @description Get the Lemon Squeezy environment variables.
|
||||
* It will throw an error if any of the required variables are missing.
|
||||
*/
|
||||
export const getLemonSqueezyEnv = () =>
|
||||
z
|
||||
.object({
|
||||
secretKey: z.string().min(1),
|
||||
webhooksSecret: z.string().min(1),
|
||||
storeId: z.string(),
|
||||
secretKey: z
|
||||
.string({
|
||||
description: `The secret key you created for your store. Please use the variable LEMON_SQUEEZY_SECRET_KEY to set it.`,
|
||||
})
|
||||
.min(1),
|
||||
webhooksSecret: z
|
||||
.string({
|
||||
description: `The shared secret you created for your webhook. Please use the variable LEMON_SQUEEZY_SIGNING_SECRET to set it.`,
|
||||
})
|
||||
.min(1)
|
||||
.max(40),
|
||||
storeId: z
|
||||
.string({
|
||||
description: `The ID of your store. Please use the variable LEMON_SQUEEZY_STORE_ID to set it.`,
|
||||
})
|
||||
.min(1),
|
||||
})
|
||||
.parse({
|
||||
secretKey: process.env.LEMON_SQUEEZY_SECRET_KEY,
|
||||
|
||||
Reference in New Issue
Block a user