-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.js
28 lines (20 loc) · 883 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
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const cors = require('cors');
const path = require('path');
const users = require('./routes/api/users')
const app = express();
const port = 5000;
app.use(cors());
app.use(express.static(path.join(__dirname, 'client/build')))
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
URIRemote = "mongodb+srv://kodfyl:[email protected]/test?retryWrites=true"
URILocal = "mongodb://localhost/myDB"
mongoose.connect(URIRemote, { useNewUrlParser: true }).then(
() => console.log("Database connection successfull")).catch(
(err) => console.log("Database connection failed!", err)
);
app.use('/api/users', users);
app.listen(port, () => console.log('Server running on Port' , port));