Skip to content
Snippets Groups Projects
Commit a9965dbd authored by Pietro Cavassin's avatar Pietro Cavassin
Browse files

create message route

parent 57c65d70
No related branches found
No related tags found
1 merge request!309Merge new updates into master
Pipeline #26874 failed
......@@ -23,7 +23,8 @@ transporter.verify(function(error, success) {
});
const mailOptions = {
from: config.email.from
from: config.email.from,
to: config.email.from
};
module.exports = function send(options, cb) {
......
......@@ -128,6 +128,8 @@ const disciplines = require(`${libs}/routes/disciplines`);
const universityLocalOffer = require(`${libs}/routes/universityLocalOffer`);
const message = require(`${libs}/routes/message`);
api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API is running' });
});
......@@ -183,4 +185,5 @@ api.use('/microregion', microregion);
api.use('/location', location);
api.use('/disciplines', disciplines);
api.use('/universityLocalOffer', universityLocalOffer);
api.use('/message', message);
module.exports = api;
/*
Copyright (C) 2021 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
This file is part of simcaq-node.
simcaq-node is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
simcaq-node is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with simcaq-node. If not, see <https://www.gnu.org/licenses/>.
*/
const express = require('express');
const messageApp = express.Router();
const email = require(`../middlewares/email`);
messageApp.post('/', (req, res, next) => {
var reqName = JSON.parse(req.body.name)
var reqEmail = JSON.parse(req.body.email)
var reqContents = JSON.parse(req.body.contents)
let mailOptions = {
from: `"${reqName} <${reqEmail}>"`,
text: reqContents
}
email(mailOptions, (err, info) => {
if(err) {
log.error(err);
res.json({msg: 'Undelivered Contact Mail'});
}
log.info(`Message ${info.messageId} sent: ${info.response}`);
res.json({msg: 'Contact Mail Successfully Delivered'});
});
})
module.exports = messageApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment