From f11becfcc8463f772e24450666468eee4ba8a8dd Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 10 Apr 2024 18:47:21 +0200 Subject: [PATCH] async'ify crazy this has gone unnoticed for so long! --- src/routes/apps.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/routes/apps.js b/src/routes/apps.js index 2d8b4686f..bf760a160 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -294,17 +294,16 @@ async function setMemoryLimit(req, res, next) { next(new HttpSuccess(202, { taskId: result.taskId })); } -function setCpuQuota(req, res, next) { +async function setCpuQuota(req, res, next) { assert.strictEqual(typeof req.body, 'object'); assert.strictEqual(typeof req.app, 'object'); if (typeof req.body.cpuQuota !== 'number') return next(new HttpError(400, 'cpuQuota is not a number')); - apps.setCpuQuota(req.app, req.body.cpuQuota, AuditSource.fromRequest(req), function (error, result) { - if (error) return next(BoxError.toHttpError(error)); + const [error, result] = await safe(apps.setCpuQuota(req.app, req.body.cpuQuota, AuditSource.fromRequest(req))); + if (error) return next(BoxError.toHttpError(error)); - next(new HttpSuccess(202, { taskId: result.taskId })); - }); + next(new HttpSuccess(202, { taskId: result.taskId })); } async function setAutomaticBackup(req, res, next) {