Add support for Resend mailer

This update expands the mailer support by adding the Resend mailer as an alternative to NodeMailer and Cloudflare Mailer. After setting the environment variable 'MAILER_PROVIDER' to 'resend', users can utilize the Resend HTTP API for mailing. Necessary instructions and variable settings regarding the usage of Resend mailer have also been added to README.md and related modules.
This commit is contained in:
giancarlo
2024-04-17 18:42:00 +08:00
parent d60609d279
commit f7ded6f789
4 changed files with 91 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import { z } from 'zod';
const MAILER_PROVIDER = z
.enum(['nodemailer', 'cloudflare'])
.enum(['nodemailer', 'cloudflare', 'resend'])
.default('nodemailer')
.parse(process.env.MAILER_PROVIDER);
@@ -26,6 +26,12 @@ export async function getMailer() {
return new CloudflareMailer();
}
case 'resend': {
const { ResendMailer } = await import('./impl/resend');
return new ResendMailer();
}
default:
throw new Error(`Invalid mailer: ${MAILER_PROVIDER as string}`);
}