-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (36 loc) · 1.1 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
49
50
51
import express, { urlencoded } from "express";
import { connectDB } from "./middleware/connectDB.js";
// import routes
import homeRouter from "./routes/home.route.js";
import apiRouter from "./routes/api.route.js";
import dashboardRouter from "./routes/dashboard.route.js"
import session from 'express-session'
import { callBack, loginController } from "./controllers/auth.controller.js";
const PORT = process.env.PORT
const app = express()
//to be able get req.body
app.use(express.urlencoded({extended: false}))
app.set('view engine', 'pug')
app.set('views', './views')
//session
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
cookie: { secure: false } // Set to true if using HTTPS
}));
// routes
app.use('/', homeRouter)
app.use('/', apiRouter)
app.use('/', dashboardRouter)
// app.use(express.json())
// login and sign up
// app.get('/signup', (req,res) =>{
// res.render('signup')
// })
app.get('/login', loginController)
app.get("/google/callback", callBack);
app.listen(PORT, ()=>{
connectDB()
console.log('hope da')
})