Message from JavaScript discussions

September 2018

— Post code?

— 

Var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var nodemailer = require('nodemailer');

// Create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })

app.use(express.static('static_content'));

app.post('/es/enviar', urlencodedParser, function (req, res) {
const output = `
<p>You have a new contact request</p>
<h3>Contact Details</h3>
<ul>
<li>Name: ${req.body.name}</li>
<li>Email: ${req.body.email}</li>
<li>Subject: ${req.body.subject}</li>
</ul>
<h3>Message</h3>
<p>${req.body.message}</p>
`;

// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({

service:'hotmail',
auth: {
user: process.env.EMAIL_USER, // generated ethereal user
pass: process.env.EMAIL_PASSWORD/ // generated ethereal password
},
tls: {
rejectUnauthorized: false
}
});

// setup email data with unicode symbols
let mailOptions = {
from: '"Nodemailer Contact" <email1hotmail.com>', // sender address
to: 'email2hotmail.com', // list of receivers
subject: 'Node Contact Request', // Subject line
text: 'Hello world?', // plain text body
html: output // html body
};

// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message sent: %s', info.messageId);
console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));

res.render('contact', { msg: 'Email has been sent' });
});
});

app.listen(8080, () => console.log('Server started...'));

— Maybe your browser is hitting the endpoint twice?

— I don't know, it ends after sending the second email

— Server started...
Message sent: <78707965-127f-0c3f-93f1-cf32331c5658hotmail.com>
Preview URL: false
Message sent: <394a12f1-272e-534e-93f8-bf268f1a5971hotmail.com>
Preview URL: false

Message permanent page

— Those are the messages

— Hey guys, im working mainly with react at the moment, i wanted to test my components for a while now...
i use redux in a lot of components (i know keep components stupid & pure as possible, i keep my eye on that).
even thinking of testing the components is a overkill, mocking all the server data first and then writing test cases 🤷‍♂️

Message permanent page

— How would ya'll approach that?

— I debug with marvelous chrome debugger tool. using debugger keyword primarily.

— Ok but is component testing possible with that?

— How would you verify tests?

— You would only be able to check that components contain the correct data, not how they look or behave

Message permanent page