Skip to content

Commit c98cb5d

Browse files
committed
fix(endpoint:user): refactor validationError for promise use
1 parent d084fab commit c98cb5d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/templates/server/api/user(auth)/user.controller.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ var passport = require('passport');
88
var config = require('../../config/environment');
99
var jwt = require('jsonwebtoken');
1010

11-
var validationError = function(res, err) {
12-
return res.status(422).json(err);
13-
};
11+
function validationError(res, statusCode) {
12+
statusCode = statusCode || 422;
13+
return function(err) {
14+
res.status(statusCode).json(err);
15+
}
16+
}
1417

1518
function handleError(res, statusCode) {
1619
statusCode = statusCode || 500;
1720
return function(err) {
18-
res.send(statusCode, err);
21+
res.status(statusCode).send(err);
1922
};
2023
}
2124

2225
function respondWith(res, statusCode) {
2326
statusCode = statusCode || 200;
2427
return function() {
25-
res.send(statusCode);
28+
res.status(statusCode).end();
2629
};
2730
}
2831

0 commit comments

Comments
 (0)