Skip to content

Commit

Permalink
setup email_service
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen-Duc-Khai committed Dec 8, 2023
1 parent 9fbb661 commit 23c29a0
Show file tree
Hide file tree
Showing 11 changed files with 1,613 additions and 0 deletions.
187 changes: 187 additions & 0 deletions backend/package-lock.json

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

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@hokify/agenda": "^6.3.0",
"agendash": "^4.0.0",
"amqplib": "^0.10.3",
"axios": "^1.6.2",
"celebrate": "^15.0.3",
"cors": "^2.8.5",
Expand Down
2 changes: 2 additions & 0 deletions email-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
README.md
1 change: 1 addition & 0 deletions email-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 2 additions & 0 deletions email-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Email service using Nodemailer AMQP
### References: https://github.com/nodemailer/nodemailer-amqp-example
Empty file added email-service/app.js
Empty file.
9 changes: 9 additions & 0 deletions email-service/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"amqp": "amqp://localhost",
"queue": "nodemailer-amqp",

"server": {
"port": 12345,
"host": "localhost"
}
}
29 changes: 29 additions & 0 deletions email-service/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const winston = require("winston");
const config = require("./config");

const enumerateErrorFormat = winston.format((info) => {
if (info instanceof Error) {
Object.assign(info, { message: info.stack });
}
return info;
});

const logger = winston.createLogger({
level: "info",
format: winston.format.combine(
enumerateErrorFormat(),
config.env === "development"
? winston.format.colorize()
: winston.format.uncolorize(),
winston.format.errors({ stack: true }),
winston.format.json()
),
defaultMeta: { application: "mail_service" },
transports: [
new winston.transports.Console({
format: winston.format.simple(),
}),
],
});

module.exports = logger;
Loading

0 comments on commit 23c29a0

Please sign in to comment.