From 0bcfb849c810f1eb6ba9cab344a14035c1953da0 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sat, 18 Jul 2020 17:44:48 -0700 Subject: [PATCH] fix(comments): Removing unneeded comments --- config/env/common.js | 6 +-- src/modules/contact/controller.js | 64 ++----------------------------- 2 files changed, 7 insertions(+), 63 deletions(-) diff --git a/config/env/common.js b/config/env/common.js index 91ea11d..3ffae82 100644 --- a/config/env/common.js +++ b/config/env/common.js @@ -6,7 +6,7 @@ module.exports = { port: process.env.PORT || 5001, logPass: 'test', - emailServer: process.env.EMAILSERVER ? process.env.EMAILSERVER : 'mail.launchpadip.net', - emailUser: process.env.EMAILUSER ? process.env.EMAILUSER : 'noreply@launchpadip.net', - emailPassword: process.env.EMAILPASS ? process.env.EMAILPASS : 'testtest' + emailServer: process.env.EMAILSERVER ? process.env.EMAILSERVER : 'mail.someserver.com', + emailUser: process.env.EMAILUSER ? process.env.EMAILUSER : 'noreply@someserver.com', + emailPassword: process.env.EMAILPASS ? process.env.EMAILPASS : 'emailpassword' } diff --git a/src/modules/contact/controller.js b/src/modules/contact/controller.js index 1ed1714..504762b 100644 --- a/src/modules/contact/controller.js +++ b/src/modules/contact/controller.js @@ -44,7 +44,10 @@ class Contact { // Email list is optional if (emailObj.emailList) { - if (!Array.isArray(emailObj.emailList) || !emailObj.emailList.length > 0) { + if ( + !Array.isArray(emailObj.emailList) || + !emailObj.emailList.length > 0 + ) { throw new Error("Property 'emailList' must be a array of emails!") } else { _to = emailObj.emailList @@ -69,64 +72,5 @@ class Contact { throw err } } - - /* // Handles the sending of data via email. - async sendEmail (data) { - try { - // Validate input - if (!data.email || typeof data.email !== 'string') { - throw new Error('Property \'email\' must be a string!') - } - const isEmail = await _this.validateEmail(data.email) - if (!isEmail) { - throw new Error('Property \'email\' must be email format!') - } - if (!data.formMessage || typeof data.formMessage !== 'string') { - throw new Error('Property \'message\' must be a string!') - } - // create reusable transporter object using the default SMTP transport - const transporter = await _this.nodemailer.createTransport({ - host: 'box.bchtest.net', - port: 587, - secure: false, // true for 465, false for other ports - auth: { - user: _this.config.emailUser, // generated ethereal user - pass: _this.config.emailPassword // generated ethereal password - } - }) - // console.log(`transporter: ${JSON.stringify(transporter.sendMail)}`) - const msg = data.formMessage.replace(/(\r\n|\n|\r)/g, '
') - const now = new Date() - const htmlMsg = ` -

New Contact Form

-

- time: ${now.toLocaleString()}
- name: ${data.name}
- email: ${data.email}
- message: ${msg}
-

- ` - // send mail with defined transport object - const info = await transporter.sendMail({ - from: `${data.email}`, // sender address - to: _this.config.emailUser, // list of receivers - subject: 'Project Pearson', // Subject line - // html: 'This is a test email' // html body - html: htmlMsg - }) - console.log('Message sent: %s', info.messageId) - } catch (err) { - console.log('Error in sendEmail()') - throw err - } - } - // Validate email - async validateEmail (email) { - // eslint-disable-next-line no-useless-escape - if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) { - return (true) - } - return (false) - } */ } module.exports = Contact