-
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.
- Loading branch information
Showing
12 changed files
with
109 additions
and
67 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
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,7 +1,14 @@ | ||
FROM node:16.6.2 | ||
FROM node:20-alpine | ||
|
||
WORKDIR /app | ||
COPY package.json /app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
COPY . /app | ||
|
||
COPY . . | ||
|
||
RUN npm run build | ||
CMD ["npm", "start"] | ||
EXPOSE 3001 | ||
CMD ["node", "dist/src/app.js"] | ||
|
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
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 |
---|---|---|
|
@@ -4,10 +4,19 @@ import config from "config"; | |
import url from "url"; | ||
import { create } from "express-handlebars"; | ||
import https from "https"; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import AWS from "aws-sdk"; | ||
import { constants } from "./constants"; | ||
import { UserDocument } from "../models/user.model"; | ||
import logger from "../utils/logger"; | ||
|
||
const SES_CONFIG = { | ||
accessKeyId: config.get<string>("access_key"), | ||
secretAccessKey: config.get<string>("secret_key"), | ||
region: "ap-south-1", | ||
}; | ||
|
||
const ses = new AWS.SES(SES_CONFIG); | ||
const mailgun = new Mailgun(formData); | ||
const mg = mailgun.client({ | ||
username: "api", | ||
|
@@ -24,36 +33,56 @@ export const sendMail = async ( | |
link: string | ||
) => { | ||
try { | ||
const data = { | ||
to: email, | ||
text: link, | ||
subject, | ||
html: content, | ||
auth: config.get<string>("emailer_auth"), | ||
}; | ||
// const data = { | ||
// from: senderEmail, | ||
// to: email, | ||
// text: link, | ||
// subject, | ||
// html: content, | ||
// }; | ||
|
||
const postOptions = { | ||
host: config.get<string>("emailer_host"), | ||
port: "443", | ||
path: config.get<string>("emailer_path"), | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": Buffer.byteLength(JSON.stringify(data)), | ||
const params = { | ||
Source: "Team CSI <[email protected]>", | ||
Destination: { | ||
ToAddresses: [email], | ||
}, | ||
Message: { | ||
Subject: { | ||
Data: subject, | ||
}, | ||
Body: { | ||
Html: { | ||
Data: content, | ||
}, | ||
}, | ||
}, | ||
}; | ||
await ses.sendEmail(params).promise(); | ||
|
||
// const postOptions = { | ||
// host: config.get<string>("emailer_host"), | ||
// port: "443", | ||
// path: config.get<string>("emailer_path"), | ||
// method: "POST", | ||
// headers: { | ||
// "Content-Type": "application/json", | ||
// "Content-Length": Buffer.byteLength(JSON.stringify(data)), | ||
// }, | ||
// }; | ||
|
||
// Set up the request | ||
const postReq = https.request(postOptions, (res) => { | ||
res.setEncoding("utf8"); | ||
res.on("data", (chunk) => { | ||
logger.info(`mail sent to ${email} Response: `, chunk); | ||
}); | ||
}); | ||
// const postReq = https.request(postOptions, (res) => { | ||
// res.setEncoding("utf8"); | ||
// res.on("data", (chunk) => { | ||
// logger.info(`mail sent to ${email} Response: `, chunk); | ||
// }); | ||
// }); | ||
|
||
// post the data | ||
postReq.write(JSON.stringify(data)); | ||
postReq.end(); | ||
// postReq.write(JSON.stringify(data)); | ||
// postReq.end(); | ||
// await mg.messages.create(domain, data); | ||
// console.log(data); | ||
// await mg.messages.create(domain, data); | ||
logger.info(`Mail sent to ${email} successfully`); | ||
} catch (e) { | ||
|