Add SMTP status check
This commit is contained in:
parent
a197ae9cc6
commit
5413c7dddf
@ -4,6 +4,8 @@ const bodyParser = require('body-parser');
|
||||
const cors = require('cors');
|
||||
const helmet = require('helmet');
|
||||
|
||||
const smtpStatus = require('../helpers/smtpStatus');
|
||||
|
||||
const accountsRoute = require('./routes/accountRoute');
|
||||
const meetingsRoute = require('./routes/meetingRoute');
|
||||
const participantsRoute = require('./routes/participantRoute');
|
||||
@ -34,10 +36,13 @@ server.use('/api/possible-dates', possibleDatesRoute);
|
||||
server.use('/api/availability', availabilityRoute);
|
||||
server.use('/api/auth', authRoute);
|
||||
|
||||
server.get("/", (req, res) => {
|
||||
const smtpMessage = smtpStatus();
|
||||
|
||||
server.get('/', (req, res) => {
|
||||
res.json({
|
||||
message: `Meeting Planner Backend API :)`,
|
||||
documentation: `Check out: https://git.armada.digital/meeting-planner/backend`
|
||||
documentation: `Check out: https://git.armada.digital/meeting-planner/backend`,
|
||||
SMTP: `${smtpMessage}`,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -7,12 +7,13 @@ module.exports = {
|
||||
dbURL: process.env.DATABASE_URL,
|
||||
// JWT
|
||||
jwtSecret: process.env.JWT_SECRET,
|
||||
saltingRounds: process.env.SALTING_ROUNDS || 10,
|
||||
saltingRounds: 10,
|
||||
// NODEMAILER
|
||||
smtpHost: process.env.SMTP_HOST,
|
||||
smtpPort: process.env.SMTP_PORT,
|
||||
smtpUsername: process.env.SMTP_USERNAME,
|
||||
smtpPassword: process.env.SMTP_PASSWORD,
|
||||
smtpSecure: process.env.SMTP_SECURE || true, // use TLS
|
||||
smtpPool: process.env.SMTP_POOL|| true, // Pool connections to server
|
||||
smtpRequireTLS: true, // True to force use of StartTLS
|
||||
smtpSecure: false, // False to force use of StartTLS
|
||||
smtpPool: true, // Pool connections to server
|
||||
};
|
||||
|
15
helpers/smtpStatus.js
Normal file
15
helpers/smtpStatus.js
Normal file
@ -0,0 +1,15 @@
|
||||
const smtpTransporter = require('./smtpTransporter');
|
||||
|
||||
function smtpStatus() {
|
||||
smtpTransporter.verify(function (error, success) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
return `SMTP is not working, check your configuration.`
|
||||
} else {
|
||||
console.log('Server is ready to take our messages');
|
||||
return `SMTP is correctly configured.`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = smtpStatus;
|
@ -6,15 +6,20 @@ const {
|
||||
smtpPort,
|
||||
smtpUsername,
|
||||
smtpPassword,
|
||||
smtpSecure,
|
||||
smtpRequireTLS,
|
||||
} = require('../config/config');
|
||||
|
||||
nodemailer.createTransport({
|
||||
const smtpTransporter = nodemailer.createTransport({
|
||||
pool: smtpPool,
|
||||
host: smtpHost,
|
||||
port: smtpPort,
|
||||
requireTLS: smtpRequireTLS,
|
||||
secure: smtpSecure,
|
||||
auth: {
|
||||
user: smtpUsername,
|
||||
pass: smtpPassword,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = smtpTransporter;
|
||||
|
Loading…
Reference in New Issue
Block a user