Files
sencho/backend
Anso 155a231aae refactor(backend): extract stacks router (phase 4c-6, final route extraction) (#744)
Move the 17 /api/stacks/* endpoints out of index.ts into routes/stacks.ts.
Endpoints covered:
- list, statuses (bulk-status cache via CacheService)
- get / put stack compose content
- envs (resolve), env read, env write (multi env_file aware)
- create (plain + from-git with policy gate + optional deploy)
- delete (three-stage Docker-down, FS-delete, DB cleanup)
- containers list, services list
- lifecycle: deploy / down / restart / stop / start
- update-preview, update, rollback (Skipper+), backup info

The inline resolveAllEnvFilePaths helper moves with the router as a
file-local function. Handlers moved verbatim; middleware chains,
response shapes, and error messages preserved.

Removes twenty-two now-unused imports from index.ts: DockerController,
ComposeService, path, UpdatePreviewService, CacheService, GitSourceService,
GitSourceError, gitRepoHost, sendGitSourceError, STACK_STATUSES_CACHE_TTL_MS,
requirePermission, requirePaid, buildPolicyGateOptions, runPolicyGate,
triggerPostDeployScan, getTerminalWs, invalidateNodeCaches, getErrorMessage,
enforcePolicyPreDeploy, isValidStackName, isPathWithinBase, YAML.

index.ts drops from 1021 to 305 lines. All /api/* route groups now live
in routes/*.ts. index.ts contains only wiring (createApp, createServer,
attachUpgrade, route mounts, remote proxy, static serving, error handler)
and startup/shutdown lifecycles. Bootstrap extraction follows in phase 5.
2026-04-23 23:31:29 -04:00
..