Created
February 19, 2018 11:54
-
-
Save rla/a781e56df772713d92b55957f526d16b to your computer and use it in GitHub Desktop.
Node.js Express config file pattern
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
const config = require('../config.json'); | |
module.exports = config; |
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
{ | |
"port": 8020, | |
"self": "http://localhost:8020", | |
"session": { | |
"key": "xxx" | |
}, | |
"db": { | |
"host": "127.0.0.1", | |
"database": "xxx", | |
"user": "xxx", | |
"password": "xxx" | |
}, | |
"timezone": "Europe/Tallinn", | |
"mail": { | |
"from": "noreply@xxx", | |
"smtp": { | |
"port": 25, | |
"host": "xxx" | |
} | |
} | |
} |
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
const util = require('util'); | |
const nodemailer = require('nodemailer'); | |
const config = require('../config'); | |
const transport = nodemailer.createTransport(config.mail.smtp); | |
// Sends mail. Wrapped into a promise. | |
const sendMail = util.promisify((options, cb) => | |
transport.sendMail(options, cb)); | |
exports.send = sendMail; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment