var fs = require('fs');
var path = require('path');
var mongoose = require('mongoose');
var util = require('util');

var url = util.format('mongodb://%s:%s@%s:%s/%s',
  process.env.APINIC_MOVIES_DB_USERNAME,
  process.env.APINIC_MOVIES_DB_PASSWORD,
  process.env.APINIC_MOVIES_DB_HOST,
  process.env.APINIC_MOVIES_DB_PORT,
  process.env.APINIC_MOVIES_DB_NAME);

var db = mongoose.createConnection(url);

db.on('open', function () {});

var files = fs.readdirSync(__dirname);

files.forEach(function(file) {
  var fileName = path.basename(file, '.js');
  if (fileName != 'index') {
    exports[fileName] = require('./' + fileName).setup(mongoose, db);
  }
});

@@ -174,30 +174,16 @@
 ess.env.
-APINIC_MOVIES_
 DB_USERN
@@ -197,38 +197,24 @@
 process.env.
-APINIC_MOVIES_
 DB_PASSWORD,
@@ -228,30 +228,16 @@
 ess.env.
-APINIC_MOVIES_
 DB_HOST,
@@ -251,30 +251,16 @@
 ess.env.
-APINIC_MOVIES_
 DB_PORT,
@@ -278,22 +278,8 @@
 env.
-APINIC_MOVIES_
 DB_N

fix mongodb connection