-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (29 loc) · 961 Bytes
/
server.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
35
36
37
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require("cors");
const path = require('path');
const scores = require('./routes/api/scores');
const port = process.env.PORT || 8080;
const app = express();
const db = process.env.MONGO_URI
mongoose
.connect(db, { useNewUrlParser: true })
.then(() => console.log("Connected to MongoDB successfully"))
.catch(err => console.log(err));
app.use(express.static(__dirname));
app.use(
cors({
origin: "https://www.natedonato.com",
})
);
app.get('/', (req, res) => {
res.sendFile(path.resolve(__dirname, 'index.html'));
});
app.get('/mobile', (req, res) => {
res.sendFile(path.resolve(__dirname, 'mobile.html'));
});
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use('/api/scores', scores);
app.listen(port, () => console.log(`Server is running on port ${port}`));