res.respond: allow for thrid parameter (message), refactor shared ops responses and adapt tests

This commit is contained in:
Matteo Pagliazzi
2016-04-21 00:52:03 +02:00
parent 9e3d8ba4ac
commit 6568fcfd5e
81 changed files with 419 additions and 465 deletions

View File

@@ -1,7 +1,5 @@
import content from '../content/index';
import i18n from '../i18n';
import _ from 'lodash';
import splitWhitespace from '../libs/splitWhitespace';
import {
NotAuthorized,
} from '../libs/errors';
@@ -39,14 +37,12 @@ module.exports = function buyPotion (user, req = {}, analytics) {
});
}
let res = {
data: _.pick(user, splitWhitespace('stats')),
message,
};
if (req.v2 === true) {
return res.data;
return user.stats;
} else {
return res;
return [
user.stats,
message,
];
}
};