Sharkey/src/server/api/endpoints/users/lists/list.ts

15 lines
388 B
TypeScript
Raw Normal View History

2018-04-24 23:34:50 +02:00
import UserList, { pack } from '../../../../../models/user-list';
2018-06-18 02:54:53 +02:00
import { ILocalUser } from '../../../../../models/user';
2018-04-24 23:34:50 +02:00
/**
* Add a user to a user list
*/
2018-07-05 19:58:29 +02:00
export default async (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
2018-04-24 23:34:50 +02:00
// Fetch lists
const userLists = await UserList.find({
userId: me._id,
});
res(await Promise.all(userLists.map(x => pack(x))));
});