reverseproxy: async'ify

This commit is contained in:
Girish Ramakrishnan
2021-08-17 14:04:29 -07:00
parent 5bcf1bc47b
commit 5dd6f85025
10 changed files with 212 additions and 292 deletions

View File

@@ -267,7 +267,7 @@ function setAutomaticUpdate(req, res, next) {
});
}
function setReverseProxyConfig(req, res, next) {
async function setReverseProxyConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.resource, 'object');
@@ -275,14 +275,13 @@ function setReverseProxyConfig(req, res, next) {
if (req.body.csp !== null && typeof req.body.csp !== 'string') return next(new HttpError(400, 'csp is not a string'));
apps.setReverseProxyConfig(req.resource, req.body, auditSource.fromRequest(req), function (error) {
if (error) return next(BoxError.toHttpError(error));
const [error] = await safe(apps.setReverseProxyConfig(req.resource, req.body, auditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
});
next(new HttpSuccess(200, {}));
}
function setCertificate(req, res, next) {
async function setCertificate(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.resource, 'object');
@@ -295,11 +294,10 @@ function setCertificate(req, res, next) {
if (req.body.cert && !req.body.key) return next(new HttpError(400, 'key must be provided'));
if (!req.body.cert && req.body.key) return next(new HttpError(400, 'cert must be provided'));
apps.setCertificate(req.resource, req.body, auditSource.fromRequest(req), function (error) {
if (error) return next(BoxError.toHttpError(error));
const [error] = await safe(apps.setCertificate(req.resource, req.body, auditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
});
next(new HttpSuccess(200, {}));
}
function setEnvironment(req, res, next) {