-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
51 lines (43 loc) · 1.55 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
require("dotenv").config();
const express = require("express");
const fileupload = require("express-fileupload");
const bodyParser = require("body-parser");
const cookieSession = require("cookie-session");
const dbController = new (require("./db/dbController"))();
const api = require("./router/api");
const user = require("./router/userHandler");
const lostItems = require("./router/lostItems");
const packingList = require("./router/packingList");
const push = require("./router/push");
const badges = require("./router/badges");
const alpacrash = require("./router/alpacrash");
const coach = require("./router/coach");
const app = express();
const PORT = process.env.PORT || 80;
app.use(fileupload({}));
app.use(express.static("public"));
app.use("/lostitems/images", express.static("uploads/lostItems/"));
app.use("/alpacrash/images", express.static("uploads/alpacrash/"));
app.use(bodyParser.urlencoded({extended: false, limit: "50mb"}));
app.use(bodyParser.json({limit: "50mb"}));
app.use((_, res, next) => {
res.append("Service-Worker-Allowed", "/");
next();
});
app.use(cookieSession({
name: 'session',
secret: 'theBestSecretKey' // TODO: Random key
}));
dbController.init();
app.use("/api", api);
app.use("/user", user);
app.use("/lostitems", lostItems);
app.use("/packinglist", packingList);
app.use("/push", push);
app.use("/badges", badges);
app.use("/alpacrash", alpacrash);
app.use("/coach", coach);
app.get('*', (req, res) => {
res.status(404).redirect("/#/404");
});
app.listen(PORT, () => console.log(`Listening on http://localhost:${PORT}`));