-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (34 loc) · 1.1 KB
/
Copy pathserver.js
File metadata and controls
44 lines (34 loc) · 1.1 KB
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
38
39
40
41
42
43
44
const express = require("express");
const mongoose = require("mongoose");
const path = require('path');
const config = require('config');
const app = express();
app.use(express.static(path.join(__dirname,'client','build')));
app.get('/', (req,resp) => {
console.log('hellow orld!');
resp.sendFile(path.join(__dirname,'client','build','index.html'));
});
app.use(express.json());
app.use(express.urlencoded({extended: false}));
const db = config.get('mongoURI');
mongoose
.connect(
db,
{
useNewUrlParser: true,
useCreateIndex: true,
//useUnifiedTopology: true
}
)
.then(() => console.log("MongoDB successfully connected"))
.catch(err => console.log(err));
//app.get('*', (req,resp) => {
//console.log('hellow orld!');
//resp.sendFile(__dirname+'/index.html');
//})
app.use('/api/user', require('./routes/api/user'));
app.use('/api/events', require('./routes/api/events'));
app.use('/api/auth', require('./routes/api/auth'));
const port = 8080;
app.listen(port, () => console.log(`Server running on port ${port}`));
module.exports = app;