-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (35 loc) · 1.05 KB
/
index.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
import express from "express";
import session from "express-session";
import env from "dotenv";
import passport from "passport";
import authRoutes from "./routes/auth.js";
import blogRoutes from "./routes/blog.js";
import profileRoutes from "./routes/profile.js";
import postRoutes from "./routes/post.js";
import listRoutes from "./routes/listing.js"
const app = express();
const port = 3000;
env.config();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
cookie: {
maxAge: 1000 * 60 * 60 * 24 * 7 // ms * s * m * h * d
},
})
);
app.use(passport.initialize());
app.use(passport.session());
app.use(authRoutes); // use auth.js from routes
app.use(blogRoutes); // use blog.js from routes
app.use(profileRoutes); // render profile and profile setting features
app.use(postRoutes);
app.use(listRoutes);
app.use(express.static(`public`));
app.listen(port, ()=>{
console.log(`${port} Opened`)
})