-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement gift-exchange emails
Merge PR #16
Showing
12 changed files
with
522 additions
and
121 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Global, Module } from '@nestjs/common'; | ||
import { EmailsService } from './services'; | ||
|
||
@Global() | ||
@Module({ | ||
imports: [], | ||
providers: [EmailsService], | ||
controllers: [], | ||
exports: [EmailsService], | ||
}) | ||
export class EmailsModule {} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './emails.module'; |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { | ||
TransactionalEmailsApi, | ||
TransactionalEmailsApiApiKeys, | ||
} from '@getbrevo/brevo'; | ||
import { EnvironmentConfig } from '@config/environment'; | ||
|
||
@Injectable() | ||
export class EmailsService { | ||
private client: TransactionalEmailsApi; | ||
|
||
constructor(private readonly config: ConfigService<EnvironmentConfig>) { | ||
this.client = new TransactionalEmailsApi(); | ||
this.client.setApiKey( | ||
TransactionalEmailsApiApiKeys.apiKey, | ||
this.config.get('brevo.apiKey', { infer: true }), | ||
); | ||
} | ||
|
||
async sendEmail(email: { | ||
subject?: string; | ||
htmlContent?: string; | ||
sender?: { name: string; email: string }; | ||
to: { email: string; name: string }[]; | ||
replyTo?: { email: string; name: string }; | ||
params?: object; | ||
templateId?: number; | ||
}) { | ||
return this.client.sendTransacEmail({ ...email }); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './emails.service'; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const EMAIL_TEMPLATES = { | ||
WELCOME_EMAIL: 1, | ||
DRAW_EMAIL: 3, | ||
}; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './collections.constant'; | ||
export * from './email-templates.constant'; |
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
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
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 |
---|---|---|
|
@@ -9,4 +9,7 @@ export interface EnvironmentConfig { | |
user: string; | ||
dbName: string; | ||
}; | ||
brevo: { | ||
apiKey: string; | ||
}; | ||
} |