UNPKG

node-express-mongodb-jwt-rest-api-skeleton

Version:

Node.js express.js MongoDB JWT REST API - This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API)

32 lines (29 loc) 774 B
const { sendEmail } = require('./sendEmail') /** * Prepares to send email * @param {string} user - user object * @param {string} subject - subject * @param {string} htmlMessage - html message */ const prepareToSendEmail = (user = {}, subject = '', htmlMessage = '') => { user = { name: user.name, email: user.email, verification: user.verification } const data = { user, subject, htmlMessage } if (process.env.NODE_ENV === 'production') { sendEmail(data, (messageSent) => messageSent ? console.log(`Email SENT to: ${user.email}`) : console.log(`Email FAILED to: ${user.email}`) ) } else if (process.env.NODE_ENV === 'development') { console.log(data) } } module.exports = { prepareToSendEmail }