Skip to content

Commit

Permalink
fix(endpoint:user): refactor validationError for promise use
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcody committed Jun 27, 2015
1 parent d084fab commit c98cb5d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/templates/server/api/user(auth)/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ var passport = require('passport');
var config = require('../../config/environment');
var jwt = require('jsonwebtoken');

var validationError = function(res, err) {
return res.status(422).json(err);
};
function validationError(res, statusCode) {
statusCode = statusCode || 422;
return function(err) {
res.status(statusCode).json(err);
}
}

function handleError(res, statusCode) {
statusCode = statusCode || 500;
return function(err) {
res.send(statusCode, err);
res.status(statusCode).send(err);
};
}

function respondWith(res, statusCode) {
statusCode = statusCode || 200;
return function() {
res.send(statusCode);
res.status(statusCode).end();
};
}

Expand Down

0 comments on commit c98cb5d

Please sign in to comment.