Updated the billing system's schema to change 'storeId' to a string type, and improved the cleanliness and readability of the code. Enhanced the logging system within the billing service for better tracking and debugging. In line with these changes, added corresponding error pages in the client side to handle any errors.
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
const production = process.env.NODE_ENV === 'production';
|
|
|
|
const AppConfigSchema = z
|
|
.object({
|
|
name: z
|
|
.string({
|
|
description: `This is the name of your SaaS. Ex. "Makerkit"`,
|
|
})
|
|
.min(1),
|
|
title: z
|
|
.string({
|
|
description: `This is the default title tag of your SaaS.`,
|
|
})
|
|
.min(1),
|
|
description: z.string({
|
|
description: `This is the default description of your SaaS.`,
|
|
}),
|
|
url: z.string().url({
|
|
message: `Please provide a valid URL. Example: 'https://example.com'`,
|
|
}),
|
|
locale: z
|
|
.string({
|
|
description: `This is the default locale of your SaaS.`,
|
|
})
|
|
.default('en'),
|
|
theme: z.enum(['light', 'dark', 'system']),
|
|
production: z.boolean(),
|
|
themeColor: z.string(),
|
|
themeColorDark: z.string(),
|
|
})
|
|
.refine(
|
|
(schema) => {
|
|
return !(schema.production && schema.url.startsWith('http:'));
|
|
},
|
|
{
|
|
message: `Please use a valid HTTPS URL in production.`,
|
|
path: ['url'],
|
|
},
|
|
)
|
|
.refine(
|
|
(schema) => {
|
|
return schema.themeColor !== schema.themeColorDark;
|
|
},
|
|
{
|
|
message: `Please provide different theme colors for light and dark themes.`,
|
|
path: ['themeColor'],
|
|
},
|
|
);
|
|
|
|
const appConfig = AppConfigSchema.parse({
|
|
name: process.env.NEXT_PUBLIC_PRODUCT_NAME,
|
|
title: process.env.NEXT_PUBLIC_SITE_TITLE,
|
|
description: process.env.NEXT_PUBLIC_SITE_DESCRIPTION,
|
|
url: process.env.NEXT_PUBLIC_SITE_URL,
|
|
locale: process.env.NEXT_PUBLIC_DEFAULT_LOCALE,
|
|
theme: process.env.NEXT_PUBLIC_DEFAULT_THEME_MODE,
|
|
themeColor: process.env.NEXT_PUBLIC_THEME_COLOR,
|
|
themeColorDark: process.env.NEXT_PUBLIC_THEME_COLOR_DARK,
|
|
production,
|
|
});
|
|
|
|
export default appConfig;
|