Skip to content

Instantly share code, notes, and snippets.

@sirdarthvader
Last active October 27, 2018 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirdarthvader/7eac981bcac5296ede670706bc5eb32d to your computer and use it in GitHub Desktop.
Save sirdarthvader/7eac981bcac5296ede670706bc5eb32d to your computer and use it in GitHub Desktop.
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:db1234@ds133353.mlab.com: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