This commit is contained in:
jslightham
2020-02-27 11:39:24 -05:00
parent fca7d1e8db
commit 52d2d79548
11 changed files with 121 additions and 25 deletions

View File

@@ -0,0 +1,5 @@
// DB.js
module.exports = {
DB: 'mongodb://localhost:27017/mevncrud'
}

View File

View File

View File

@@ -0,0 +1,21 @@
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const PORT = 4000;
const cors = require('cors');
const mongoose = require('mongoose');
const config = require('./DB.js');
mongoose.Promise = global.Promise;
mongoose.connect(config.DB, { useNewUrlParser: true }).then(
() => {console.log('Database is connected') },
err => { console.log('Can not connect to the database'+ err)}
);
app.use(cors());
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.listen(PORT, function(){
console.log('Server is running on Port:',PORT);
});