make startBackupTask async

This commit is contained in:
Girish Ramakrishnan
2021-09-10 12:10:10 -07:00
parent 242fad137c
commit ae13fe60a7
4 changed files with 53 additions and 69 deletions
+4 -5
View File
@@ -26,12 +26,11 @@ async function list(req, res, next) {
next(new HttpSuccess(200, { backups: result }));
}
function startBackup(req, res, next) {
backups.startBackupTask(auditSource.fromRequest(req), function (error, taskId) {
if (error) return next(BoxError.toHttpError(error));
async function startBackup(req, res, next) {
const [error, taskId] = await safe(backups.startBackupTask(auditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, { taskId }));
});
next(new HttpSuccess(202, { taskId }));
}
async function cleanup(req, res, next) {