Added API to update document tree

This commit is contained in:
Jori Lallo
2016-06-25 22:27:44 -07:00
parent 7ea6eb5d28
commit a0649e6fd3
11 changed files with 182 additions and 30 deletions

View File

@@ -56,4 +56,26 @@ router.post('atlases.list', auth(), pagination(), async (ctx) => {
};
});
router.post('atlases.updateNavigationTree', auth(), async (ctx) => {
let { id, tree } = ctx.request.body;
ctx.assertPresent(id, 'id is required');
const user = ctx.state.user;
const atlas = await Atlas.findOne({
where: {
id: id,
teamId: user.teamId,
},
});
if (!atlas) throw httpErrors.NotFound();
const newTree = await atlas.updateNavigationTree(tree);
ctx.body = {
data: await presentAtlas(atlas, true),
tree: newTree,
};
});
export default router;