Created
October 26, 2018 11:39
-
-
Save sirdarthvader/f214f61e3b0fff970d2017f0d1b8823c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const mongoose = require('mongoose'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
//connect to mongoose | |
mongoose.Promise = global.Promise; | |
mongoose | |
.connect( | |
'mongodb://DB-username:Db-password@ds133353.mlab.com:33353/DB-name', | |
{ useNewUrlParser: true } | |
) | |
.then(() => { | |
console.log('mongoDB connected'); | |
}) | |
.catch(err => { | |
console.log('trouble connecting mongoDB'); | |
}); | |
//Home page | |
app.get('/', (req, res) => { | |
res.send('about'); | |
}); | |
const PORT = process.env.PORT || 5000; | |
app.listen(PORT, () => { | |
console.log(`Server started on port ${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment