Skip to content

Commit

Permalink
Added subscribe endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
13XAVI committed Jun 25, 2024
2 parents 5adeb58 + 52a7f9e commit b9a087c
Show file tree
Hide file tree
Showing 22 changed files with 1,444 additions and 539 deletions.
636 changes: 115 additions & 521 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"jest": "^29.7.0",
"joi": "^17.13.1",
"jsonwebtoken": "^9.0.2",
"mailgun-js": "^0.22.0",
"mailgun-js": "^0.6.7",
"morgan": "^1.10.0",
"node-fetch": "^2.6.7",
"nodemailer": "^6.9.13",
Expand Down Expand Up @@ -69,13 +69,15 @@
"coveragePathIgnorePatterns": [
"/node_modules/",
"/src/emails/",
"/src/utilis/"
"/src/utilis/",
"/src/Notification.vendor/"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/src/emails/",
"/src/middlewares/",
"/src/utilis/"
"/src/utilis/",
"/src/Notification.vendor/"
]
},
"devDependencies": {
Expand All @@ -88,6 +90,7 @@
"@types/jsonwebtoken": "^9.0.6",
"@types/mailgun-js": "^0.22.18",
"@types/morgan": "^1.9.9",
"@types/node-cron": "^3.0.11",
"@types/node-fetch": "^2.6.11",
"@types/nodemailer": "^6.4.15",
"@types/passport": "^1.0.16",
Expand All @@ -103,6 +106,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"node-cron": "^3.0.3",
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"ts-node-dev": "^2.0.0",
Expand Down
35 changes: 35 additions & 0 deletions src/Notification.vendor/EmailSendor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import nodemailer from 'nodemailer';
import dotenv from 'dotenv';

dotenv.config();

async function sendEmail(vendorEmail: string, message_title: string, messageContent: string) {
try {
const transporter = nodemailer.createTransport({
service: 'gmail',
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
},
});

const mailOptions = {
from: `"The E-commerce Team" <${process.env.EMAIL_USER}>`,
to: vendorEmail,
subject: 'Notification from Your Company',
text: messageContent,
html: `<p>${messageContent.replace(/\n/g, '<br>')}</p>`,
};

await transporter.sendMail(mailOptions);

} catch (error) {
throw error
}
}

export default sendEmail;

Loading

0 comments on commit b9a087c

Please sign in to comment.