Files
dashcaddy/dashcaddy-api/routes/apps/index.js
Krystie 5baa97bbf9 fix(lint): Add ctx shim to routes/apps and routes/arr
- routes/apps/deploy.js: Add ctx shim with APP_TEMPLATES, siteConfig, buildDomain, buildServiceUrl, addServiceToConfig, dns, notification, safeErrorMessage
- routes/apps/index.js: Extract additional ctx properties for sub-routes
- routes/arr/config.js: Add ctx shim with notification, safeErrorMessage + logError import
- routes/arr/index.js: Extract notification, safeErrorMessage for sub-routes

Result: Fixed ~30 no-undef errors (deploy.js 0 errors, arr/config.js 0 errors)
2026-03-29 22:35:13 -07:00

49 lines
1.5 KiB
JavaScript

const express = require('express');
const initHelpers = require('./helpers');
const initDeploy = require('./deploy');
const initRemoval = require('./removal');
const initTemplates = require('./templates');
const initRestore = require('./restore');
/**
* Apps routes aggregator
* Assembles all apps sub-routes with their dependencies
* @param {Object} ctx - Application context (for backward compatibility)
* @returns {express.Router}
*/
module.exports = function(ctx) {
const router = express.Router();
// Extract dependencies from context
const deps = {
docker: ctx.docker,
caddy: ctx.caddy,
credentialManager: ctx.credentialManager,
servicesStateManager: ctx.servicesStateManager,
portLockManager: ctx.portLockManager,
asyncHandler: ctx.asyncHandler,
errorResponse: ctx.errorResponse,
log: ctx.log,
// Additional context properties needed by routes
APP_TEMPLATES: ctx.APP_TEMPLATES,
siteConfig: ctx.siteConfig,
buildDomain: ctx.buildDomain,
buildServiceUrl: ctx.buildServiceUrl,
addServiceToConfig: ctx.addServiceToConfig,
dns: ctx.dns,
notification: ctx.notification,
safeErrorMessage: ctx.safeErrorMessage
};
// Initialize helpers with dependencies
const helpers = initHelpers(deps);
// Mount sub-routes with explicit dependencies
router.use(initDeploy({ ...deps, helpers }));
router.use(initRemoval({ ...deps, helpers }));
router.use(initTemplates({ ...deps, helpers }));
router.use(initRestore({ ...deps, helpers }));
return router;
};