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.
This commit is contained in:
giancarlo
2024-03-27 14:10:53 +08:00
parent ff19e0c204
commit 2acd9c7d10
12 changed files with 146 additions and 70 deletions

View File

@@ -8,11 +8,27 @@ enum Themes {
}
const AppConfigSchema = z.object({
name: z.string(),
title: z.string(),
description: z.string(),
url: z.string(),
locale: z.string().default('en'),
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(),

View File

@@ -6,8 +6,12 @@ const providers: z.ZodType<Provider> = getProviders();
const AuthConfigSchema = z.object({
providers: z.object({
password: z.boolean(),
magicLink: z.boolean(),
password: z.boolean({
description: 'Enable password authentication.',
}),
magicLink: z.boolean({
description: 'Enable magic link authentication.',
}),
oAuth: providers.array(),
}),
});