migrate to "export default"

also, set no-use-before-define in linter
This commit is contained in:
Girish Ramakrishnan
2026-02-14 15:43:24 +01:00
parent ddb46646fa
commit 36aa641cb9
231 changed files with 2846 additions and 2728 deletions
+10 -9
View File
@@ -4,18 +4,11 @@ import BoxError from '../boxerror.js';
import debugModule from 'debug';
import { HttpError } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import * as tokens from '../tokens.js';
import * as users from '../users.js';
import tokens from '../tokens.js';
import users from '../users.js';
const debug = debugModule('box:routes/accesscontrol');
export {
passwordAuth,
tokenAuth,
authorize,
authorizeOperator,
};
async function passwordAuth(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
@@ -102,3 +95,11 @@ async function authorizeOperator(req, res, next) {
return next(new HttpError(403, 'user is not an operator'));
}
export default {
passwordAuth,
tokenAuth,
authorize,
authorizeOperator,
};
+12 -11
View File
@@ -1,20 +1,10 @@
import assert from 'node:assert';
import * as applinks from '../applinks.js';
import applinks from '../applinks.js';
import BoxError from '../boxerror.js';
import safe from 'safetydance';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
export {
listByUser,
add,
get,
update,
del,
getIcon,
load
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -96,3 +86,14 @@ async function getIcon(req, res) {
res.send(req.resources.applink.icon);
}
export default {
listByUser,
add,
get,
update,
del,
getIcon,
load
};
+8 -7
View File
@@ -1,16 +1,10 @@
import * as appPasswords from '../apppasswords.js';
import appPasswords from '../apppasswords.js';
import assert from 'node:assert';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
list,
get,
del,
add
};
async function get(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
@@ -56,3 +50,10 @@ async function del(req, res, next) {
next(new HttpSuccess(204, {}));
}
export default {
list,
get,
del,
add
};
+78 -77
View File
@@ -1,93 +1,22 @@
import apps from '../apps.js';
import * as appstore from '../appstore.js';
import appstore from '../appstore.js';
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import * as backupSites from '../backupsites.js';
import backupSites from '../backupsites.js';
import BoxError from '../boxerror.js';
import * as community from '../community.js';
import community from '../community.js';
import constants from '../constants.js';
import debugModule from 'debug';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as metrics from '../metrics.js';
import metrics from '../metrics.js';
import safe from 'safetydance';
import * as updater from '../updater.js';
import * as users from '../users.js';
import updater from '../updater.js';
import users from '../users.js';
import WebSocket from 'ws';
const debug = debugModule('box:routes/apps');
export {
getApp,
listByUser,
getAppIcon,
install,
uninstall,
archive,
restore,
importApp,
exportApp,
backup,
update,
getTask,
getLogs,
getLogStream,
listEventlog,
listBackups,
listBackupSites,
repair,
setAccessRestriction,
setOperators,
setCrontab,
setLabel,
setTags,
setNotes,
setIcon,
setTurn,
setRedis,
setMemoryLimit,
setCpuQuota,
setAutomaticBackup,
setAutomaticUpdate,
setReverseProxyConfig,
setCertificate,
setDebugMode,
setEnvironment,
setMailbox,
setInbox,
setLocation,
setStorage,
setMounts,
setDevices,
setUpstreamUri,
setChecklistItem,
stop,
start,
restart,
createExec,
startExec,
startExecWebSocket,
getExec,
checkUpdate,
clone,
downloadFile,
uploadFile,
updateBackup,
downloadBackup,
getMetrics,
getMetricStream,
load
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -1140,3 +1069,75 @@ async function getMetricStream(req, res, next) {
metricStream.on('end', res.end.bind(res));
metricStream.on('error', res.end.bind(res, null));
}
export default {
getApp,
listByUser,
getAppIcon,
install,
uninstall,
archive,
restore,
importApp,
exportApp,
backup,
update,
getTask,
getLogs,
getLogStream,
listEventlog,
listBackups,
listBackupSites,
repair,
setAccessRestriction,
setOperators,
setCrontab,
setLabel,
setTags,
setNotes,
setIcon,
setTurn,
setRedis,
setMemoryLimit,
setCpuQuota,
setAutomaticBackup,
setAutomaticUpdate,
setReverseProxyConfig,
setCertificate,
setDebugMode,
setEnvironment,
setMailbox,
setInbox,
setLocation,
setStorage,
setMounts,
setDevices,
setUpstreamUri,
setChecklistItem,
stop,
start,
restart,
createExec,
startExec,
startExecWebSocket,
getExec,
checkUpdate,
clone,
downloadFile,
uploadFile,
updateBackup,
downloadBackup,
getMetrics,
getMetricStream,
load
};
+12 -11
View File
@@ -1,19 +1,11 @@
import * as appstore from '../appstore.js';
import appstore from '../appstore.js';
import assert from 'node:assert';
import BoxError from '../boxerror.js';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import * as users from '../users.js';
import * as _ from '../underscore.js';
import users from '../users.js';
import _ from '../underscore.js';
export {
getApps,
getApp,
getAppVersion,
unlinkAccount,
getSubscription
};
async function getApps(req, res, next) {
const [error, apps] = await safe(appstore.getApps());
@@ -58,3 +50,12 @@ async function getSubscription(req, res, next) {
if (users.compareRoles(req.user.role, users.ROLE_OWNER) < 0) next(new HttpSuccess(200, _.pick(result, ['plan', 'status'])));
else next(new HttpSuccess(200, result)); // { email, cloudronId, cloudronCreatedAt, plan, current_period_end, canceled_at, cancel_at, status, features }
}
export default {
getApps,
getApp,
getAppVersion,
unlinkAccount,
getSubscription
};
+11 -10
View File
@@ -1,21 +1,12 @@
import apps from '../apps.js';
import assert from 'node:assert';
import * as archives from '../archives.js';
import archives from '../archives.js';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
load,
list,
get,
getIcon,
del,
unarchive
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -94,3 +85,13 @@ async function unarchive(req, res, next) {
next(new HttpSuccess(202, { id: result.id, taskId: result.taskId }));
}
export default {
load,
list,
get,
getIcon,
del,
unarchive
};
+10 -9
View File
@@ -9,18 +9,11 @@ import { HttpSuccess } from '@cloudron/connect-lastmile';
import oidcClients from '../oidcclients.js';
import safe from 'safetydance';
import speakeasy from 'speakeasy';
import * as tokens from '../tokens.js';
import * as users from '../users.js';
import tokens from '../tokens.js';
import users from '../users.js';
const debug = debugModule('box:routes/cloudron');
export {
login,
logout,
passwordResetRequest,
passwordReset,
setupAccount,
};
async function login(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
@@ -113,3 +106,11 @@ async function setupAccount(req, res, next) {
next(new HttpSuccess(201, { accessToken }));
}
export default {
login,
logout,
passwordResetRequest,
passwordReset,
setupAccount,
};
+11 -10
View File
@@ -6,16 +6,6 @@ import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
load,
list,
get,
update,
startIntegrityCheck,
stopIntegrityCheck
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -78,3 +68,14 @@ async function stopIntegrityCheck(req, res, next) {
next(new HttpSuccess(204, {}));
}
export default {
load,
list,
get,
update,
startIntegrityCheck,
stopIntegrityCheck
};
+26 -25
View File
@@ -1,36 +1,12 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import backups from '../backups.js';
import * as backupSites from '../backupsites.js';
import backupSites from '../backupsites.js';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
load,
list,
get,
add,
del,
// separate update routes to skip (slow) storage validation
setConfig,
setLimits,
setSchedule,
setRetention,
setEnabledForUpdates,
setName,
setContents,
setEncryption,
listBackups,
createBackup,
cleanup,
remount,
getStatus,
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -268,3 +244,28 @@ async function listBackups(req, res, next) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, { backups: results }));
}
export default {
load,
list,
get,
add,
del,
// separate update routes to skip (slow) storage validation
setConfig,
setLimits,
setSchedule,
setRetention,
setEnabledForUpdates,
setName,
setContents,
setEncryption,
listBackups,
createBackup,
cleanup,
remount,
getStatus,
};
+13 -12
View File
@@ -1,22 +1,11 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as branding from '../branding.js';
import branding from '../branding.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
getCloudronName,
setCloudronName,
getCloudronAvatar,
setCloudronAvatar,
getCloudronBackground,
setCloudronBackground,
unsetCloudronBackground,
getFooter,
setFooter,
};
async function getFooter(req, res, next) {
const [error, footer] = await safe(branding.getFooter());
@@ -112,3 +101,15 @@ async function getCloudronBackground(req, res, next) {
res.set('Content-Type', 'image/webp');
res.status(200).send(background);
}
export default {
getCloudronName,
setCloudronName,
getCloudronAvatar,
setCloudronAvatar,
getCloudronBackground,
setCloudronBackground,
unsetCloudronBackground,
getFooter,
setFooter,
};
+13 -12
View File
@@ -1,21 +1,11 @@
import assert from 'node:assert';
import BoxError from '../boxerror.js';
import * as cloudron from '../cloudron.js';
import cloudron from '../cloudron.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import * as translations from '../translations.js';
import translations from '../translations.js';
export {
getStatus,
listLanguages,
getLanguage,
setLanguage,
getTimeZone,
setTimeZone
};
async function getStatus(req, res, next) {
const [error, status] = await safe(cloudron.getStatus());
@@ -66,3 +56,14 @@ async function setLanguage(req, res, next) {
next(new HttpSuccess(200, {}));
}
export default {
getStatus,
listLanguages,
getLanguage,
setLanguage,
getTimeZone,
setTimeZone
};
+5 -4
View File
@@ -1,12 +1,9 @@
import assert from 'node:assert';
import BoxError from '../boxerror.js';
import * as community from '../community.js';
import community from '../community.js';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
getAppVersion
};
async function getAppVersion(req, res, next) {
assert.strictEqual(typeof req.query.url, 'string');
@@ -17,3 +14,7 @@ async function getAppVersion(req, res, next) {
next(new HttpSuccess(200, result)); // { manifest, publishState, creationDate, ts }
}
export default {
getAppVersion
};
+20 -19
View File
@@ -1,8 +1,8 @@
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as branding from '../branding.js';
import branding from '../branding.js';
import constants from '../constants.js';
import * as dashboard from '../dashboard.js';
import dashboard from '../dashboard.js';
import ejs from 'ejs';
import fs from 'node:fs';
import { HttpError } from '@cloudron/connect-lastmile';
@@ -10,24 +10,8 @@ import { HttpSuccess } from '@cloudron/connect-lastmile';
import path from 'node:path';
import paths from '../paths.js';
import safe from 'safetydance';
import * as settings from '../settings.js';
import settings from '../settings.js';
export {
getConfig,
startPrepareLocation,
changeLocation,
renderIndex,
renderFilemanager,
renderLogs,
renderTerminal,
renderPasswordreset,
renderSetupaccount,
renderSetup,
renderRestore,
renderActivation,
};
async function getConfig(req, res, next) {
const [error, cloudronConfig] = await safe(dashboard.getConfig());
@@ -115,3 +99,20 @@ async function renderRestore(req, res) {
async function renderActivation(req, res) {
res.send(ejs.render(TEMPLATE_ACTIVATION, {}));
}
export default {
getConfig,
startPrepareLocation,
changeLocation,
renderIndex,
renderFilemanager,
renderLogs,
renderTerminal,
renderPasswordreset,
renderSetupaccount,
renderSetup,
renderRestore,
renderActivation,
};
+6 -5
View File
@@ -1,15 +1,11 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as directoryServer from '../directoryserver.js';
import directoryServer from '../directoryserver.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
getConfig,
setConfig,
};
async function getConfig(req, res, next) {
const [error, config] = await safe(directoryServer.getConfig());
@@ -32,3 +28,8 @@ async function setConfig(req, res, next) {
next(new HttpSuccess(200, {}));
}
export default {
getConfig,
setConfig,
};
+10 -9
View File
@@ -1,19 +1,11 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as dockerRegistries from '../dockerregistries.js';
import dockerRegistries from '../dockerregistries.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
list,
add,
get,
del,
update,
load
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -82,3 +74,12 @@ async function del(req, res, next) {
next(new HttpSuccess(204));
}
export default {
list,
add,
get,
del,
update,
load
};
+14 -13
View File
@@ -1,23 +1,12 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as dns from '../dns.js';
import * as domains from '../domains.js';
import dns from '../dns.js';
import domains from '../domains.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
add,
get,
list,
setConfig,
setWellKnown,
del,
checkDnsRecords,
syncDnsRecords,
};
async function add(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
@@ -171,3 +160,15 @@ async function syncDnsRecords(req, res, next) {
next(new HttpSuccess(201, { taskId }));
}
export default {
add,
get,
list,
setConfig,
setWellKnown,
del,
checkDnsRecords,
syncDnsRecords,
};
+5 -4
View File
@@ -4,10 +4,6 @@ import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
get,
list
};
async function get(req, res, next) {
const [error, event] = await safe(eventlog.get(req.params.eventId));
@@ -36,3 +32,8 @@ async function list(req, res, next) {
next(new HttpSuccess(200, { eventlogs }));
}
export default {
get,
list
};
+7 -6
View File
@@ -1,16 +1,11 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as externalLdap from '../externalldap.js';
import externalLdap from '../externalldap.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
getConfig,
setConfig,
sync
};
async function sync(req, res, next) {
const [error, taskId] = await safe(externalLdap.startSyncer());
@@ -45,3 +40,9 @@ async function setConfig(req, res, next) {
next(new HttpSuccess(200, {}));
}
export default {
getConfig,
setConfig,
sync
};
+4 -3
View File
@@ -5,9 +5,6 @@ import { HttpError } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import services from '../services.js';
export {
proxy,
};
function proxy(kind) {
assert(kind === 'mail' || kind === 'volume' || kind === 'app');
@@ -53,3 +50,7 @@ function proxy(kind) {
}
};
}
export default {
proxy,
};
+13 -12
View File
@@ -1,22 +1,11 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as groups from '../groups.js';
import groups from '../groups.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
load,
get,
list,
add,
setName,
del,
setMembers,
setAllowedApps
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.groupId, 'string');
@@ -99,3 +88,15 @@ async function del(req, res, next) {
next(new HttpSuccess(204));
}
export default {
load,
get,
list,
add,
setName,
del,
setMembers,
setAllowedApps
};
+38 -38
View File
@@ -1,42 +1,42 @@
import * as accesscontrol from './accesscontrol.js';
import * as appPasswords from './apppasswords.js';
import * as apps from './apps.js';
import * as applinks from './applinks.js';
import * as appstore from './appstore.js';
import * as archives from './archives.js';
import * as auth from './auth.js';
import * as backups from './backups.js';
import * as backupSites from './backupsites.js';
import * as branding from './branding.js';
import * as cloudron from './cloudron.js';
import * as community from './community.js';
import * as dashboard from './dashboard.js';
import * as directoryServer from './directoryserver.js';
import * as dockerRegistries from './dockerregistries.js';
import * as domains from './domains.js';
import * as eventlog from './eventlog.js';
import * as externalLdap from './externalldap.js';
import * as filemanager from './filemanager.js';
import * as groups from './groups.js';
import * as mail from './mail.js';
import * as mailserver from './mailserver.js';
import * as network from './network.js';
import * as notifications from './notifications.js';
import * as oidcClients from './oidcclients.js';
import * as profile from './profile.js';
import * as provision from './provision.js';
import * as reverseProxy from './reverseproxy.js';
import * as services from './services.js';
import * as system from './system.js';
import * as tasks from './tasks.js';
import * as tokens from './tokens.js';
import * as updater from './updater.js';
import * as userDirectory from './user-directory.js';
import * as users from './users.js';
import * as volumes from './volumes.js';
import * as wellknown from './wellknown.js';
import accesscontrol from './accesscontrol.js';
import appPasswords from './apppasswords.js';
import apps from './apps.js';
import applinks from './applinks.js';
import appstore from './appstore.js';
import archives from './archives.js';
import auth from './auth.js';
import backups from './backups.js';
import backupSites from './backupsites.js';
import branding from './branding.js';
import cloudron from './cloudron.js';
import community from './community.js';
import dashboard from './dashboard.js';
import directoryServer from './directoryserver.js';
import dockerRegistries from './dockerregistries.js';
import domains from './domains.js';
import eventlog from './eventlog.js';
import externalLdap from './externalldap.js';
import filemanager from './filemanager.js';
import groups from './groups.js';
import mail from './mail.js';
import mailserver from './mailserver.js';
import network from './network.js';
import notifications from './notifications.js';
import oidcClients from './oidcclients.js';
import profile from './profile.js';
import provision from './provision.js';
import reverseProxy from './reverseproxy.js';
import services from './services.js';
import system from './system.js';
import tasks from './tasks.js';
import tokens from './tokens.js';
import updater from './updater.js';
import userDirectory from './user-directory.js';
import users from './users.js';
import volumes from './volumes.js';
import wellknown from './wellknown.js';
export {
export default {
accesscontrol,
appPasswords,
apps,
+33 -32
View File
@@ -1,42 +1,11 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as mail from '../mail.js';
import mail from '../mail.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
getDomain,
listDomains,
getStatus,
setMailFromValidation,
setCatchAllAddress,
setMailRelay,
setMailEnabled,
setBanner,
sendTestMail,
listMailboxesByDomain,
getMailbox,
addMailbox,
updateMailbox,
delMailbox,
getAliases,
setAliases,
listMailingListsByDomain,
getMailingList,
addMailingList,
updateMailingList,
delMailingList,
getStats
};
async function getDomain(req, res, next) {
assert.strictEqual(typeof req.params.domain, 'string');
@@ -344,3 +313,35 @@ async function delMailingList(req, res, next) {
next(new HttpSuccess(204));
}
export default {
getDomain,
listDomains,
getStatus,
setMailFromValidation,
setCatchAllAddress,
setMailRelay,
setMailEnabled,
setBanner,
sendTestMail,
listMailboxesByDomain,
getMailbox,
addMailbox,
updateMailbox,
delMailbox,
getAliases,
setAliases,
listMailingListsByDomain,
getMailingList,
addMailingList,
updateMailingList,
delMailingList,
getStats
};
+10 -9
View File
@@ -5,20 +5,12 @@ import debugModule from 'debug';
import http from 'node:http';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as mailServer from '../mailserver.js';
import mailServer from '../mailserver.js';
import safe from 'safetydance';
import services from '../services.js';
const debug = debugModule('box:routes/mailserver');
export {
proxy,
proxyAndRestart,
queueProxy,
setLocation,
getLocation
};
async function proxyToMailContainer(port, pathname, req, res, next) {
req.clearTimeout();
@@ -95,3 +87,12 @@ async function setLocation(req, res, next) {
next(new HttpSuccess(202, { taskId }));
}
export default {
proxy,
proxyAndRestart,
queueProxy,
setLocation,
getLocation
};
+18 -17
View File
@@ -3,25 +3,9 @@ import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as network from '../network.js';
import network from '../network.js';
import safe from 'safetydance';
export {
getBlocklist,
setBlocklist,
getDynamicDns,
setDynamicDns,
getIPv4Config,
setIPv4Config,
getIPv6Config,
setIPv6Config,
getIPv4,
getIPv6,
};
async function getBlocklist(req, res, next) {
const [error, blocklist] = await safe(network.getBlocklist());
@@ -111,3 +95,20 @@ async function getIPv6(req, res, next) {
next(new HttpSuccess(200, { ip }));
}
export default {
getBlocklist,
setBlocklist,
getDynamicDns,
setDynamicDns,
getIPv4Config,
setIPv4Config,
getIPv6Config,
setIPv6Config,
getIPv4,
getIPv6,
};
+8 -7
View File
@@ -2,15 +2,9 @@ import assert from 'node:assert';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as notifications from '../notifications.js';
import notifications from '../notifications.js';
import safe from 'safetydance';
export {
load,
get,
list,
update
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.notificationId, 'string');
@@ -57,3 +51,10 @@ async function update(req, res, next) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(204, {}));
}
export default {
load,
get,
list,
update
};
+9 -8
View File
@@ -5,14 +5,6 @@ import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
load,
add,
list,
get,
update,
del,
};
async function add(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
@@ -97,3 +89,12 @@ async function del(req, res, next) {
next(new HttpSuccess(204));
}
export default {
load,
add,
list,
get,
update,
del,
};
+31 -30
View File
@@ -3,38 +3,14 @@ import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as oidcServer from '../oidcserver.js';
import * as passkeys from '../passkeys.js';
import oidcServer from '../oidcserver.js';
import passkeys from '../passkeys.js';
import safe from 'safetydance';
import * as tokens from '../tokens.js';
import * as userDirectory from '../user-directory.js';
import * as users from '../users.js';
import * as settings from '../settings.js';
import tokens from '../tokens.js';
import userDirectory from '../user-directory.js';
import users from '../users.js';
import settings from '../settings.js';
export {
canEditProfile,
get,
setDisplayName,
setEmail,
setFallbackEmail,
getAvatarById,
setAvatar,
unsetAvatar,
setLanguage,
getBackgroundImage,
setBackgroundImage,
unsetBackgroundImage,
setPassword,
setTwoFactorAuthenticationSecret,
enableTwoFactorAuthentication,
disableTwoFactorAuthentication,
setNotificationConfig,
destroyUserSession,
getPasskey,
getPasskeyRegistrationOptions,
registerPasskey,
deletePasskey
};
async function canEditProfile(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
@@ -305,3 +281,28 @@ async function deletePasskey(req, res, next) {
next(new HttpSuccess(204));
}
export default {
canEditProfile,
get,
setDisplayName,
setEmail,
setFallbackEmail,
getAvatarById,
setAvatar,
unsetAvatar,
setLanguage,
getBackgroundImage,
setBackgroundImage,
unsetBackgroundImage,
setPassword,
setTwoFactorAuthenticationSecret,
enableTwoFactorAuthentication,
disableTwoFactorAuthentication,
setNotificationConfig,
destroyUserSession,
getPasskey,
getPasskeyRegistrationOptions,
registerPasskey,
deletePasskey
};
+15 -14
View File
@@ -3,23 +3,13 @@ import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as network from '../network.js';
import * as provision from '../provision.js';
import network from '../network.js';
import provision from '../provision.js';
import safe from 'safetydance';
import superagent from '@cloudron/superagent';
import * as system from '../system.js';
import * as users from '../users.js';
import system from '../system.js';
import users from '../users.js';
export {
providerTokenAuth,
verifyUnprovisioned,
setup,
activate,
restore,
getStatus,
getBlockDevices,
detectIP
};
async function verifyUnprovisioned(req, res, next) {
const activated = await users.isActivated();
@@ -151,3 +141,14 @@ async function detectIP(req, res, next) {
const result = await network.detectIP();
next(new HttpSuccess(200, { ipv4: result.ipv4, ipv6: result.ipv6 }));
}
export default {
providerTokenAuth,
verifyUnprovisioned,
setup,
activate,
restore,
getStatus,
getBlockDevices,
detectIP
};
+8 -7
View File
@@ -3,15 +3,9 @@ import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as reverseProxy from '../reverseproxy.js';
import reverseProxy from '../reverseproxy.js';
import safe from 'safetydance';
export {
getTrustedIps,
setTrustedIps,
renewCerts,
};
async function getTrustedIps(req, res, next) {
const [error, trustedIps] = await safe(reverseProxy.getTrustedIps());
@@ -40,3 +34,10 @@ async function renewCerts(req, res, next) {
next(new HttpSuccess(202, { taskId }));
}
export default {
getTrustedIps,
setTrustedIps,
renewCerts,
};
+14 -13
View File
@@ -3,22 +3,11 @@ import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as metrics from '../metrics.js';
import * as platform from '../platform.js';
import metrics from '../metrics.js';
import platform from '../platform.js';
import safe from 'safetydance';
import services from '../services.js';
export {
list,
get,
configure,
getLogs,
getLogStream,
restart,
rebuild,
getMetrics,
getPlatformStatus
};
async function list(req, res, next) {
const [error, result] = await safe(services.listServices());
@@ -153,3 +142,15 @@ async function getMetrics(req, res, next) {
async function getPlatformStatus(req, res, next) {
next(new HttpSuccess(200, platform.getStatus()));
}
export default {
list,
get,
configure,
getLogs,
getLogStream,
restart,
rebuild,
getMetrics,
getPlatformStatus
};
+16 -15
View File
@@ -2,23 +2,10 @@ import assert from 'node:assert';
import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import * as metrics from '../metrics.js';
import metrics from '../metrics.js';
import safe from 'safetydance';
import * as system from '../system.js';
import system from '../system.js';
export {
reboot,
getInfo,
getMemory,
getLogs,
getLogStream,
getMetrics,
getMetricStream,
getBlockDevices,
getFilesystems,
getFilesystemUsage,
getCpus,
};
async function reboot(req, res, next) {
// Finish the request, to let the appstore know we triggered the reboot
@@ -197,3 +184,17 @@ async function getFilesystemUsage(req, res, next) {
task.start(); // background
}
export default {
reboot,
getInfo,
getMemory,
getLogs,
getLogStream,
getMetrics,
getMetricStream,
getBlockDevices,
getFilesystems,
getFilesystemUsage,
getCpus,
};
+11 -10
View File
@@ -5,16 +5,6 @@ import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import tasks from '../tasks.js';
export {
load,
get,
list,
stopTask,
getLogs,
getLogStream
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.taskId, 'string');
@@ -119,3 +109,14 @@ async function getLogStream(req, res, next) {
logStream.on('end', res.end.bind(res));
logStream.on('error', res.end.bind(res, null));
}
export default {
load,
get,
list,
stopTask,
getLogs,
getLogStream
};
+1 -1
View File
@@ -4,7 +4,7 @@ import common from './common.js';
import expect from 'expect.js';
import superagent from '@cloudron/superagent';
import timers from 'timers/promises';
import * as tokens from '../../tokens.js';
import tokens from '../../tokens.js';
/* global it:false */
/* global describe:false */
+1 -1
View File
@@ -1,6 +1,6 @@
/* global it:false */
import * as applinks from '../../applinks.js';
import applinks from '../../applinks.js';
import common from './common.js';
import expect from 'expect.js';
import superagent from '@cloudron/superagent';
+6 -6
View File
@@ -5,23 +5,23 @@ import async from 'async';
import child_process from 'node:child_process';
import constants from '../../constants.js';
import crypto from 'node:crypto';
import * as database from '../../database.js';
import database from '../../database.js';
import Docker from 'dockerode';
import expect from 'expect.js';
import fs from 'node:fs';
import hat from '../../hat.js';
import http from 'node:http';
import * as ldapServer from '../../ldapserver.js';
import ldapServer from '../../ldapserver.js';
import net from 'node:net';
import nock from 'nock';
import path from 'node:path';
import paths from '../../paths.js';
import * as platform from '../../platform.js';
import platform from '../../platform.js';
import safe from 'safetydance';
import * as server from '../../server.js';
import * as settings from '../../settings.js';
import server from '../../server.js';
import settings from '../../settings.js';
import superagent from '@cloudron/superagent';
import * as tokens from '../../tokens.js';
import tokens from '../../tokens.js';
import url from 'node:url';
/* global describe:false */
+2 -2
View File
@@ -1,11 +1,11 @@
/* global it:false */
import * as appstore from '../../appstore.js';
import appstore from '../../appstore.js';
import common from './common.js';
import constants from '../../constants.js';
import expect from 'expect.js';
import nock from 'nock';
import * as settings from '../../settings.js';
import settings from '../../settings.js';
import superagent from '@cloudron/superagent';
/* global describe:false */
+1 -1
View File
@@ -1,6 +1,6 @@
/* global it:false */
import * as archives from '../../archives.js';
import archives from '../../archives.js';
import backups from '../../backups.js';
import common from './common.js';
import expect from 'expect.js';
+1 -1
View File
@@ -1,6 +1,6 @@
/* global it, describe, before, after */
import * as backupSites from '../../backupsites.js';
import backupSites from '../../backupsites.js';
import common from './common.js';
import expect from 'expect.js';
import superagent from '@cloudron/superagent';
+30 -29
View File
@@ -1,20 +1,20 @@
import apps from '../../apps.js';
import * as appstore from '../../appstore.js';
import * as backupSites from '../../backupsites.js';
import appstore from '../../appstore.js';
import backupSites from '../../backupsites.js';
import debugModule from 'debug';
import constants from '../../constants.js';
import * as database from '../../database.js';
import database from '../../database.js';
import expect from 'expect.js';
import * as mailer from '../../mailer.js';
import mailer from '../../mailer.js';
import nock from 'nock';
import oidcClients from '../../oidcclients.js';
import * as oidcServer from '../../oidcserver.js';
import * as server from '../../server.js';
import * as settings from '../../settings.js';
import oidcServer from '../../oidcserver.js';
import server from '../../server.js';
import settings from '../../settings.js';
import superagent from '@cloudron/superagent';
import tasks from '../../tasks.js';
import timers from 'timers/promises';
import * as tokens from '../../tokens.js';
import tokens from '../../tokens.js';
const debug = debugModule('box:test/common');
@@ -96,27 +96,6 @@ const app = {
const serverUrl = `http://localhost:${constants.PORT}`;
export default {
setup,
setupServer,
cleanup,
clearMailQueue,
checkMails,
waitForTask,
waitForAsyncTask,
owner,
admin,
user,
app,
getDefaultBackupSite,
mockApiServerOrigin,
dashboardDomain,
dashboardFqdn: 'my.test.example.com',
appstoreToken,
mailFqdn: 'my.test.example.com',
serverUrl,
auditSource: { ip: '5.6.7.8' }
};
async function setupServer() {
debug('Setting up server');
@@ -249,3 +228,25 @@ async function getDefaultBackupSite() {
const result = await backupSites.list();
return result.find(r => r.name === 'Default');
}
export default {
setup,
setupServer,
cleanup,
clearMailQueue,
checkMails,
waitForTask,
waitForAsyncTask,
owner,
admin,
user,
app,
getDefaultBackupSite,
mockApiServerOrigin,
dashboardDomain,
dashboardFqdn: 'my.test.example.com',
appstoreToken,
mailFqdn: 'my.test.example.com',
serverUrl,
auditSource: { ip: '5.6.7.8' }
};
+3 -3
View File
@@ -2,10 +2,10 @@
import common from './common.js';
import expect from 'expect.js';
import * as mail from '../../mail.js';
import mail from '../../mail.js';
import superagent from '@cloudron/superagent';
import * as _ from '../../underscore.js';
import * as dig from '../../dig.js';
import _ from '../../underscore.js';
import dig from '../../dig.js';
/* global describe:false */
/* global before:false */
+1 -1
View File
@@ -2,7 +2,7 @@
import common from './common.js';
import expect from 'expect.js';
import * as notifications from '../../notifications.js';
import notifications from '../../notifications.js';
import superagent from '@cloudron/superagent';
/* global describe:false */
+1 -1
View File
@@ -5,7 +5,7 @@ import expect from 'expect.js';
import fs from 'node:fs';
import speakeasy from 'speakeasy';
import superagent from '@cloudron/superagent';
import * as tokens from '../../tokens.js';
import tokens from '../../tokens.js';
const customAvatarSize = fs.readFileSync('./logo.png').length;
+1 -1
View File
@@ -1,7 +1,7 @@
/* global it:false */
import common from './common.js';
import * as appstore from '../../appstore.js';
import appstore from '../../appstore.js';
import expect from 'expect.js';
import nock from 'nock';
import superagent from '@cloudron/superagent';
+1 -1
View File
@@ -4,7 +4,7 @@ import common from './common.js';
import expect from 'expect.js';
import fs from 'node:fs';
import superagent from '@cloudron/superagent';
import * as users from '../../users.js';
import users from '../../users.js';
/* global describe:false */
/* global before:false */
+9 -8
View File
@@ -4,15 +4,8 @@ import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import oidcClients from '../oidcclients.js';
import safe from 'safetydance';
import * as tokens from '../tokens.js';
import tokens from '../tokens.js';
export {
verifyOwnership,
list,
get,
add,
del
};
async function verifyOwnership(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
@@ -73,3 +66,11 @@ async function del(req, res, next) {
next(new HttpSuccess(204, {}));
}
export default {
verifyOwnership,
list,
get,
add,
del
};
+11 -10
View File
@@ -4,17 +4,8 @@ import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import * as updater from '../updater.js';
import updater from '../updater.js';
export {
getAutoupdatePattern,
setAutoupdatePattern,
getBoxUpdate,
checkBoxUpdate,
updateBox,
};
async function getAutoupdatePattern(req, res, next) {
const [error, pattern] = await safe(updater.getAutoupdatePattern());
@@ -61,3 +52,13 @@ async function checkBoxUpdate(req, res, next) {
next(new HttpSuccess(200, { update: result }));
}
export default {
getAutoupdatePattern,
setAutoupdatePattern,
getBoxUpdate,
checkBoxUpdate,
updateBox,
};
+6 -5
View File
@@ -4,12 +4,8 @@ import BoxError from '../boxerror.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import * as userDirectory from '../user-directory.js';
import userDirectory from '../user-directory.js';
export {
getProfileConfig,
setProfileConfig
};
async function getProfileConfig(req, res, next) {
const [error, directoryConfig] = await safe(userDirectory.getProfileConfig());
@@ -29,3 +25,8 @@ async function setProfileConfig(req, res, next) {
next(new HttpSuccess(200, {}));
}
export default {
getProfileConfig,
setProfileConfig
};
+32 -31
View File
@@ -1,41 +1,13 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as groups from '../groups.js';
import groups from '../groups.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import * as users from '../users.js';
import * as _ from '../underscore.js';
import users from '../users.js';
import _ from '../underscore.js';
export {
get,
list,
add,
del,
setRole,
setActive,
getAvatar,
setAvatar,
unsetAvatar,
updateProfile,
setPassword,
verifyPassword,
setLocalGroups,
setGhost,
getPasswordResetLink,
sendPasswordResetEmail,
getInviteLink,
sendInviteEmail,
disableTwoFactorAuthentication,
load
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.userId, 'string');
@@ -311,3 +283,32 @@ async function sendInviteEmail(req, res, next) {
next(new HttpSuccess(202, {}));
}
export default {
get,
list,
add,
del,
setRole,
setActive,
getAvatar,
setAvatar,
unsetAvatar,
updateProfile,
setPassword,
verifyPassword,
setLocalGroups,
setGhost,
getPasswordResetLink,
sendPasswordResetEmail,
getInviteLink,
sendInviteEmail,
disableTwoFactorAuthentication,
load
};
+11 -11
View File
@@ -1,21 +1,11 @@
import assert from 'node:assert';
import AuditSource from '../auditsource.js';
import BoxError from '../boxerror.js';
import * as volumes from '../volumes.js';
import volumes from '../volumes.js';
import { HttpError } from '@cloudron/connect-lastmile';
import { HttpSuccess } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
export {
add,
get,
update,
del,
list,
load,
remount,
getStatus
};
async function load(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -93,3 +83,13 @@ async function getStatus(req, res, next) {
next(new HttpSuccess(200, status));
}
export default {
add,
get,
update,
del,
list,
load,
remount,
getStatus
};
+5 -4
View File
@@ -1,10 +1,7 @@
import { HttpError } from '@cloudron/connect-lastmile';
import safe from 'safetydance';
import * as wellknown from '../wellknown.js';
import wellknown from '../wellknown.js';
export {
get
};
async function get(req, res, next) {
const host = req.headers['host'];
@@ -15,3 +12,7 @@ async function get(req, res, next) {
res.status(200).set('content-type', result.type).send(result.body);
}
export default {
get
};