-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (30 loc) · 868 Bytes
/
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
const express = require("express");
const session = require("express-session");
const bodyParser = require("body-parser");
const app = express();
const routes = require("./public/scripts/routes.js");
const port = process.env.PORT ? process.env.PORT : 8000;
require("dotenv").config();
const sessionConfig = {
secret: process.env.cookieSecret,
name: "movieinfo",
resave: false,
saveUninitialized: false,
cookie: {
sameSite: "Lax"
}
}
app.set("trusty proxy", 1);
sessionConfig.cookie.secure = true;
app.use(session(sessionConfig));
app.use(express.static(process.cwd() + "/public"));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.set("view engine", "pug");
routes(app);
app.listen(port, (err) => {
if (err) {
console.error("Error in server setup")
}
console.log(`Server is active on port ${port}`)
})