-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (31 loc) · 1.11 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
const express = require("express");
const cors = require("cors");
const helmet = require("helmet");
const bodyParser = require("body-parser");
const path = require("path");
const config = require("./config");
const harvested = [];
const app = express();
// ################################################ SERVER CONFIGURATION ####################################################
app.enable("trust proxy", 1);
app.use(cors());
app.use(helmet());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.set("view engine", "ejs");
app.use(express.static(path.resolve(__dirname, "static")));
// ################################################ SERVER ROUTE #########################################################
app.get("/", (req, res, next) => {
res.render("pages/index", {
site: config.site,
harvested,
});
});
app.post("/submit", (req, res, next) => {
if (req.body.token) {
harvested.push(req.body.token);
}
return next();
});
// ################################################ EXPORT APP #########################################################
module.exports = app;