Commit Graph
353 Commits
Author SHA1 Message Date
Krystie 22c48076c0 Merge remote changes - resolve conflicts: keep remote package.json v1.4.0, keep local self-updater.js logic, features.js regenerated by build 2026-05-14 21:08:20 -07:00
Krystie 947007438f Update: version 1.2.0, new version UI features, CSP hash auto-update, bug fixes 2026-05-14 21:04:35 -07:00
SamiandClaude Opus 4.7 f65af5d7fd fix(updater): stop false-positive "update available" loop when commit is unknown
Dockerfile never received DASHCADDY_COMMIT at build, so /app/VERSION held
'unknown'. _isNewer then treated same-version-different-commit as newer,
making the auto-updater rebuild the container indefinitely (each rebuild
still produced commit='unknown').

- self-updater._isNewer: normalize commits; treat unknown/null/empty as no
  commit info and fall back to pure version comparison
- self-updater._autoCheckAndApply + routes/updates: refuse to apply when
  local version >= remote version (belt-and-suspenders)
- update-management.js: hide '(unknown)' from version label
- Dockerfile: COPY VERSION instead of writing from build arg
- VERSION: committed placeholder ('dev'); scripts/release.sh now writes
  the real short SHA into the tarball's VERSION before tar-ing, so every
  published release ships with an accurate commit

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:20:59 -07:00
Sami 88206ff215 chore(release): bump to 1.4.0 2026-05-06 20:29:04 -07:00
SamiandClaude Opus 4.7 f537a0dd25 feat: cloud backup destinations + long-term resource history
Cloud backups (Dropbox / WebDAV / SFTP):
- backup-manager.js: save + load handlers per provider, credential
  resolution via credentialManager, destination probe.
- routes/backups.js: /credentials/{provider} (masked GET, POST, DELETE),
  /test-destination, scheduling endpoints.
- status/js/backup-restore.js: destination picker, provider-specific
  credential forms, test button wired to backend probe.
- npm deps already present (dropbox 10.34.0, webdav 5.7.1,
  ssh2-sftp-client 11.0.0).

Resource history:
- resource-monitor.js: three-tier rollup storage — raw 10s samples
  (7-day retention), hourly rollups (30-day), daily rollups
  (365-day). getHistoryByRange() auto-selects the appropriate tier.
- routes/monitoring.js: /monitoring/history/:containerId now supports
  startTime/endTime range mode (legacy ?hours=N still works).
- status/js/resource-monitor.js + dashboard.css: "History" tab with
  range buttons (1h/24h/7d/30d/1y), SVG sparklines for
  CPU / memory / network. Renderer handles raw and rolled-up shapes.

status/dist/features.js rebuilt from source via build.js.

Lifted out of wip/cloud-backups-and-history; the half-finished
app-deps feature from that branch (frontend calls /api/v1/apps/
check-dependencies but the endpoint doesn't exist) is preserved
separately on wip/app-deps for later.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 19:14:38 -07:00
SamiandClaude Opus 4.7 6e47df0d3c fix(installer): add src/ deploy + drop MakeDirectory=yes; bump 1.3.1
- install.sh now deploys the src/ directory alongside routes/.
  Without this, fresh installs of v1.3.0+ produce containers whose
  Dockerfile references src/ but the directory is missing on the host
  filesystem, so docker build fails with "/src: not found".

- The fallback heredoc that writes /etc/systemd/system/dashcaddy-
  updater.path drops MakeDirectory=yes for the same reason it was
  removed from the on-disk unit (e994ad1): systemd creates the watched
  trigger.json path as an empty directory on unit start, blocking
  every subsequent update with EISDIR.

Bumped to 1.3.1 so the existing v1.3.0 instance auto-updates and
picks up these and the host-script fix from 0cf6323.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 18:42:23 -07:00
SamiandClaude Opus 4.7 0cf63231d3 fix(updater): copy src/, replace routes/ in place instead of nesting
Two bugs in the host-side updater script:

1. The Dockerfile (since f5fe32b) does \`COPY src/ ./src/\`, but the
   host script never copies src/ from staging into the api source
   directory. Result: every update fails with
   "failed to compute cache key: ... '/src': not found".

2. \`cp -rf staging/routes api_source/routes/\` does NOT replace the
   destination directory — it copies the source dir INTO the
   destination, producing api_source/routes/routes/. Means new route
   files end up nested one level deep and never get loaded by
   server.js, so updates silently regress route handlers even when
   the build succeeds.

Switch to "rm -rf dest && cp -rf src dest" semantics for both routes
and src, in all four touch points (deploy + 3 rollback paths).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 18:31:28 -07:00
SamiandClaude Opus 4.7 e994ad157e fix(systemd): drop MakeDirectory=yes from updater path unit
`MakeDirectory=yes` on a `PathChanged=` directive whose target is a
file (not a directory) causes systemd to create the watched path as
an empty directory on unit start. The container's self-updater then
crashes with EISDIR every time it tries to writeFile() the trigger,
and the host script never runs.

The parent `/opt/dashcaddy/updates/` is already created by the
installer/Docker volume, so the flag is redundant and only here as
a footgun. Drop it.

Reproducer: enable the unit on a fresh system, watch
`/opt/dashcaddy/updates/trigger.json` get materialized as a directory
within milliseconds of `systemctl start dashcaddy-updater.path`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 17:50:10 -07:00
SamiandClaude Opus 4.7 fa40dcff7a chore(release): bump to 1.3.0
v1.2.0 was published as a tarball but its package.json bump was never
committed back to git. This release picks up where that gap left off
and includes two fixes that v1.2.0 (commit a216dd8) was missing:

  - 6abba43: clear ALL pending self-update history entries (not just
    the first), so stuck installs unwind cleanly.
  - 0460129: allow apiSourceDir to be overridden via the
    DASHCADDY_API_SOURCE_DIR env var, so installs that don't follow
    the default /etc/dashcaddy/sites/dashcaddy-api/ layout (e.g. older
    deployments under /opt/dashcaddy/) can point the auto-updater at
    the right path without patching the constructor.

Without these, instances on the older /opt/dashcaddy/ layout get
stuck in a 30-min retry loop where every update attempt fails with
'cp: cannot create directory /etc/dashcaddy/sites/dashcaddy-api/'.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 17:43:29 -07:00
SamiandClaude Opus 4.7 0460129b32 feat(self-updater): allow apiSourceDir override via DASHCADDY_API_SOURCE_DIR env
Mirrors the env-var pattern f5fe32b introduced for channel and
instanceIdFile. Lets installs that don't follow the default
/etc/dashcaddy/sites/dashcaddy-api/ layout (e.g. older deployments
under /opt/dashcaddy/) point the auto-updater at the right path
without having to patch the constructor call site.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 16:27:32 -07:00
SamiandClaude Opus 4.7 6abba43a80 fix(self-updater): clear all pending history entries, not just one
checkPostUpdateResult() used history.find() which only ever updated a
single pending entry. When multiple update attempts stacked up, the
extra pending entries stayed stuck in 'pending' forever even though
the actual update completed. Switch to filter() + loop to clear all
matching entries.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 02:04:23 -07:00
Krystie a216dd882d Add dashboard version button and self-update UI wiring 2026-05-05 17:52:05 -07:00
Krystie 95b137bf17 Fix DNS2 self-updater path and sync live dashboard version UI 2026-05-05 17:26:42 -07:00
Krystie f5fe32b999 feat(update): add release policy checks and dashboard version verification 2026-05-04 18:05:00 -07:00
Krystie 0c658a26a8 fix(routes): complete post-refactor dependency wiring cleanup 2026-05-04 16:44:18 -07:00
Krystie 4eebb3ce7a fix(test): remove stale jest setupFilesAfterEnv entry 2026-05-04 16:36:09 -07:00
Krystie 55c405082a fix: use TIMEOUTS constants instead of magic numbers in health and services routes
- health.js: replace magic number 5000 with TIMEOUTS.HTTP_DEFAULT (twice)
- services.js: replace magic number 5000 with TIMEOUTS.HTTP_DEFAULT

Both files already import TIMEOUTS from constants but weren't using it.
2026-05-01 02:36:31 -07:00
Krystie 2f1e2107bc fix: replace console.log/console.error with proper logging in monitoring and themes routes
- monitoring.js: Added log dependency, replaced console.log with log.warn
- themes.js: Added log dependency, replaced console.error with log.error
- src/app.js: Pass log to monitoringRoutes and themesRoutes

This fixes error messages being lost to stdout instead of proper log files.
2026-05-01 02:24:59 -07:00
SamiandClaude Opus 4.6 ea5acfa9a2 test: build comprehensive test suite reaching 80%+ coverage threshold
Add 22 test files (~700 tests) covering security-critical modules, core
infrastructure, API routes, and error handling. Final coverage: 86.73%
statements / 80.57% branches / 85.57% functions / 87.42% lines, all above
the 80% threshold enforced by jest.config.js.

Highlights:
- Unit tests for crypto-utils, credential-manager, auth-manager, csrf,
  input-validator, state-manager, health-checker, backup-manager,
  update-manager, resource-monitor, app-templates, platform-paths,
  port-lock-manager, errors, error-handler, pagination, url-resolver
- Route tests for health, services, and containers (supertest + mocked deps)
- Shared test-utils helper for mock factories and Express app builder
- npm scripts for CI: test:ci, test:unit, test:routes, test:security,
  test:changed, test:debug
- jest.config.js: expand coverage targets, add 80% threshold gate
- routes/services.js: import ValidationError and NotFoundError from errors
- .gitignore: exclude coverage/, *.bak, *.log

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 21:36:46 -07:00
SamiandClaude Opus 4.6 bdf3f247b1 feat: add 7 new features — exec shell, SSE events, compose import, docker resources, resource limits, email notifications, auto-updates
- Container exec/shell via WebSocket + xterm.js (subtle >_ button on cards)
- Live dashboard updates via SSE (resource alerts, health changes, update notices)
- Docker Compose import with YAML parsing, preview, and dependency-ordered deploy
- Volume & network management modal with disk usage overview
- CPU/memory resource limits on deploy and live update
- Email SMTP notifications (nodemailer) alongside Discord/Telegram/ntfy
- Scheduled auto-update scheduler with maintenance windows (daily/weekly/monthly)

New deps: ws, js-yaml, nodemailer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 16:15:14 -07:00
SamiandClaude Opus 4.6 b60e7e40d0 fix: spread response data instead of nesting under 'data' key
The Phase 2.1 refactor wrapped success() responses as { success, data: {...} }
but the frontend expects flat responses like { success, license: {...} }.
This caused license to show FREE TIER and broke other API consumers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 02:00:05 -07:00
SamiandClaude Opus 4.6 9e24f33465 fix: make /api/config and /api/services/status public endpoints
These endpoints must be accessible without TOTP auth for the dashboard
to load site config (TLD, DNS servers, custom logo) and service status
(bulk probe results). Without them, the dashboard shows all services
as OFF and loses custom branding after any session expiry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 01:10:24 -07:00
SamiandClaude Opus 4.6 80bff25af9 fix: increase general rate limit from 100 to 1000 per 15min
100 requests/15min was far too low for a dashboard with auto-refresh
polling every 10-30 seconds, causing 429s on TOTP config, site config,
license status and other endpoints after ~3 minutes of normal use.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 23:26:30 -07:00
SamiandClaude Opus 4.6 188bcfbda0 fix: exempt dashboard-critical endpoints from rate limiter
License status, services list, config, and license feature checks
were being rate-limited (429) after ~14 minutes of dashboard polling,
causing the license to show FREE TIER and services to fail loading.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 18:45:25 -07:00
SamiandClaude Opus 4.6 4c2e4ed986 fix: resolve ctx naming conflict in arr/config.js, add pylon to known config keys
- Remove redundant ctx shim that conflicted with function parameter
- Use destructured notification/safeErrorMessage directly
- Add pylon, customLogoDark, customLogoLight to known config keys

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 03:23:59 -07:00
SamiandClaude Opus 4.6 70ce32fbe0 fix: add Pylon relay fallback to /probe/:id endpoint
The lightweight probe endpoint used by the dashboard for live status
checks had no Pylon integration. When DNS2 (Singapore) tried to probe
home network services directly, all probes timed out with 502. Now
falls back to the configured Pylon relay before the domain fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 03:21:13 -07:00
SamiandClaude Opus 4.6 f865790fe1 fix(routes): restore ctx access in 15 route files broken by Phase 2.1 refactor
The modular refactor changed function signatures to destructured deps but
left internal ctx.* references intact, causing "ctx is not defined" errors
on /api/config, /api/logo, and many other endpoints. Also implements
loadTotpConfig and saveTotpConfig which were left as stubs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 03:01:29 -07:00
SamiandClaude Opus 4.6 01bf01d043 fix: repair SSO auto-login and remove repo artifacts
- Add missing fetchT dep to session-handlers.js (fixes ctx is not
  defined error that broke jellyfin/emby/plex/syncthing SSO)
- Replace all ctx.fetchT calls with direct fetchT usage
- Remove server-old.js (69K monolith backup) from tracking
- Remove AI-generated doc artifacts from repo root
- Update .gitignore to prevent re-adding these files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 01:28:19 -07:00
SamiandClaude Opus 4.6 3b08fe25e8 merge: integrate Phase 2.1 server refactor from remote
Resolve conflict in server.js by accepting the remote's modular
refactor (1960 lines → 230 lines). Local Phase 1/2 changes
(logger swap, unused import) are superseded by the new structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 01:13:46 -07:00
SamiandClaude Opus 4.6 7cd053ab0f fix: clean up Phase 1/2 commit issues
- Remove duplicate HTTP_STATUS/NETWORK exports in constants.js
- Remove unused responseHelpers import from server.js
- Remove backup file and doc artifacts from tracking
- Update .gitignore to prevent re-adding bloat files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 01:08:48 -07:00
Krystie ae6f2d9df1 fix(routes): Pass full deps to config/backup and create ctx shim 2026-03-30 00:24:47 -07:00
Krystie a2ee590897 fix(routes): Pass licenseManager and other deps to auth/sso-gate 2026-03-30 00:23:12 -07:00
Krystie e4b5a0a645 fix(routes): Add missing ctx shim to auth/sso-gate.js 2026-03-30 00:22:19 -07:00
Krystie 564c442ea4 fix(routes): Correct require paths for errors.js in subdirectory routes 2026-03-30 00:21:25 -07:00
Krystie 2929e52b14 fix(docker): Copy src/ directory in Dockerfile for Phase 2.1 refactor 2026-03-30 00:20:28 -07:00
Krystie a86546181e fix(lint): Add ctx shim to routes/auth/totp
- Add credentialManager, totpConfig, saveTotpConfig, session to deps
- Create ctx shim for backward compatibility
- Fix hasOwnProperty anti-pattern (use Object.prototype.hasOwnProperty.call)

Result: 54 errors → 0 errors
2026-03-29 22:37:21 -07:00
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
Krystie 3de65dbf81 Refactor recipes routes: explicit dependency injection
- Updated all recipes route modules to use destructured dependencies
- Added JSDoc comments for factory functions
- Replaced ctx. references with direct parameter access
- All files pass syntax validation

Files refactored:
- routes/recipes/deploy.js
- routes/recipes/manage.js
- routes/recipes/index.js (orchestrator)
2026-03-29 21:45:28 -07:00
Krystie 77ae8171b8 Refactor config routes: explicit dependency injection
- Updated all config route modules to use destructured dependencies
- Added JSDoc comments for factory functions
- Replaced ctx. references with direct parameter access
- All files pass syntax validation

Files refactored:
- routes/config/assets.js
- routes/config/backup.js
- routes/config/settings.js
- routes/config/index.js (orchestrator)
2026-03-29 21:43:29 -07:00
Krystie df3e8efdd0 Refactor auth routes: explicit dependency injection
- Updated all auth route modules to use destructured dependencies
- Added JSDoc comments for factory functions
- Replaced ctx. references with direct parameter access
- Updated auth/index.js to extract and pass explicit dependencies
- sso-gate.js maintains session helper exports from session-handlers
- All files pass syntax validation

Files refactored:
- routes/auth/keys.js
- routes/auth/session-handlers.js
- routes/auth/sso-gate.js
- routes/auth/totp.js
- routes/auth/index.js (orchestrator)
2026-03-29 21:42:30 -07:00
Krystie a4788c3f28 Refactor apps routes: explicit dependency injection
- Updated all apps route modules to use destructured dependencies
- Added JSDoc comments for factory functions
- Replaced ctx. references with direct parameter access
- Updated apps/index.js to extract and pass explicit dependencies
- All files pass syntax validation

Files refactored:
- routes/apps/deploy.js (18k lines)
- routes/apps/helpers.js (17k lines)
- routes/apps/removal.js
- routes/apps/restore.js
- routes/apps/templates.js
- routes/apps/index.js (orchestrator)
2026-03-29 21:36:15 -07:00
Krystie 6bde2eb62e Refactor arr routes: explicit dependency injection
- Updated all arr route modules to use destructured dependencies
- Added JSDoc comments for factory functions
- Replaced ctx. references with direct parameter access
- Updated arr/index.js to extract and pass explicit dependencies
- Maintained backward compatibility with context pattern
- All files pass syntax validation

Files refactored:
- routes/arr/detect.js
- routes/arr/credentials.js
- routes/arr/config.js (579 lines)
- routes/arr/smart-connect.js
- routes/arr/plex.js
- routes/arr/helpers.js
- routes/arr/index.js (orchestrator)
2026-03-29 21:30:41 -07:00
Krystie ac23b2e093 refactor(routes): Phase 3.6 - standardize sites.js 2026-03-29 20:16:08 -07:00
Krystie cabcbcf98a refactor(routes): Phase 3.5 - standardize logs.js 2026-03-29 20:14:33 -07:00
Krystie 8b1492142f refactor(routes): Phase 3.4 - standardize browse.js 2026-03-29 20:13:25 -07:00
Krystie e6e788fdce refactor(routes): Phase 3.3 - standardize notifications.js (explicit deps) 2026-03-29 20:06:36 -07:00
Krystie f6b103aed7 refactor(routes): Phase 3.2 - standardize tailscale.js (explicit deps + throw-based errors) 2026-03-29 20:06:13 -07:00
Krystie 4e96c62708 refactor(routes): Phase 3.1 - standardize updates.js (explicit deps) 2026-03-29 20:05:06 -07:00
Krystie 5da1e572a1 refactor(server): Complete Phase 2.1 - Split monolithic server.js
MASSIVE REFACTOR:
- Created src/app.js (17KB) - Express setup, middleware, routes
- Slimmed server.js from 1997 lines → 230 lines (88% reduction!)
- Backed up original as server-old.js for reference

NEW STRUCTURE:
src/
├── app.js (Express application factory)
├── config/ (paths, site config, constants)
├── context/ (DI container, domain modules)
└── utils/ (http, logging, responses, async-handler)

STATS:
- Old server.js: 1997 lines (monolith)
- New server.js: 230 lines (entry point only)
- Modular code: 1729 lines across 14 files in src/
- Total reduction: 88% in main file

server.js now ONLY handles:
- App creation
- License loading
- HTTP server startup
- Feature module initialization
- Graceful shutdown

All business logic moved to src/ modules. Clean, testable, maintainable.

Phase 2.1 COMPLETE 
2026-03-29 19:46:41 -07:00
Krystie fa7a78388a refactor(utils): Extract utilities from server.js
- Create src/utils/http.js - fetchT and HTTP helpers
- Create src/utils/logging.js - Structured logging and error logging
- Create src/utils/responses.js - Standard API responses
- Create src/utils/async-handler.js - Async wrapper with error handling
- Create src/utils/index.js - Consolidated exports

Removes scattered helper functions from server.js
2026-03-29 19:40:18 -07:00