merge taskdb into tasks.js

This commit is contained in:
Girish Ramakrishnan
2021-07-12 23:35:30 -07:00
parent db685d3a56
commit e59d0e878d
18 changed files with 487 additions and 669 deletions
+9 -11
View File
@@ -283,14 +283,13 @@ function prepareDashboardDomain(req, res, next) {
});
}
function renewCerts(req, res, next) {
async function renewCerts(req, res, next) {
if ('domain' in req.body && typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
cloudron.renewCerts({ domain: req.body.domain || null }, auditSource.fromRequest(req), function (error, taskId) {
if (error) return next(BoxError.toHttpError(error));
const [error, taskId] = await safe(cloudron.renewCerts({ domain: req.body.domain || null }, auditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, { taskId }));
});
next(new HttpSuccess(202, { taskId }));
}
function syncExternalLdap(req, res, next) {
@@ -317,16 +316,15 @@ function getLanguages(req, res, next) {
});
}
function syncDnsRecords(req, res, next) {
async function syncDnsRecords(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if ('domain' in req.body && typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
if ('type' in req.body && typeof req.body.type !== 'string') return next(new HttpError(400, 'type must be a string'));
cloudron.syncDnsRecords(req.body, function (error, taskId) {
if (error && error.reason === BoxError.ACCESS_DENIED) return next(new HttpSuccess(200, { error: { reason: error.reason, message: error.message }}));
if (error) return next(BoxError.toHttpError(error));
const [error, taskId] = await safe(cloudron.syncDnsRecords(req.body));
if (error && error.reason === BoxError.ACCESS_DENIED) return next(new HttpSuccess(200, { error: { reason: error.reason, message: error.message }}));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(201, { taskId }));
});
next(new HttpSuccess(201, { taskId }));
}