From 531da98c24c41458e7d8f6cc8c60053e1876dcd4 Mon Sep 17 00:00:00 2001 From: lila Date: Sat, 2 May 2026 13:18:00 +0200 Subject: [PATCH] fix: initialize Resend lazily to prevent test failures when API key is absent --- apps/api/src/lib/auth.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/api/src/lib/auth.ts b/apps/api/src/lib/auth.ts index 601708e..fe41e35 100644 --- a/apps/api/src/lib/auth.ts +++ b/apps/api/src/lib/auth.ts @@ -4,7 +4,6 @@ import { Resend } from "resend"; import { db } from "@lila/db"; import * as schema from "@lila/db/schema"; -const resend = new Resend(process.env["RESEND_API_KEY"]); const emailFrom = process.env["EMAIL_FROM"] ?? "noreply@lilastudy.com"; export const auth = betterAuth({ @@ -30,6 +29,7 @@ export const auth = betterAuth({ user: { email: string }; url: string; }) => { + const resend = new Resend(process.env["RESEND_API_KEY"]); await resend.emails.send({ from: emailFrom, to: user.email, @@ -48,6 +48,7 @@ export const auth = betterAuth({ user: { email: string }; url: string; }) => { + const resend = new Resend(process.env["RESEND_API_KEY"]); await resend.emails.send({ from: emailFrom, to: user.email,