fix(routes): Pass full deps to config/backup and create ctx shim
This commit is contained in:
@@ -8,15 +8,35 @@ const express = require('express');
|
||||
module.exports = function(ctx) {
|
||||
const router = express.Router();
|
||||
|
||||
const deps = {
|
||||
// Common deps for all config routes
|
||||
const baseDeps = {
|
||||
configStateManager: ctx.configStateManager,
|
||||
servicesStateManager: ctx.servicesStateManager,
|
||||
asyncHandler: ctx.asyncHandler,
|
||||
log: ctx.log
|
||||
};
|
||||
|
||||
router.use(require('./settings')(deps));
|
||||
router.use(require('./assets')(deps));
|
||||
router.use(require('./backup')(deps));
|
||||
// Additional deps for backup route
|
||||
const backupDeps = {
|
||||
...baseDeps,
|
||||
SERVICES_FILE: ctx.SERVICES_FILE,
|
||||
CONFIG_FILE: ctx.CONFIG_FILE,
|
||||
TOTP_CONFIG_FILE: ctx.TOTP_CONFIG_FILE,
|
||||
TAILSCALE_CONFIG_FILE: ctx.TAILSCALE_CONFIG_FILE,
|
||||
NOTIFICATIONS_FILE: ctx.NOTIFICATIONS_FILE,
|
||||
caddy: ctx.caddy,
|
||||
dns: ctx.dns,
|
||||
fetchT: ctx.fetchT,
|
||||
totpConfig: ctx.totpConfig,
|
||||
credentialManager: ctx.credentialManager,
|
||||
loadSiteConfig: ctx.loadSiteConfig,
|
||||
loadNotificationConfig: ctx.loadNotificationConfig,
|
||||
session: ctx.session,
|
||||
saveTotpConfig: ctx.saveTotpConfig
|
||||
};
|
||||
|
||||
router.use(require('./settings')(baseDeps));
|
||||
router.use(require('./assets')({ ...baseDeps, CONFIG_FILE: ctx.CONFIG_FILE, readConfig: ctx.readConfig, saveConfig: ctx.saveConfig, errorResponse: ctx.errorResponse }));
|
||||
router.use(require('./backup')(backupDeps));
|
||||
return router;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user