-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (27 loc) · 769 Bytes
/
index.js
File metadata and controls
33 lines (27 loc) · 769 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
33
require('dotenv').config();
import express from 'express';
import cors from 'cors';
import bp from 'body-parser';
import mongoose from 'mongoose';
import playerRoutes from './routes/playerRoutes';
import gameRoutes from './routes/gameRoutes';
const app = express();
const PORT = process.env.PORT || 4000;
mongoose.Promise = global.Promise;
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
//body-parser setup
app.use(bp.urlencoded({extended: true}));
app.use(bp.json());
//CORS Setup
app.use(cors())
playerRoutes(app)
gameRoutes(app)
app.get('/', (req, res) => {
res.send(`Our application is running on port ${PORT}`)
})
app.listen(PORT, () =>{
console.log(`Your server is running on port ${PORT}`)
})