[misc] add a new endpoint for changing a docs meta data -- incl. deleted

- Validate the request payload with joi -- includes acceptance tests.
- Reject updates to docs that have been deleted.
This commit is contained in:
Jakob Ackermann
2021-02-15 13:13:48 +00:00
parent 50cc1c1119
commit dd4f4057f4
12 changed files with 593 additions and 27 deletions
@@ -188,6 +188,17 @@ module.exports = HttpController = {
})
},
patchDoc(req, res, next) {
const { project_id, doc_id } = req.params
logger.log({ project_id, doc_id }, 'patching doc')
DocManager.patchDoc(project_id, doc_id, req.body, function (error) {
if (error) {
return next(error)
}
res.sendStatus(204)
})
},
_buildDocView(doc) {
const doc_view = { _id: doc._id != null ? doc._id.toString() : undefined }
for (const attribute of ['lines', 'rev', 'version', 'ranges', 'deleted']) {