-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
62 lines (42 loc) · 1.39 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
const express = require("express")
const app = express()
const path = require("path")
const bodyParser = require("body-parser")
const session = require("express-session")
const nocache = require("nocache")
// const morgan = require("morgan")
const dotenv = require("dotenv");
dotenv.config();
const PORT = process.env.PORT || 3000
// const googlePassport = require("./helpers/passport")
// const passport = require("passport")
// const cors = require('cors');
require("./DB/dataBase")
// app.use(passport.initialize())
// app.use(passport.session())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(nocache())
// app.use(cors());
// app.use(morgan('dev'));
app.use(session({
secret: process.env.SESSION_SECRET_KEY,
resave: false,
saveUninitialized: true,
cookie: {
maxAge: 72 * 60 * 60 * 1000,
httpOnly: true
}
}))
app.set("view engine", "ejs")
app.set("views", [path.join(__dirname, "views/user"), path.join(__dirname, "views/admin")])
app.use(express.static(path.join(__dirname, "public")))
const userRoutes = require("./routes/userRouter")
const adminRoutes = require("./routes/adminRouter")
app.use("/", userRoutes)
app.use("/admin", adminRoutes)
app.get('*', function (req, res) {
res.redirect("/pageNotFound");
// console.log("here");
});
app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`))