Add SMTP transporter in helpers

This commit is contained in:
rui hildt 2020-08-29 11:01:57 +02:00
parent 2b4832a4f7
commit a197ae9cc6
2 changed files with 28 additions and 3 deletions

View File

@ -1,13 +1,18 @@
// from '.env' in root folder
module.exports = {
// from '.env' in root folder
// APP
port: process.env.PORT || 3001,
environment: process.env.NODE_ENV || 'development',
// DATABASE
dbURL: process.env.DATABASE_URL,
// JWT
jwtSecret: process.env.JWT_SECRET,
saltingRounds: process.env.SALTING_ROUNDS || 10,
// NODEMAILER
smtpHost: process.env.SMTP_HOST,
smtpPort: process.env.SMTP_PORT,
smtpUsername: process.env.SMTP_USERNAME,
smtpPassword: process.env.SMTP_PASSWORD,
// Others
saltingRounds: process.env.SALTING_ROUNDS || 10,
smtpSecure: process.env.SMTP_SECURE || true, // use TLS
smtpPool: process.env.SMTP_POOL|| true, // Pool connections to server
};

View File

@ -0,0 +1,20 @@
const nodemailer = require('nodemailer');
const {
smtpPool,
smtpHost,
smtpPort,
smtpUsername,
smtpPassword,
} = require('../config/config');
nodemailer.createTransport({
pool: smtpPool,
host: smtpHost,
port: smtpPort,
secure: smtpSecure,
auth: {
user: smtpUsername,
pass: smtpPassword,
},
});