Fix setup and restore to have a task style API

This commit is contained in:
Girish Ramakrishnan
2018-12-15 15:27:16 -08:00
parent 1fd6c363ba
commit a961407379
10 changed files with 152 additions and 100 deletions

View File

@@ -11,9 +11,8 @@ exports = module.exports = {
checkForUpdates: checkForUpdates,
getLogs: getLogs,
getLogStream: getLogStream,
getStatus: getStatus,
setDashboardDomain: setDashboardDomain,
setDashboardDns: setDashboardDns,
prepareDashboardDomain: prepareDashboardDomain,
renewCerts: renewCerts
};
@@ -187,10 +186,10 @@ function setDashboardDomain(req, res, next) {
});
}
function setDashboardDns(req, res, next) {
function prepareDashboardDomain(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) {
cloudron.prepareDashboardDomain(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));
@@ -198,14 +197,6 @@ function setDashboardDns(req, res, next) {
});
}
function getStatus(req, res, next) {
cloudron.getStatus(function (error, status) {
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, status));
});
}
function renewCerts(req, res, next) {
cloudron.renewCerts({ domain: req.body.domain || null }, auditSource(req), function (error, taskId) {
if (error && error.reason === CloudronError.NOT_FOUND) return next(new HttpError(404, error.message));