-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
87 lines (70 loc) · 1.63 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
const express = require("express");
const fs = require("fs");
const cors = require("cors");
const {
echo,
getTime,
getName,
getTodo,
getExplara,
getCount,
generateCertificate,
mailer
} = require("./functions");
const app = express();
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(cors());
app.get("/time", (_, res) => {
const t = getTime();
res.send(t);
});
app.get("/ping", (_, res) => {
res.send("pong");
});
app.get("/echo", (req, res) => {
const { query } = req.query;
const data = echo(query);
res.send(data);
});
app.get("/getname", (_, res) => {
res.send(getName());
});
app.get("/gettodos", async (_, res) => {
const data = await getTodo(true);
res.send(data);
});
app.get("/gettodo", async (_, res) => {
const data = await getTodo();
res.send(data);
});
app.get("/explara", async (_, res) => {
const data = await getExplara();
console.log({ data });
res.send(data);
});
app.get("/count", async (_, res) => {
const data = await getCount();
res.send(data);
});
app.get("/certificate", async (_, res) => {
const data = await generateCertificate();
res.send(data);
});
app.post("/mailer", async (_, res) => {
const data = await mailer(_.body);
res.send(data);
});
app.get("/registrations", async (_, res) => {
const filePath = __dirname + "/html/totalRegistration.html";
res.sendFile(filePath);
});
app.get("/", (_, res) => {
console.log("yo");
res.send({ working: "yes bro", status: "Alive and kicking" });
});
if (process.env.isDev) {
app.listen(5000, () => console.log("listening on port 5000"));
}
module.exports = app;
// getWorkshopCount();