Added shared mailer package to remove circular dependencies between packages. (#63)

This commit is contained in:
Giancarlo Buomprisco
2024-09-04 03:34:48 +08:00
committed by GitHub
parent d18f810c6e
commit 4c7a3354b9
21 changed files with 256 additions and 38 deletions

View File

@@ -0,0 +1,20 @@
import { z } from 'zod';
export const MailerSchema = z
.object({
to: z.string().email(),
// this is not necessarily formatted
// as an email so we type it loosely
from: z.string().min(1),
subject: z.string(),
})
.and(
z.union([
z.object({
text: z.string(),
}),
z.object({
html: z.string(),
}),
]),
);

View File

@@ -0,0 +1,28 @@
import 'server-only';
import { z } from 'zod';
export const SmtpConfigSchema = z.object({
user: z.string({
description:
'This is the email account to send emails from. This is specific to the email provider.',
required_error: `Please provide the variable EMAIL_USER`,
}),
pass: z.string({
description: 'This is the password for the email account',
required_error: `Please provide the variable EMAIL_PASSWORD`,
}),
host: z.string({
description: 'This is the SMTP host for the email provider',
required_error: `Please provide the variable EMAIL_HOST`,
}),
port: z.number({
description:
'This is the port for the email provider. Normally 587 or 465.',
required_error: `Please provide the variable EMAIL_PORT`,
}),
secure: z.boolean({
description: 'This is whether the connection is secure or not',
required_error: `Please provide the variable EMAIL_TLS`,
}),
});