-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.js
33 lines (33 loc) · 1018 Bytes
/
server.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
'use strict'
require('dotenv').config()
const express = require('express')
const passport = require('passport')
require('./config/passportConfig')(passport) // pass passport for configuration
const app = express()
const session = require('express-session')
const routes = require('./routes')
const sessionStore = require('./config/promiseConnection')
const PORT = process.env.PORT
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'))
}
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.use(
session({
secret: 'hotelworxmernapplication',
store: sessionStore,
resave: false,
saveUninitialized: false,
cookie: {
maxAge: 3600000, // 3600000 1 hour in milliseconds. The expiration time of the cookie to set it as a persistent cookie.
sameSite: true
}
})
)
app.use(passport.initialize())
app.use(passport.session())
app.use(routes)
app.listen(PORT, () =>
console.log(`Express API listening on http://localhost:${PORT}`)
)