-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
59 lines (49 loc) · 1.56 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
52
53
54
55
56
57
58
59
// REQUIRES
const express = require("express");
const path = require("path");
const cors = require("cors");
const bodyParser = require("body-parser");
const session = require("express-session");
// ROUTE REQUIRES
const homeRoute = require("./routes/home");
const errorRoute = require("./routes/error");
const saveRoute = require("./routes/save");
const editRoute = require("./routes/edit");
const deleteRoute = require("./routes/delete");
const loginRoute = require("./routes/login");
const logoutRoute = require("./routes/logout");
const registerRoute = require("./routes/register");
const mineRoute = require("./routes/mine");
// CONSTANTS
const PORT = process.env.PORT || 80;
// APP CREATION & CONFIG
const app = express();
app.engine("pug", require("pug").__express)
app.set("views", path.join(__dirname, "views"))
app.set("view engine", "pug");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
app.use(express.static(path.join(__dirname, "public")));
// app.use(cookieParser());
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true,
cookie: {
// secure: true,
maxAge: null
}
}));
// APP ROUTING
app.use("/", homeRoute);
app.use("/error", errorRoute);
app.use("/save", saveRoute);
app.use("/edit", editRoute);
app.use("/delete", deleteRoute);
app.use("/login", loginRoute);
app.use("/logout", logoutRoute);
app.use("/register", registerRoute);
app.use("/mine", mineRoute);
// APP LISTENING
app.listen(PORT, () => console.log("Quickbin listening on port " + PORT));