-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
68 lines (51 loc) · 1.93 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
68
var express = require('express');
var app = express();
var emailJS = require('emailjs/email');
var PORT = process.env.PORT || 3000;
var bodyParser = require('body-parser');
// create application/json parser
var jsonParser = bodyParser.json()
// create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })
app.use('/',jsonParser);
app.use(express.static(__dirname + '/public'));
app.get('/team', function(req,res){
res.sendFile(__dirname + '/public/app/team/team.html');
});
app.get('/', function (req, res){
res.sendFile(__dirname + '/public/app/index.html');
});
app.get('/contact', function(req,res){
res.sendFile(__dirname + '/public/app/contact_form/contact_form.html');
});
app.get('/portfolio', function(req,res){
res.sendFile(__dirname + '/public/app/portfolio/portfolio.html');
});
app.post('/contact-submit',function(req,res){
var requestBody = (req.body);
// ['veebuv@gmail.com','vnamburi92@gmail.com'].forEach(function(email){
sendEmailTo('zenkara.global@gmail.com',requestBody.name,requestBody.email,requestBody.message,req,res)
// })
res.json({formSubmissionSuccess: true});
})
app.post('/test-api', function(req,res){
console.log('body', req.body)
})
app.listen(PORT, function () {
console.log('Example app listening on: ' + PORT);
});
//************NODE EMAIL
var api_key = 'key-110eb41b3bea0d31e9e327a341365aad';
var domain = 'zenkara.io';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
function sendEmailTo (email_id,client_name,client_email,message,req,res){
var message = {
from: "Zenkara <customer@zenkara.mailgun.org>",
to: 'zenkara.global@gmail.com',
subject: client_name + " wants to chat with us!",
text: "They can be reached on: " + client_email + " and they have a message : \n" + message
};
mailgun.messages().send(message, function (error, body) {
console.log('error', body);
});
}