text: 'use strict';
  var chalk = require('chalk');
  
  // Requires in ./db/index.js -- which returns a promise that represents
  // mongoose establishing a connection to a MongoDB database.
  var startDb = require('./db');
  var seed = require('./seed');
  
  // Create a node server instance! cOoL!
  var server = require('http').createServer();
  
  var createApplication = function () {
      var app = require('./app.js');
      server.on('request', app); // Attach the Express application.
  };
  
  var startServer = function () {
  	var PORT = process.env.VCAP_APP_PORT || 3000;
  
      server.listen(PORT, function () {
          console.log(chalk.blue('Server started on port', chalk.magenta(PORT)));
      });
  
  };
  
  startDb.then(createApplication).then(startServer).catch(function (err) {
      console.error(chalk.red(err.stack));
      process.kill(1);
  });