Present with related objects

This commit is contained in:
Jori Lallo
2016-05-19 23:53:07 -07:00
parent 99a59ceb94
commit 270f556570
3 changed files with 51 additions and 30 deletions

View File

@@ -23,7 +23,7 @@ router.post('atlases.info', auth(), async (ctx) => {
if (!atlas) throw httpErrors.NotFound();
ctx.body = {
data: presentAtlas(atlas),
data: await presentAtlas(atlas, true),
};
});
@@ -41,11 +41,15 @@ router.post('atlases.list', auth(), pagination(), async (ctx) => {
limit: ctx.state.pagination.limit,
});
// Atlases
let data = [];
await Promise.all(atlases.map(async (atlas) => {
data.push(await presentAtlas(atlas));
}))
ctx.body = {
pagination: ctx.state.pagination,
data: atlases.map((atlas) => {
return presentAtlas(atlas);
})
data: data,
};
});