-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
48 lines (39 loc) · 1.26 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
const express = require("express");
const app = express();
const userRouter = require("./router/userRouter.js");
const adminRouter = require("./router/adminRouter.js");
const session = require("express-session");
const connectDB = require("./Database/database.js");
const nocache = require("nocache");
const path = require("path")
const dotenv = require("dotenv")
dotenv.config();
connectDB()
app.use(express.static("public"));
app.use(express.static("views"));
app.use(express.static("uploads"));
app.use(express.urlencoded({extended : true}));
app.use(express.json());
app.use(session({
secret : "Furnix@session",
resave : false,
saveUninitialized : true
}))
app.use(nocache())
app.use("/static" ,express.static(path.join(__dirname, "public")));
app.set('view engine' , 'ejs');
app.use("/admin" , adminRouter);
app.use('/' , userRouter);
app.use("*",(req,res)=>{
const CartCount = req.session.CartCount
const wishCount = req.session.wishCount
res.status(404).render("user/page-404" , {CartCount , wishCount})
});
app.use((req, res, next) => {
if (req.method === 'GET') {
delete req.session.categorySearch
console.log("hello");
}
next();
});
app.listen(process.env.PORT, console.log(`Server started at ${process.env.PORT} number`));