appstore and support: async'ify

This commit is contained in:
Girish Ramakrishnan
2021-08-18 15:54:53 -07:00
parent 200018a022
commit 03e22170da
16 changed files with 458 additions and 633 deletions
+8 -10
View File
@@ -55,7 +55,7 @@ function getCloudronName(req, res, next) {
});
}
function setAppstoreListingConfig(req, res, next) {
async function setAppstoreListingConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
const listingConfig = _.pick(req.body, 'whitelist', 'blacklist');
@@ -73,19 +73,17 @@ function setAppstoreListingConfig(req, res, next) {
if (!listingConfig.blacklist.every(id => typeof id === 'string')) return next(new HttpError(400, 'blacklist must be array of strings'));
}
settings.setAppstoreListingConfig(listingConfig, function (error) {
if (error) return next(BoxError.toHttpError(error));
const [error] = await safe(settings.setAppstoreListingConfig(listingConfig));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, {}));
});
next(new HttpSuccess(202, {}));
}
function getAppstoreListingConfig(req, res, next) {
settings.getAppstoreListingConfig(function (error, listingConfig) {
if (error) return next(BoxError.toHttpError(error));
async function getAppstoreListingConfig(req, res, next) {
const [error, listingConfig] = await safe(settings.getAppstoreListingConfig());
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, listingConfig));
});
next(new HttpSuccess(200, listingConfig));
}
async function setCloudronAvatar(req, res, next) {