Ported sell function. Add unit tests. Create sell route. Add integration tests

This commit is contained in:
Keith Holliday
2016-04-06 08:27:18 -05:00
parent 68ff26e6d6
commit 05b41bb41c
7 changed files with 181 additions and 15 deletions

View File

@@ -828,4 +828,24 @@ api.userReleaseMounts = {
},
};
/*
* @api {post} /user/sell/:type/:key Sells user's items.
* @apiVersion 3.0.0
* @apiName UserSell
* @apiGroup User
*
* @apiSuccess {Object} data `stats items`
*/
api.userSell = {
method: 'POST',
middlewares: [authWithHeaders(), cron],
url: '/user/sell/:type/:key',
async handler (req, res) {
let user = res.locals.user;
let sellResponse = common.ops.sell(user, req);
await user.save();
res.respond(200, sellResponse);
},
};
module.exports = api;