From 81e192bee42733a8a2e27adc916c8e0c35b5a20a Mon Sep 17 00:00:00 2001 From: sudarsan ps Date: Wed, 2 May 2018 11:34:09 +0530 Subject: [PATCH] code optimization --- routes/dashboard.js | 8 ++++---- routes/sendemail.js | 6 ------ shared/shared.js | 6 ++++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/routes/dashboard.js b/routes/dashboard.js index 8087b4a..24c5d63 100644 --- a/routes/dashboard.js +++ b/routes/dashboard.js @@ -14,24 +14,24 @@ router.route('/') async.waterfall( [ - function(nextFun){ + (nextFun)=>{ userFunctions.identityEmailList(function(err,emailList){ nextFun(err,emailList); }); }, - function(emailList,nextFun){ + (emailList,nextFun)=>{ userFunctions.identityDomainList(function(err,domainList){ emailList.domainList = domainList nextFun(err,emailList); }); }, - function(emailList,nextFun){ + (emailList,nextFun)=>{ userFunctions.fetchSendQuota(function(err,sendQuota){ emailList.sendQuota = sendQuota nextFun(err,emailList); }); }, - function(emailList,nextFun){ + (emailList,nextFun)=>{ userFunctions.fetchSendStatistics(function(err,sendStatistics){ console.log("sendStatistics:"+JSON.stringify(sendStatistics)); emailList.sendStatistics = sendStatistics diff --git a/routes/sendemail.js b/routes/sendemail.js index dd4497d..f108d98 100644 --- a/routes/sendemail.js +++ b/routes/sendemail.js @@ -32,12 +32,6 @@ router.route('/') if(validator.isEmail(toAddress) && validator.isEmail(fromAddress)){ - let transporter = nodemailer.createTransport({ - SES: new AWS.SES({ - apiVersion: process.env.SES_API_VERSION - }) - }); - transporter.sendMail({ from: fromAddress, to: toAddress, diff --git a/shared/shared.js b/shared/shared.js index e65bf02..40ab9a5 100755 --- a/shared/shared.js +++ b/shared/shared.js @@ -30,3 +30,9 @@ global.nodemailer = require('nodemailer'); global.config = require('../config/config'); + +global.transporter = nodemailer.createTransport({ + SES: new AWS.SES({ + apiVersion: process.env.SES_API_VERSION + }) +});