-
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.
- Loading branch information
1 parent
ee03f16
commit bdda1d8
Showing
9 changed files
with
287 additions
and
53 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
API_URI=http://localhost:4000 | ||
APP_URI=http://localhost:4200 | ||
APP_VERSION= | ||
|
||
AWS_ACCESS_KEY_ID= | ||
AWS_BUCKET= | ||
AWS_ENDPOINT= | ||
AWS_REGION= | ||
AWS_SECRET_ACCESS_KEY= | ||
|
||
DATABASE_MASTER_HOST= | ||
DATABASE_SLAVE_HOST= | ||
DATABASE_PORT= | ||
DATABASE_TYPE= | ||
DATABASE_NAME= | ||
DATABASE_USER= | ||
DATABASE_PASSWORD= | ||
|
||
DEBUG=false | ||
|
||
ENCRYPT_KEY= | ||
JWT_SECRET= | ||
JWT_TTL= | ||
|
||
MODE=production | ||
ORIGIN=http://localhost:4200,https://ordero.vercel.app | ||
PORT=4000 | ||
|
||
REDIS_DATABASE=0 | ||
REDIS_ENABLED=false | ||
REDIS_HOST= | ||
REDIS_PASSWORD= | ||
REDIS_PORT= | ||
REDIS_QUEUE=0 | ||
|
||
MAIL_FROM='Ordero <[email protected]>' | ||
MAIL_PASSWORD= | ||
MAIL_USERNAME= | ||
SMTP_HOST= | ||
SMTP_PORT= | ||
|
||
MAILERSEND_API_KEY= | ||
MAILERSEND_DOMAIN= | ||
|
||
SENTRY_DSN= | ||
SOCKET_TYPE=socketio | ||
|
||
TWILLIO_SERVICE= | ||
TWILLIO_SID= | ||
TWILLIO_TOKEN= | ||
|
||
TZ=UTC |
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
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
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,95 @@ | ||
import { config } from '@lib/helpers/config.helper'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { EmailParams, MailerSend, Recipient, Sender } from 'mailersend'; | ||
|
||
interface MailersendPayload { | ||
receipient: string; | ||
subject: string; | ||
data: { | ||
name: string; | ||
team_name: string; | ||
verification_code?: string; | ||
reset_link?: string; | ||
password?: string; | ||
}; | ||
template_id?: string; | ||
} | ||
|
||
@Injectable() | ||
export class MailService { | ||
protected mailerSend: MailerSend; | ||
protected sentFrom: Sender; | ||
protected mailDomain: string; | ||
|
||
constructor() { | ||
this.mailerSend = new MailerSend({ | ||
apiKey: config.get('MAILERSEND_API_KEY'), | ||
}); | ||
this.sentFrom = new Sender('[email protected]', 'Order Team'); | ||
} | ||
|
||
async sendVerificationCode(payload: MailersendPayload) { | ||
const recipients = [new Recipient(payload.receipient, payload.data.name)]; | ||
const personalization = [ | ||
{ | ||
email: payload.receipient, | ||
data: payload.data, | ||
}, | ||
]; | ||
|
||
const emailParams = new EmailParams() | ||
.setFrom(this.sentFrom) | ||
.setTo(recipients) | ||
.setSubject(payload.subject) | ||
.setPersonalization(personalization) | ||
.setTemplateId('z3m5jgrkqkdldpyo'); | ||
|
||
await this.mailerSend.email.send(emailParams); | ||
} | ||
|
||
async sendResetPassword(payload: MailersendPayload) { | ||
const recipients = [new Recipient(payload.receipient, payload.data.name)]; | ||
const personalization = [ | ||
{ | ||
email: payload.receipient, | ||
data: { | ||
name: payload.data.name, | ||
reset_link: payload.data.reset_link, | ||
team_name: payload.data.team_name, | ||
}, | ||
}, | ||
]; | ||
|
||
const emailParams = new EmailParams() | ||
.setFrom(this.sentFrom) | ||
.setTo(recipients) | ||
.setSubject(payload.subject) | ||
.setPersonalization(personalization) | ||
.setTemplateId('pq3enl67y78g2vwr'); | ||
|
||
await this.mailerSend.email.send(emailParams); | ||
} | ||
|
||
async sendStaffRegister(payload: MailersendPayload) { | ||
const recipients = [new Recipient(payload.receipient, payload.data.name)]; | ||
const personalization = [ | ||
{ | ||
email: payload.receipient, | ||
data: { | ||
name: payload.data.name, | ||
team_name: payload.data.team_name, | ||
password: payload.data.password, | ||
}, | ||
}, | ||
]; | ||
|
||
const emailParams = new EmailParams() | ||
.setFrom(this.sentFrom) | ||
.setTo(recipients) | ||
.setSubject(payload.subject) | ||
.setPersonalization(personalization) | ||
.setTemplateId('351ndgw6q6n4zqx8'); | ||
|
||
await this.mailerSend.email.send(emailParams); | ||
} | ||
} |
Oops, something went wrong.