remove success field from json responses

This commit is contained in:
Matteo Pagliazzi
2015-11-23 21:04:21 +01:00
parent 093970b48a
commit 4a941deece
6 changed files with 1 additions and 21 deletions

View File

@@ -5,7 +5,6 @@ describe('notFound Middleware', () => {
let request = requester().get('/api/v3/dummy-url');
return expect(request).to.eventually.be.rejected.and.eql({
success: false,
code: 404,
error: 'NotFound',
message: 'Not found.',

View File

@@ -39,7 +39,6 @@ describe('POST /user/auth/local/register', () => {
password,
confirmPassword: confirmPassword,
})).to.eventually.be.rejected.and.eql({
success: false,
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
@@ -57,7 +56,6 @@ describe('POST /user/auth/local/register', () => {
password,
confirmPassword,
})).to.eventually.be.rejected.and.eql({
success: false,
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
@@ -74,7 +72,6 @@ describe('POST /user/auth/local/register', () => {
password,
confirmPassword: password,
})).to.eventually.be.rejected.and.eql({
success: false,
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
@@ -93,7 +90,6 @@ describe('POST /user/auth/local/register', () => {
password,
confirmPassword: password,
})).to.eventually.be.rejected.and.eql({
success: false,
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
@@ -111,7 +107,6 @@ describe('POST /user/auth/local/register', () => {
email: email,
confirmPassword: confirmPassword,
})).to.eventually.be.rejected.and.eql({
success: false,
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
@@ -143,7 +138,6 @@ describe('POST /user/auth/local/register', () => {
password: password,
confirmPassword: password,
})).to.eventually.be.rejected.and.eql({
success: false,
code: 401,
error: 'NotAuthorized',
message: t('usernameTaken'),
@@ -161,7 +155,6 @@ describe('POST /user/auth/local/register', () => {
password,
confirmPassword: password,
})).to.eventually.be.rejected.and.eql({
success: false,
code: 401,
error: 'NotAuthorized',
message: t('emailTaken'),

View File

@@ -34,7 +34,6 @@ describe('errorHandler', () => {
expect(res.status).to.be.calledWith(500);
expect(res.json).to.be.calledWith({
success: false,
error: 'InternalServerError',
message: 'An unexpected error occurred.',
});
@@ -51,7 +50,6 @@ describe('errorHandler', () => {
expect(res.status).to.be.calledWith(400);
expect(res.json).to.be.calledWith({
success: false,
error: 'Error',
message: 'Error message',
});
@@ -68,7 +66,6 @@ describe('errorHandler', () => {
expect(res.status).to.be.calledWith(500);
expect(res.json).to.be.calledWith({
success: false,
error: 'InternalServerError',
message: 'An unexpected error occurred.',
});
@@ -84,7 +81,6 @@ describe('errorHandler', () => {
expect(res.status).to.be.calledWith(400);
expect(res.json).to.be.calledWith({
success: false,
error: 'BadRequest',
message: 'Bad request.',
});
@@ -101,7 +97,6 @@ describe('errorHandler', () => {
expect(res.status).to.be.calledWith(error.statusCode);
expect(res.json).to.be.calledWith({
success: false,
error: error.name,
message: error.message,
});
@@ -117,7 +112,6 @@ describe('errorHandler', () => {
expect(res.status).to.be.calledWith(400);
expect(res.json).to.be.calledWith({
success: false,
error: 'BadRequest',
message: 'Invalid request parameters.',
errors: error,
@@ -143,7 +137,6 @@ describe('errorHandler', () => {
expect(res.status).to.be.calledWith(400);
expect(res.json).to.be.calledWith({
success: false,
error: 'BadRequest',
message: 'User validation failed.',
errors: [

View File

@@ -31,7 +31,6 @@ describe('response middleware', function() {
expect(res.status).to.be.calledWith(200);
expect(res.json).to.be.calledWith({
field: 1,
success: true,
});
});
@@ -45,7 +44,6 @@ describe('response middleware', function() {
expect(res.status).to.be.calledWith(403);
expect(res.json).to.be.calledWith({
field: 1,
success: false,
});
});
});

View File

@@ -252,7 +252,6 @@ function _requestMaker (user, method, additionalSets) {
if (API_V === 'v3') {
return reject({
success: err.response.body.success,
code: err.status,
error: err.response.body.error,
message: err.response.body.message,

View File

@@ -1,8 +1,6 @@
export default function responseHandler (req, res, next) {
res.respond = function respond (status = 200, data = {}) {
res.status(status);
data.success = status >= 400 ? false : true; // TODO the data object should be cloned to avoid pollution?
res.json(data);
res.status(status).json(data);
};
next();