-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (40 loc) · 1.01 KB
/
Copy pathindex.js
File metadata and controls
49 lines (40 loc) · 1.01 KB
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
import express from "express";
import cors from "cors";
import session from "express-session";
import dotenv from "dotenv";
import db from "./config/Database.js";
import SequelizeStore from "connect-session-sequelize";
import UserRoute from "./routes/UserRoute.js";
import ProductRoute from "./routes/ProductRoute.js";
import AuthRoute from "./routes/AuthRoute.js";
dotenv.config();
const app=express();
const PORT=process.env.APP_PORT;
const sessionStore=SequelizeStore(session.Store);
const store=new sessionStore({
db:db
});
// (async() => {
// await db.sync();
// })();
app.use(session({
secret:process.env.SESSION_SECRET,
resave:false,
saveUninitialized:true,
store:store,
cookie:{
secure:"auto"
}
}));
app.use(cors({
credentials:true,
origin:"http://localhost:3000"
}));
app.use(express.json());
app.use(UserRoute);
app.use(ProductRoute);
app.use(AuthRoute);
// store.sync();
app.listen(PORT,() => {
console.log(`Server up and running on ${[process.env.APP_PORT]}`)
});