-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix build issue with missing SMTP password
- Loading branch information
1 parent
1fc4345
commit caa1731
Showing
1 changed file
with
8 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -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] : "", | ||
|
@@ -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, | ||
|