Update environment variables in resend module
This commit is contained in:
@@ -11,7 +11,14 @@
|
|||||||
import { Resend } from 'resend';
|
import { Resend } from 'resend';
|
||||||
import { env } from '$env/dynamic/private';
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
export const resend = new Resend(env.RESEND_API_KEY);
|
let _resend: Resend;
|
||||||
|
|
||||||
|
function getResend(): Resend {
|
||||||
|
if (!_resend) {
|
||||||
|
_resend = new Resend(env.RESEND_API_KEY);
|
||||||
|
}
|
||||||
|
return _resend;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a transactional email using a Resend-hosted template.
|
* Send a transactional email using a Resend-hosted template.
|
||||||
@@ -38,7 +45,7 @@ export async function sendMail(options: {
|
|||||||
}) {
|
}) {
|
||||||
const { to, subject, templateId, data } = options;
|
const { to, subject, templateId, data } = options;
|
||||||
|
|
||||||
const result = await resend.emails.send({
|
const result = await getResend().emails.send({
|
||||||
from: env.EMAIL_FROM,
|
from: env.EMAIL_FROM,
|
||||||
to: [to],
|
to: [to],
|
||||||
subject: subject ?? 'Template Email',
|
subject: subject ?? 'Template Email',
|
||||||
|
|||||||
Reference in New Issue
Block a user