     @handleApiError(
       res,
       err,
-      errorMsg: "failed to create user"
+      errorMsg: "failed to create user (name=#{name})"
     )
   )
   .done()

  )

startCompetition = (req, res) ->
  @api.startCompetition(req.body.userId, req.body.name)
  .then((competition) ->
    res.json(201, competition)
    console.log("[HTTP] 201: started competition: #{competition}")
  )
  .fail((err) =>
    @handleApiError(res, err, errorMsg: "failed to start competition")
  )
  .done()

endCompetition = (req, res) ->
  @api.endCompetition(req.params.competitionId)
  .then((competition) ->
    res.json(200, competition)
    console.log "[HTTP] 200: ended competition: #{competition}"
  )
  .fail((err) =>
    @handleApiError(res, err, errorMsg: "failed to end competition")
  )
  .done()

joinCompetition = (req, res) ->
  @api.joinCompetition(req.body.userId, req.params.competitionId)
  .then((competitionMembership) ->
    res.json(201, competitionMembership)
    console.log("[HTTP] 201: joined competition: #{competitionMembership}")
  )
  .fail((err) =>
    @handleApiError(res, err, errorMsg: "failed to join competition")
  )
  .done()


  )

createUser = (req, res) ->
  name = req.body.name

  @api.createUser(name)
  .then((user) ->
    res.json(201, user)
    console.log("[HTTP] 201: created user: #{user}")
