Last active
October 27, 2018 12:33
-
-
Save sirdarthvader/7eac981bcac5296ede670706bc5eb32d to your computer and use it in GitHub Desktop.
This file contains hidden or 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'); | |
//Instantiate express app | |
const app = express(); | |
//connect to mongoose | |
mongoose.Promise = global.Promise; | |
mongoose | |
.connect( | |
'mongodb://ashish:[email protected]:33353/ideajot', | |
{ useNewUrlParser: true } | |
) | |
.then(() => { | |
console.log('mongoDB connected'); | |
}) | |
.catch(err => { | |
console.log('trouble connecting mongoDB'); | |
}); | |
//Get root route | |
app.get('/', (req, res) => { | |
res.send('root route of the server'); | |
}); | |
//Start the port and server | |
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