var express = require('express'),
    mongoose = require('mongoose'),
    dotenv = require('dotenv'),
    bodyParser = require('body-parser');

/**
 * Load environment variables from .env file, where API keys and passwords are configured.
 */
dotenv.load({ path: '.env.example' });

var db;
if (process.env.ENV == 'Test') {
    db = mongoose.connect(process.env.MONGODB_URI_TEST);
}
else {
    db = mongoose.connect(process.env.MONGODB_URI);
}
mongoose.connection.on('error', () => {
  console.error('MongoDB Connection Error. Please make sure that MongoDB is running.');
  process.exit(1);
});

var Book = require('./models/bookModel');

var app = express();
var port = process.env.PORT || 3000;

app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());

var bookRouter = require('./routes/bookRoutes')(Book);

app.use('/api/books', bookRouter);

app.get('/', function(req, res) {
   res.send('Welcome to my API.');
});

app.listen(port, function() {
    console.log('Now it changed to something else. Running on PORT:' + port);
});

module.exports = app;
@@ -272,24 +272,55 @@
 ample' %7D);%0A%0A
+/**%0A * Connect to MongoDB %0A */%0A
 var db;%0Aif (
@@ -624,50 +624,34 @@
 );%0A%0A
-var Book = require('./models/bookModel');%0A
+/**%0A * Setup ExpressJS%0A */
 %0Avar
@@ -705,17 +705,16 @@
 %7C 3000;%0A
-%0A
 app.use(
@@ -783,16 +783,106 @@
 on());%0A%0A
+/**%0A * Setup Mongoose Model(s) and Route(s)%0A */%0Avar Book = require('./models/bookModel');%0A
 var book
@@ -928,17 +928,16 @@
 (Book);%0A
-%0A
 app.use(
@@ -960,24 +960,60 @@
 okRouter);%0A%0A
+/**%0A * Handle the root GET call%0A */%0A
 app.get('/',
@@ -1069,21 +1069,22 @@
 API.');%0A
-
 %7D);%0A%0A
+%0A
 app.list

format app.js for readability