Files
myeasycms-v2/apps/web/config/app.config.ts
giancarlo 2acd9c7d10 Refactor mailer setup and validate web configuration in app
This commit refactors how SMTP configuration for mailers is set up and introduces schema validation for incoming configurations. The mailer modules have been restructured, with schema definition files added, and redundant codes removed. Moreover, web application configuration now has minimum validation on name and title, and URL validation has been added.
2024-03-27 14:10:53 +08:00

51 lines
1.2 KiB
TypeScript

import { z } from 'zod';
const production = process.env.NODE_ENV === 'production';
enum Themes {
Light = 'light',
Dark = 'dark',
}
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.nativeEnum(Themes),
production: z.boolean(),
themeColor: z.string(),
themeColorDark: z.string(),
});
const appConfig = AppConfigSchema.parse({
name: 'Awesomely',
title: 'Awesomely - Your SaaS Title',
description: 'Your SaaS Description',
url: process.env.NEXT_PUBLIC_SITE_URL,
locale: process.env.NEXT_PUBLIC_DEFAULT_LOCALE,
theme: Themes.Light,
production,
themeColor: '#ffffff',
themeColorDark: '#0a0a0a',
});
export default appConfig;