-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
62 lines (44 loc) · 1.47 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
60
61
62
//jshint esversion:6
require("dotenv").config();
const express = require("express"),
bodyParser = require("body-parser"),
session = require("express-session"),
mysql = require("mysql"),
flash = require("connect-flash"),
methodOverride = require("method-override"),
app = express();
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
name: process.env.SESS_NAME,
cookie: {
secure: false,
maxAge: 3600000,
sameSite: true,
}
}))
app.use(flash());
app.use((req,res,next)=>{
res.locals.loggedUser = req.session.user_name;
res.locals.userStation = req.session.user_station;
res.locals.userFlight = req.session.user_flightNumber;
res.locals.error = req.flash("error");
res.locals.success = req.flash("success");
res.locals.loginerror = req.flash("loginerror");
next()
})
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static("public"));
app.use(methodOverride('_method'));
require("./routes")(app);
app.set("view engine", "ejs");
// Connection To Local Server
let port = process.env.PORT;
if (port == null || port == "") {
port = 3000;
}
app.listen(port, ()=>{
console.log("Flight Ops Connected to local server 3000");
});
//https://medium.com/@sesitamakloe/how-we-structure-our-express-js-routes-58933d02e491