Split dashboard dns setup and db operations

The dns setup is now a task that we can wait on. Once that task
is done, we can do db operations to switch the domain in a separate
route
This commit is contained in:
Girish Ramakrishnan
2018-12-14 09:57:28 -08:00
parent 357e44284d
commit bdf9671280
8 changed files with 53 additions and 70 deletions

View File

@@ -13,6 +13,7 @@ exports = module.exports = {
getLogStream: getLogStream,
getStatus: getStatus,
setDashboardDomain: setDashboardDomain,
setDashboardDns: setDashboardDns,
renewCerts: renewCerts
};
@@ -186,6 +187,17 @@ function setDashboardDomain(req, res, next) {
});
}
function setDashboardDns(req, res, next) {
if (!req.body.domain || typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
cloudron.setDashboardDns(req.body.domain, auditSource(req), function (error, taskId) {
if (error && error.reason === CloudronError.BAD_FIELD) return next(new HttpError(404, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(202, { taskId }));
});
}
function getStatus(req, res, next) {
cloudron.getStatus(function (error, status) {
if (error) return next(new HttpError(500, error));