This commit is contained in:
syuilo
2018-04-25 19:53:16 +09:00
parent 3d9ac6387e
commit c2e053a208
11 changed files with 363 additions and 79 deletions

View File

@ -0,0 +1,23 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import UserList, { pack } from '../../../../../models/user-list';
/**
* Show a user list
*/
module.exports = async (params, me) => new Promise(async (res, rej) => {
// Get 'listId' parameter
const [listId, listIdErr] = $(params.listId).type(ID).$;
if (listIdErr) return rej('invalid listId param');
// Fetch the list
const userList = await UserList.findOne({
_id: listId,
userId: me._id,
});
if (userList == null) {
return rej('list not found');
}
res(await pack(userList));
});

View File

@ -1,15 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import $ from 'cafy';
import User, { pack } from '../../../../models/user';
/**
* Search a user by username
*
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'query' parameter