Skip to content

Commit

Permalink
Fix build issue with missing SMTP password
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Feb 18, 2025
1 parent 1fc4345 commit caa1731
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/ResendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import { User } from "./Types";
import CollectionId from "./client/CollectionId";
import { ObjectId } from "bson";

const resend = new Resend(process.env.SMTP_PASSWORD);

export interface ResendInterface {
createContact: (rawUser: NextAuthUser) => Promise<void>;
emailDevelopers: (subject: string, message: string) => void;
}

export class ResendUtils implements ResendInterface {
private static resend: Resend;

constructor() {
ResendUtils.resend ??= new Resend(process.env.SMTP_PASSWORD);
}

async createContact(rawUser: NextAuthUser) {
const user = rawUser as User;

Expand All @@ -27,7 +31,7 @@ export class ResendUtils implements ResendInterface {

const nameParts = user.name?.split(" ");

const res = await resend.contacts.create({
const res = await ResendUtils.resend.contacts.create({
email: user.email,
firstName: nameParts[0],
lastName: nameParts.length > 1 ? nameParts[1] : "",
Expand Down Expand Up @@ -60,7 +64,7 @@ export class ResendUtils implements ResendInterface {
return;
}

resend.emails.send({
ResendUtils.resend.emails.send({
from: "Gearbox Server <[email protected]>",
to: JSON.parse(process.env.DEVELOPER_EMAILS), // Environment variables are always strings, so we need to parse it
subject,
Expand Down

0 comments on commit caa1731

Please sign in to comment.