-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (40 loc) · 1.29 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
const express = require('express');
const axios = require('axios');
const bodyParser = require('body-parser');
const cors = require('cors');
const cron = require('node-cron');
const mongoose = require('mongoose');
const session = require('express-session');
var passport = require('passport');
var crypto = require('crypto');
var routes = require('./routes/index');
const googleRoutes = require('./googleConfig/googleAuth')
const connection = require('./config/databaseLocal');
const MongoStore = require('connect-mongo')(session);
require('./config/passport');
require('./googleConfig/googleAuth');
require('dotenv').config();
const app = express();
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(cors());
const sessionStore = new MongoStore({mongooseConnection:connection,collection:'sessions'})
app.use(session({
secret: process.env.SECRET,
resave: false,
saveUninitialized: true,
store: sessionStore,
cookie:{
maxAge: 1000 * 60 * 60 * 24
}
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(routes);
app.use(googleRoutes);
const port = 5002||process.env.PORT;
app.listen(port,()=>{
console.log(`Server is listening on port ${port}....`)
})