-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
67 lines (56 loc) · 1.91 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var nodemailer = require('nodemailer');
var express = require("express");
var session = require("express-session");
var queries = require("./functions/queries.js");
var app = express();
var router = express.Router();
var bodyParser = require('body-parser');
var path = __dirname + '/views/';
app.use(express.static(__dirname + '/views/'));
app.use(session({ resave: true , secret: '123456' , saveUninitialized: true}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
router.use(function (req,res,next) {
next();
});
router.get("checkout-fln", function(req,res){
res.sendFile(path + "checkout-fln.html");
});
router.get("/checkout-bc", function(req,res){
res.sendFile(path + "checkout-bc.html");
});
app.post('/send', function (req, res){
queries.insert(req.body.nome, req.body.email, req.body.telefone, req.body.checkin, req.body.pax, req.body.gb, req.body.destino, res, req);
var dadosCompra = [];
dadosCompra.push("Nome", req.body.nome)
dadosCompra.push("Email",req.body.email)
dadosCompra.push("Telefone",req.body.telefone)
dadosCompra.push("Início",req.body.checkin)
dadosCompra.push("Pax",req.body.pax)
dadosCompra.push("Valor",req.body.gb)
dadosCompra.push("Destino",req.body.destino)
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: ''
}
});
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Nova solicitação de compra ViajaPASS - Verifique o pagamento',
text: dadosCompra.toString()
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
});
app.use("/",router);
app.listen(3000,function(){
console.log("Live at port 3000");
});