Fix docker-compose: lockfile name, lazy Resend init

This commit is contained in:
2026-01-27 17:20:28 +00:00
parent 54d1bb7240
commit 6620333def
2 changed files with 15 additions and 3 deletions

View File

@@ -1,6 +1,17 @@
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
let resend: Resend | null = null;
function getResendClient(): Resend {
if (!resend) {
const apiKey = process.env.RESEND_API_KEY;
if (!apiKey) {
throw new Error('RESEND_API_KEY is not configured');
}
resend = new Resend(apiKey);
}
return resend;
}
export interface SendEmailParams {
to: string;
@@ -11,7 +22,8 @@ export interface SendEmailParams {
}
export async function sendEmail(params: SendEmailParams) {
const { data, error } = await resend.emails.send({
const client = getResendClient();
const { data, error } = await client.emails.send({
from: params.from || process.env.DEFAULT_FROM_EMAIL || 'onboarding@resend.dev',
to: params.to,
subject: params.subject,