Add API to set and transfer ownership

This commit is contained in:
Girish Ramakrishnan
2018-06-28 16:48:04 -07:00
parent ff5bd42bef
commit 9978dff627
6 changed files with 111 additions and 3 deletions

View File

@@ -21,6 +21,8 @@ exports = module.exports = {
cloneApp: cloneApp,
setOwner: setOwner,
uploadFile: uploadFile,
downloadFile: downloadFile
};
@@ -554,3 +556,17 @@ function downloadFile(req, res, next) {
stream.pipe(res);
});
}
function setOwner(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.ownerId !== 'string') return next(new HttpError(400, 'ownerId must be a string'));
apps.setOwner(req.params.id, req.body.ownerId, function (error) {
if (error && error.reason === AppsError.NOT_FOUND) return next(new HttpError(404, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, { }));
});
}