 db.open (err,db) ->
   if err
     console.error "Can't connect!"
+    return
   db.authenticate config.db.username, config.db.password, () ->
     if err
       console.error "Can't authenticate!"


  passport.deserializeUser (user, done) ->
    mongo.query 'user', { _id: ID(user) }
      .then (users) -> 
        done(null, users[0]);



        console.log err.stack
        setCORS res
        res.status(err.status || 500).send({ message: err.err || err.errmsg })

      .done()

  app.use /^((?!\/auth|\/user).)*$/, (req, res, next) ->
