-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (25 loc) · 841 Bytes
/
server.js
File metadata and controls
32 lines (25 loc) · 841 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
const express = require('express')
const app = express()
const port = process.env.PORT || 3001
const logger = require('morgan')
const cors = require('cors')
const bodyParser = require('body-parser')
require("dotenv").config()
require('./config/database')
const path = require('path');
const favicon = require('serve-favicon');
const authRouter = require('./routes/auth')
const tripRouter = require('./routes/trips')
app.use(cors())
app.use(bodyParser.json())
app.use(logger('dev'))
app.use('/api/auth', authRouter)
app.use('/api/trips', tripRouter)
app.use(favicon(path.join(__dirname, 'build', 'favicon.ico')));
app.use(express.static(path.join(__dirname, 'build')));
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.listen(port, () => {
console.log(`Listening on ${port}`)
})