-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (28 loc) · 959 Bytes
/
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
const express=require('express');
const passport=require('passport');
var bodyParser = require('body-parser');
const cookieSession=require('cookie-session');
const keys=require('./config/keys');
const app=express();
app.use(require('./utils/cors'));
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json());
const googleSetup=require('./services/googlepassport');
app.use(cookieSession({
maxAge:24*60*60*1000,
keys:[keys.cookieKey]
}));
app.use(passport.initialize()); //this uses googleSetup
app.use(passport.session()); //this uses cookieSession
app.use('/',require('./routes/user'));
//for heroku only
if(process.env.NODE_ENV === 'production'){
app.use(express.static('client/build'))
const path = require('path');
app.get('*',(req,res)=>{
res.sendFile(path.resolve(__dirname,'client','build','index.html'))
})
}
app.listen(process.env.PORT||5555,()=>{
console.log("server started....");
})