 MongoClient = require('mongodb').MongoClient
 requireFu = require('require-fu')
 
-mongoUrl = "mongodb://127.0.0.1:27017/galegis-api-dev"
-
+# Set up the Job queue.
 jobs = kue.createQueue()
 jobs.on 'job complete', (id) ->
   kue.Job.get id, (err, job) ->

app.use(require('stylus').middleware(__dirname + '/public'))
app.use(express.static(path.join(__dirname, 'public')))

# development only
if 'development' == app.get('env')
  app.use(express.logger('dev'))
  app.use(express.errorHandler())
  app.use('/kue', kue.app)

# production only
if 'production' == app.get('env')
  mongoUrl = "mongodb://127.0.0.1:27017/galegis-api"

  app.use(express.logger('default'))

  kueUser = process.env.KUEUSER || "kue"

    poolSize: 10
    auto_reconnect: true

MongoClient.connect app.get('mongo url'), mongoOptions, (err, db) ->
  # Load up routes
  requireFu(__dirname + '/routes')(app, jobs, db)

