-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
222 lines (191 loc) · 5.44 KB
/
index.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
const express = require("express");
const path = require("path");
const bodyParser = require('body-parser');
const nodemailer = require("nodemailer");
const app = express();
app.set('view engine', 'ejs');
app.set('views', './frontend/views/');
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static('./frontend/public/images'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const port = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.render('index', { title: 'San Antonio Professional Cleaning Services' });
});
app.get('/about', (req, res) => {
res.render('about', { title: 'Local Cleaning Services' });
});
app.get('/clean', (req, res) => {
res.render('clean', { title: 'Santization and Sterilization | Keeping Clean' });
});
app.get('/service', (req, res) => {
res.render('service', { title: 'Representing Our Own Brand of Cleaning' });
});
app.get('/standard', (req, res) => {
res.render('standard', { title: 'Our Reputation is Our Guaranteed Standard' });
});
app.get('/hire', (req, res) => {
res.render('hire', { title: 'Join Our Professional Cleaning Crew' });
});
app.get('/quote', (req, res) => {
res.render('quote', { title: 'Recieve A Personalized Quote For Our Services' });
});
app.get('/booking', (req, res) => {
res.render('booking', { title: 'Schedule Your Cleaning Routine' });
});
app.post('/getQuote', (req, res) => {
req.body.call = Boolean(req.body.call);
req.body.text = Boolean(req.body.text);
req.body.comm = Boolean(req.body.comm);
req.body.resd = Boolean(req.body.resd);
const output = `
<p>Quote Request for Cleaning Services </p>
<h3>Contact Details</h3>
<ul>
<li>First Name: ${req.body.first}</li>
<li>Last Name: ${req.body.last}</li>
<li>Phone Number ${req.body.phone}</li>
<li>Email: ${req.body.email}</li><br>
Requires Phone Call: ${req.body.call} <br>
Request Text Msg Quote: ${req.body.text}
</ul>
<h3>Home Details</h3>
Square Footage: ${req.body.square} <br>
Commercial: ${req.body.comm} <br>
Resedential: ${req.body.resd} <br>
<h3>Comments</h3>
<p>${req.body.comment}</p>
`
let transporter = nodemailer.createTransport({
host: process.env.host,
port: process.env.nm_port,
secure: false,
auth: {
user: process.env.user,
pass: process.env.pass,
},
tls:{
rejectUnauthorized: false
}
});
let info = transporter.sendMail({
from: process.env.user,
to: process.env.user,
subject: "Quote for Cleaning Services",
text: "Request for Quote",
html: output
});
res.redirect('back');
});
app.post('/getDate', (req, res) => {
const output = `
<p>Schedule Date for Cleaning Services</p>
<h3>Contact Details</h3>
<ul>
<li>First Name: ${req.body.first}</li>
<li>Last Name: ${req.body.last}</li>
<li>Phone Number ${req.body.phone}</li>
<li>Email: ${req.body.email}</li><br>
Proposed Date for Cleaning: ${req.body.date}
</ul>
<h3>Home Details</h3>
Square Footage: ${req.body.square} <br>
Address: ${req.body.address} <br>
<h3>Comments</h3>
<p>${req.body.comment}</p>
`
let transporter = nodemailer.createTransport({
host: process.env.host,
port: process.env.nm_port,
secure: false,
auth: {
user: process.env.user,
pass: process.env.pass,
},
tls:{
rejectUnauthorized: false
}
});
let info = transporter.sendMail({
from: process.env.user,
to: process.env.user,
subject: "Request for Cleaning Services",
text: "Schedule a Cleaning Date",
html: output
});
res.redirect('back');
});
app.post('/rateUs', (req, res) => {
const output = `
<p>Rate Our Cleaning Services</p>
<h3>Contact Details</h3>
<ul>
<li>First Name: ${req.body.first}</li>
<li>Last Name: ${req.body.last}</li>
</ul>
<h3>Star Rating</h3>
<p>User Rating: ${req.body.score}</p>
<h3>Comments</h3>
<p>${req.body.comment}</p>
`
let transporter = nodemailer.createTransport({
host: process.env.host,
port: process.env.nm_port,
secure: false,
auth: {
user: process.env.user,
pass: process.env.pass,
},
tls:{
rejectUnauthorized: false
}
});
let info = transporter.sendMail({
from: process.env.user,
to: process.env.user,
subject: "Rate Our Cleaning Services",
text: "Star Rating System",
html: output
});
res.redirect('back');
});
app.post('/sendFeed', (req, res) => {
const output = `
<p>Send Us Your Feedback</p>
<h3>Contact Details</h3>
<ul>
<li>First Name: ${req.body.first}</li>
<li>Last Name: ${req.body.last}</li>
</ul>
<h3>Contact Information</h3>
<p>Customer Email: ${req.body.email}</p>
<h3>Comments</h3>
<p>${req.body.comment}</p>
`
let transporter = nodemailer.createTransport({
host: process.env.host,
port: process.env.nm_port,
secure: false,
auth: {
user: process.env.user,
pass: process.env.pass,
},
tls:{
rejectUnauthorized: false
}
});
let info = transporter.sendMail({
from: process.env.user,
to: process.env.user,
subject: "Cleaning Feedback/Comments",
text: "Customers Thoughts",
html: output
});
res.redirect('back');
});
app.use((req, res) => {
res.status(404).render('error', { title: 'Page Not Found' });
});
app.listen(port, () =>
console.log(`Listening at http://localhost:${port}`));