fix: initialize Resend lazily to prevent test failures when API key is absent
All checks were successful
Build and Deploy / quality (push) Successful in 1m46s
Build and Deploy / build-and-deploy (push) Successful in 1m37s

This commit is contained in:
lila 2026-05-02 13:18:00 +02:00
parent 90b0890263
commit 531da98c24

View file

@ -4,7 +4,6 @@ import { Resend } from "resend";
import { db } from "@lila/db"; import { db } from "@lila/db";
import * as schema from "@lila/db/schema"; 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"; const emailFrom = process.env["EMAIL_FROM"] ?? "noreply@lilastudy.com";
export const auth = betterAuth({ export const auth = betterAuth({
@ -30,6 +29,7 @@ export const auth = betterAuth({
user: { email: string }; user: { email: string };
url: string; url: string;
}) => { }) => {
const resend = new Resend(process.env["RESEND_API_KEY"]);
await resend.emails.send({ await resend.emails.send({
from: emailFrom, from: emailFrom,
to: user.email, to: user.email,
@ -48,6 +48,7 @@ export const auth = betterAuth({
user: { email: string }; user: { email: string };
url: string; url: string;
}) => { }) => {
const resend = new Resend(process.env["RESEND_API_KEY"]);
await resend.emails.send({ await resend.emails.send({
from: emailFrom, from: emailFrom,
to: user.email, to: user.email,