forked from shanedgilbert/Stub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (25 loc) · 1.1 KB
/
index.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
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';
import showRoutes from './routes/shows.js';
import accountRoutes from './routes/accounts.js';
import listRoutes from './routes/lists.js';
const app = express();
app.use(bodyParser.json({ limit: '30mb', extended: true }))
app.use(bodyParser.urlencoded({ limit: '30mb', extended: true }))
app.use(cors());
app.use('/shows', showRoutes);
app.use('/accounts', accountRoutes);
app.use('/listsdb', listRoutes);
const CONNECTION_URL = 'mongodb+srv://scottsak:[email protected]/Stub';
const PORT = process.env.PORT|| 5000;
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
};
app.get('*', (request, response) => {
response.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => app.listen(PORT, () => console.log(`Server Running on Port: http://localhost:${PORT}`)))
.catch((error) => console.log(`${error} did not connect`));