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

@@ -3,7 +3,7 @@ WORKDIR /app
# Install dependencies # Install dependencies
FROM base AS install FROM base AS install
COPY package.json bun.lockb ./ COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production RUN bun install --frozen-lockfile --production
# Production image # Production image

View File

@@ -1,6 +1,17 @@
import { Resend } from 'resend'; 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 { export interface SendEmailParams {
to: string; to: string;
@@ -11,7 +22,8 @@ export interface SendEmailParams {
} }
export async function sendEmail(params: 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', from: params.from || process.env.DEFAULT_FROM_EMAIL || 'onboarding@resend.dev',
to: params.to, to: params.to,
subject: params.subject, subject: params.subject,