Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
feat: connect gmail limals
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicGendre committed Jan 21, 2022
1 parent 64286e6 commit ce3dcc0
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
DATABASE_URL="postgresql://postgres:9fgJYRt11rz8OfL6ftw3cnTU9Ccyb98CGuSWYaTfShwCUIUn0E0EUQHgfqyQSMEw@localhost:5432/limals"
JWT_SECRET="Y89kGTFgNXPvkzapJyV3spBZbFtgddN4"
SALT="EAsCKIFVCV5CcfJc7M24Zgegy0j9zEuu"
EMAIL_SERVICE="gmail"
EMAIL_USER="[email protected]"
EMAIL_PASSWORD="Secret00"
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@nestjs/swagger": "^5.1.5",
"@prisma/client": "^3.8.1",
"@types/faker": "^5.5.9",
"@types/nodemailer": "^6.4.4",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"concurrently": "^6.4.0",
Expand All @@ -51,6 +52,7 @@
"image-to-base64": "^2.2.0",
"image-uploader": "^2.0.2",
"multer": "^1.4.4",
"nodemailer": "^6.7.2",
"passport-jwt": "^4.0.0",
"pg": "^8.7.1",
"reflect-metadata": "^0.1.13",
Expand Down
9 changes: 9 additions & 0 deletions src/email/email.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import EmailService from './email.service';

@Module({
controllers: [],
providers: [EmailService],
exports: [EmailService],
})
export class EmailModule {}
22 changes: 22 additions & 0 deletions src/email/email.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Injectable } from '@nestjs/common';
import { createTransport } from 'nodemailer';
import * as Mail from 'nodemailer/lib/mailer';

@Injectable()
export default class EmailService {
private nodemailerTransport: Mail;

constructor() {
this.nodemailerTransport = createTransport({
service: process.env.EMAIL_SERVICE,
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASSWORD,
},
});
}

sendMail(options: Mail.Options) {
return this.nodemailerTransport.sendMail(options);
}
}

0 comments on commit ce3dcc0

Please sign in to comment.