merge appdb.js into apps.js

This commit is contained in:
Girish Ramakrishnan
2021-08-20 09:19:44 -07:00
parent b6f2d6d620
commit 77f5cb183b
39 changed files with 1599 additions and 2495 deletions

View File

@@ -265,34 +265,27 @@ function getLogs(unit, options, callback) {
return callback(null, transformStream);
}
function prepareDashboardDomain(domain, auditSource, callback) {
async function prepareDashboardDomain(domain, auditSource) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
debug(`prepareDashboardDomain: ${domain}`);
if (settings.isDemo()) return callback(new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode'));
if (settings.isDemo()) throw new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode');
domainsGet(domain, function (error, domainObject) {
if (error) return callback(error);
const domainObject = domains.get(domain);
const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject);
const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject);
apps.getAll(async function (error, result) {
if (error) return callback(error);
const result = apps.list();
const conflict = result.filter(app => app.fqdn === fqdn);
if (conflict.length) throw new BoxError(BoxError.BAD_STATE, 'Dashboard location conflicts with an existing app');
const conflict = result.filter(app => app.fqdn === fqdn);
if (conflict.length) return callback(new BoxError(BoxError.BAD_STATE, 'Dashboard location conflicts with an existing app'));
const taskId = await tasks.add(tasks.TASK_SETUP_DNS_AND_CERT, [ constants.DASHBOARD_LOCATION, domain, auditSource ]);
const [taskError, taskId] = await safe(tasks.add(tasks.TASK_SETUP_DNS_AND_CERT, [ constants.DASHBOARD_LOCATION, domain, auditSource ]));
if (taskError) return callback(taskError);
tasks.startTask(taskId, {}, NOOP_CALLBACK);
tasks.startTask(taskId, {}, NOOP_CALLBACK);
callback(null, taskId);
});
});
return taskId;
}
// call this only pre activation since it won't start mail server