API v4 (WIP) (#10453)

API v4
This commit is contained in:
Matteo Pagliazzi
2018-06-18 14:40:25 +02:00
committed by GitHub
parent 97a069642d
commit 8be9964483
158 changed files with 631 additions and 348 deletions

View File

@@ -0,0 +1 @@
See https://github.com/HabitRPG/habitica/pull/10453

View File

@@ -0,0 +1,29 @@
import { authWithHeaders } from '../../middlewares/auth';
import { toArray, orderBy } from 'lodash';
let api = {};
/* NOTE most inbox routes are either in the user or members controller */
/**
* @api {get} /api/v3/inbox/messages Get inbox messages for a user
* @apiPrivate
* @apiName GetInboxMessages
* @apiGroup Inbox
* @apiDescription Get inbox messages for a user
*
* @apiSuccess {Array} data An array of inbox messages
*/
api.getInboxMessages = {
method: 'GET',
url: '/inbox/messages',
middlewares: [authWithHeaders()],
async handler (req, res) {
const messagesObj = res.locals.user.inbox.messages;
const messagesArray = orderBy(toArray(messagesObj), ['timestamp'], ['desc']);
res.respond(200, messagesArray);
},
};
module.exports = api;