Added delete endpoint

This commit is contained in:
Tom Moor
2018-05-13 00:28:31 -07:00
parent 9000aa3aac
commit 22bc5a7373
7 changed files with 60 additions and 4 deletions

View File

@@ -61,4 +61,18 @@ router.post('shares.create', auth(), async ctx => {
};
});
router.post('shares.delete', auth(), async ctx => {
const { id } = ctx.body;
ctx.assertPresent(id, 'id is required');
const share = await Share.findById(id);
authorize(ctx.state.user, 'delete', share);
await share.destroy();
ctx.body = {
success: true,
};
});
export default router;