observe-to-email

git clone git://git.codymlewis.com/observe-to-email.git
Log | Files | Refs | README

commit bcb1269ff118ba90553c131dd2795b76fe909f56
parent be238e145f135ab53a58dcb358d259d74d15c242
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Sat,  8 Sep 2018 22:20:35 +1000

Removed pointless dependency

Diffstat:
Mapp.js | 2--
Mpackage.json | 31+++++++++++++++----------------
Aroutes/.#index.js | 2++
Mroutes/index.js | 68++++++++++++++++++++++++++++++++++----------------------------------
Droutes/users.js | 9---------
5 files changed, 51 insertions(+), 61 deletions(-)

diff --git a/app.js b/app.js @@ -6,7 +6,6 @@ var cookieParser = require('cookie-parser'); var logger = require('morgan'); var indexRouter = require('./routes/index'); -var usersRouter = require('./routes/users'); var app = express(); @@ -22,7 +21,6 @@ app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', indexRouter); -app.use('/users', usersRouter); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/package.json b/package.json @@ -1,18 +1,17 @@ { - "name": "seng2260observe", - "version": "0.0.0", - "private": true, - "scripts": { - "start": "node ./bin/www" - }, - "dependencies": { - "adaro": "~1.0.4", - "cookie-parser": "~1.4.3", - "debug": "~2.6.9", - "express": "~4.16.0", - "formidable": "^1.2.1", - "http-errors": "~1.6.2", - "morgan": "~1.9.0", - "nodemailer": "^4.6.8" - } + "name": "seng2260observe", + "version": "0.0.0", + "private": true, + "scripts": { + "start": "node ./bin/www" + }, + "dependencies": { + "adaro": "~1.0.4", + "cookie-parser": "~1.4.3", + "debug": "~2.6.9", + "express": "~4.16.0", + "http-errors": "~1.6.2", + "morgan": "~1.9.0", + "nodemailer": "^4.6.8" + } } diff --git a/routes/.#index.js b/routes/.#index.js @@ -0,0 +1 @@ +uxie@distortion-world.23764:1536322038+ \ No newline at end of file diff --git a/routes/index.js b/routes/index.js @@ -12,42 +12,42 @@ router.get('/observe', function(req, res, next) { router.post('/observe', function(req, res, next) { var nodemailer = require('nodemailer'); - var form = new formidable.IncomingForm(); - form.parse(req, function (err, fields, files) { - var today = new Date(); - console.log("Started creating message"); - msg = '\\subsubsection{Test from ' + today.toDateString() + '}\n' + - '\\begin{center}\n\\begin{tabular}{| c | c |}\n\\hline\n' + - '\ninterface type & ' + fields.interface + - '\\\\\\hline\ntime taken & ' + fields.time + 'mins' + - '\\\\\\hline\nThe tester felt & ' + fields.expression + - '\\\\\\hline\nThe tester thought the system would be useful for & ' + fields.testerAction + - '\\\\\\hline\nThe tester commented & ' + fields.testerComment + - '\\\\\\hline\nOther observations & ' + fields.otherComment + - '\\\\\n\\hline\n\\end{tabular}\n\\end{center}'; - var transporter = nodemailer.createTransport({ - service: 'gmail', - auth: { - user: 'seng2260efg@gmail.com', - pass: 'seng2260hla9000' - } - }); - var mailOptions = { - from: 'seng2260efg@gmail.com', - to: 'seng2260efg@gmail.com', - subject: 'HLA9000 - Observations: ' + today.toDateString(), - text: msg - }; - console.log("Sending mail"); - transporter.sendMail(mailOptions, function(error, info){ - if (error) { - console.log(error); - } else { - console.log('Email sent: ' + info.response); - } + // var form = new formidable.IncomingForm(); + // form.parse(req, function (err, req.body, files) { + var today = new Date(); + console.log("Started creating message"); + msg = '\\subsubsection{Test from ' + today.toDateString() + '}\n' + + '\\begin{center}\n\\begin{tabular}{| c | c |}\n\\hline\n' + + '\ninterface type & ' + req.body.interface + + '\\\\\\hline\ntime taken & ' + req.body.time + 'mins' + + '\\\\\\hline\nThe tester felt & ' + req.body.expression + + '\\\\\\hline\nThe tester thought the system would be useful for & ' + req.body.testerAction + + '\\\\\\hline\nThe tester commented & ' + req.body.testerComment + + '\\\\\\hline\nOther observations & ' + req.body.otherComment + + '\\\\\n\\hline\n\\end{tabular}\n\\end{center}'; + var transporter = nodemailer.createTransport({ + service: 'gmail', + auth: { + user: 'seng2260efg@gmail.com', + pass: 'seng2260hla9000' + } + }); + var mailOptions = { + from: 'seng2260efg@gmail.com', + to: 'seng2260efg@gmail.com', + subject: 'HLA9000 - Observations: ' + today.toDateString(), + text: msg + }; + console.log("Sending mail"); + transporter.sendMail(mailOptions, function(error, info){ + if (error) { + console.log(error); + } else { + console.log('Email sent: ' + info.response); + } - }); }); + // }); res.redirect('/success'); }); router.get('/success', function(req, res, next) { diff --git a/routes/users.js b/routes/users.js @@ -1,9 +0,0 @@ -var express = require('express'); -var router = express.Router(); - -/* GET users listing. */ -router.get('/', function(req, res, next) { - res.send('respond with a resource'); -}); - -module.exports = router;