-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (39 loc) · 1.08 KB
/
app.js
File metadata and controls
44 lines (39 loc) · 1.08 KB
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
const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");
const app = express();
const PORT = process.env.PORT || 3000;
const HOST = process.env.HOST || "http://localhost";
console.log(process.env.SENDGRID_API_KEY);
const sgMail = require("@sendgrid/mail");
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
app.listen(PORT, () => console.log(`Server is running on ${HOST}:${PORT}`));
app.use(express.json());
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.use(
cors({
origin: [process.env.CLIENT_URL, "http://127.0.0.1:5500"],
methods: ["GET", "POST"],
})
);
app.post("/feedback", (req, res) => {
sendFeedbackConfirmation(req.body);
res.status(201).send();
});
app.get("/", (req, res) => {
res.status(201).send("CheckMate");
});
function sendFeedbackConfirmation(email) {
const mail = {
to: email,
from: "checkMate@gmail.com",
subject: "Checkmate Feedback",
html:
"<p>Thank you for your feedback 💝</p> <p>Regards, <br> Farfosheen Team 🔥</p>",
};
sgMail.send(mail);
}