-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (27 loc) · 758 Bytes
/
server.js
File metadata and controls
33 lines (27 loc) · 758 Bytes
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
'use strict'
const path = require('path')
const express = require('express')
const session = require('express-session')
const bodyParser = require('body-parser')
const routes = require('./routes')
const PORT = process.env.PORT || 8000
const app = express()
app.use(bodyParser.json())
app.use(session({
secret: 'definitely not keyboard cat',
cookie: { maxAge: 3600000 },
resave: true,
saveUninitialized: true,
secure: false,
httpOnly: false
}))
app.use(express.static(path.join(__dirname, 'build')))
app.use(routes)
app.get('*', (req, res, next) => {
if (req.accepts('html')) {
res.sendFile(path.join(__dirname, 'build', 'index.html'))
} else {
next()
}
})
app.listen(PORT, () => console.log(`Server started on port ${PORT}`))