   daisy queue
 
 
-
 validateRequest = (req) ->
 
   token = null
   { username, email, firstName, lastName } = req.body
 
-  errors =
-    invalidRequest      :
-      statusCode        : 400
-      message           : 'invalid request'
-    unauthorizedRequest :
-      statusCode        : 401
-      message           : 'unauthorized request'
-
   unless email
-    return { error : errors.invalidRequest }
+    return { error : apiErrors.invalidInput }
 
   unless token = checkAuthorizationBearerHeader req
-    return { error : errors.unauthorizedRequest }
+    return { error : apiErrors.unauthorizedRequest }
 
   return { error : null, token, username, email, firstName, lastName }
 

    ->
      # checking if token is valid
      JApiToken.one { code : token }, (err, apiToken_) ->

        if err
          return callback { statusCode : 500, message : 'an error occurred' }

        unless apiToken_
          return callback { statusCode : 400, message : 'invalid token!' }

        apiToken = apiToken_
        queue.next()


  # validating req params
  { error, token, username, email, firstName, lastName } = validateRequest req
  return sendApiError res, error  if error

  client   = null
  apiToken = null
