-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 720 Bytes
/
server.js
File metadata and controls
25 lines (20 loc) · 720 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
import express from 'express'
import leaderBoardModel from './leaderBoardModel'
import morgan from 'morgan'
import bodyParser from 'body-parser'
const app = express()
app.use(bodyParser.json())
app.use(morgan("dev"))
app.set('port', (process.env.PORT || 3001))
// Express only serves static assets in production
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'))
}
app.post('/leaderBoard', (req, res) => {
leaderBoardModel(req.body.leaderBoard)
.then(data => res.send(data.leaderBoard))
.catch(err => console.log(err))
})
app.listen(app.get('port'), () => {
console.log(`Find the server at: http://localhost:${app.get('port')}/`) // eslint-disable-line no-console
})