B2B-88: add starter kit structure and elements

This commit is contained in:
devmc-ee
2025-06-08 16:18:30 +03:00
parent 657a36a298
commit e7b25600cb
1280 changed files with 77893 additions and 5688 deletions

View File

@@ -0,0 +1,15 @@
import { z } from 'zod';
export const StripeClientEnvSchema = z
.object({
publishableKey: z.string().min(1),
})
.refine(
(schema) => {
return schema.publishableKey.startsWith('pk_');
},
{
path: ['publishableKey'],
message: `Stripe publishable key must start with 'pk_'`,
},
);

View File

@@ -0,0 +1,39 @@
import { z } from 'zod';
export const StripeServerEnvSchema = z
.object({
secretKey: z
.string({
required_error: `Please provide the variable STRIPE_SECRET_KEY`,
})
.min(1),
webhooksSecret: z
.string({
required_error: `Please provide the variable STRIPE_WEBHOOK_SECRET`,
})
.min(1),
})
.refine(
(schema) => {
const key = schema.secretKey;
const secretKeyPrefix = 'sk_';
const restrictKeyPrefix = 'rk_';
return (
key.startsWith(secretKeyPrefix) || key.startsWith(restrictKeyPrefix)
);
},
{
path: ['STRIPE_SECRET_KEY'],
message: `Stripe secret key must start with 'sk_' or 'rk_'`,
},
)
.refine(
(schema) => {
return schema.webhooksSecret.startsWith('whsec_');
},
{
path: ['STRIPE_WEBHOOK_SECRET'],
message: `Stripe webhook secret must start with 'whsec_'`,
},
);