'use strict';

let express = require('express'),
    app = express(),
    load = require('express-load'),
    db = require('./app/mongo/mongoConnection')

process.db = db;

load('routes', {
    cwd: 'app'
}).then('mongo').into(app)

//db.connect('mongodb://localhost:27017/cookbook', function(err) {
db.connect('mongodb://heroku_cmbkjpkr:q7i1u0lhd9n6m542b6g9igj8jc@ds145997.mlab.com:45997/heroku_cmbkjpkr', function(err) {
    if (err) {
        console.log('Unable to connect to Mongo.')
        process.exit(1)
    } else {
        app.listen(process.env.PORT || 3000, function() {
            console.log('Here we go...')
        })
    }
})

@@ -150,260 +150,325 @@
 on')
-%0A%0Aprocess.db = db;%0A%0Aload('routes', %7B%0A    cwd: 'app'%0A%7D).then('mongo').into(app)%0A%0A//db.connect('mongodb://localhost:27017/cookbook', function(err) %7B%0Adb.connect('mongodb://heroku_cmbkjpkr:q7i1u0lhd9n6m542b6g9igj8jc@ds145997.mlab.com:45997/heroku_cmbkjpkr'
+,%0A    url = 'mongodb://localhost:27017/cookbook'%0A%0Aif (process.MONGODB_URI) %7B%0A    url = 'mongodb://heroku_cmbkjpkr:q7i1u0lhd9n6m542b6g9igj8jc@ds145997.mlab.com:45997/heroku_cmbkjpkr'%0A%7D%0A%0Aprocess.db = db;%0A%0Aload('routes', %7B%0A    cwd: 'app'%0A%7D).then('mongo').into(app)%0A%0Aconsole.log(process.MONGODB_URI, url);%0A%0Adb.connect(url
 , fu

test deploy on heroku, url to mongo connection