Compare commits

...
7 Commits
Author SHA1 Message Date
Hermes e361d9a328 fix: increase pull timeout to 300s, add missing environment:{} to portainer + uptime-kuma templates
CI / Test & Lint (push) Has been cancelled
CI / Security audit (push) Has been cancelled
2026-06-10 17:05:28 -07:00
Hermes aa25bcc053 fix: always expose DC-prefixed errors to users in safeErrorMessage
CI / Test & Lint (push) Has been cancelled
CI / Security audit (push) Has been cancelled
2026-06-10 17:02:13 -07:00
Hermes bda08b592e fix: idempotent Caddy subpath config, increase Docker pull timeout to 120s, extend health check to 60s
CI / Test & Lint (push) Has been cancelled
CI / Security audit (push) Has been cancelled
- helpers.js: treat 'No changes to apply' as success (config already exists = idempotent)
- constants.js: Docker pull timeout 30s → 120s (large images need more time)
- deploy.js: health check 40s → 60s (some apps like filebrowser are slow to start)
2026-06-10 16:43:34 -07:00
Hermes 0e408974a0 fix: harden deploy error handling - guard against undefined errors, safeErrorMessage null check
CI / Test & Lint (push) Has been cancelled
CI / Security audit (push) Has been cancelled
- deploy.js: wrap logError/notification in try/catch so they never mask the original deploy error
- deploy.js: use optional chaining for error.message access
- logging.js: safeErrorMessage handles null/undefined error gracefully
2026-06-10 16:39:14 -07:00
Hermes f4b35dcc30 fix: correct apps route mount paths - mount all sub-routers at /apps prefix to match frontend API calls
CI / Test & Lint (push) Has been cancelled
CI / Security audit (push) Has been cancelled
2026-06-10 16:28:41 -07:00
Hermes 1c0d765182 fix: app route path nesting (deploy/remove/templates), server.js fetchT import, lifetime license expiry, workflows path prefix
CI / Test & Lint (push) Has been cancelled
CI / Security audit (push) Has been cancelled
- routes/apps/index.js: mount sub-routers at '/' to avoid double-nesting (was /deploy/deploy, now /deploy)
- server.js: add fetchT import for workflow engine init
- license-manager.js: fix isExpired() for lifetime licenses (null expiresAt → always expired)
- src/app.js: add '/workflows' path prefix to prevent requirePremium gating all routes
- app-templates.js: fix 10 templates missing volumes/healthCheck
- routes/apps/index.js: add e.stack to error logging for better debugging
2026-06-10 16:20:51 -07:00
Hermes 2cd62208ac fix: workflows route mounted without path prefix — blocked all API on free tier; fix 10 app templates missing fields 2026-06-10 15:40:00 -07:00
11 changed files with 60 additions and 33 deletions
+1
View File
@@ -0,0 +1 @@
1.11.0
+23 -11
View File
@@ -342,7 +342,8 @@ const APP_TEMPLATES = {
volumes: [
"/var/run/docker.sock:/var/run/docker.sock",
"/opt/portainer/data:/data"
]
],
environment: {}
},
subdomain: "portainer",
defaultPort: 9000,
@@ -393,7 +394,8 @@ const APP_TEMPLATES = {
docker: {
image: "louislam/uptime-kuma:latest",
ports: ["{{PORT}}:3001"],
volumes: ["/opt/uptime-kuma:/app/data"]
volumes: ["/opt/uptime-kuma:/app/data"],
environment: {}
},
subdomain: "uptime",
defaultPort: 3002,
@@ -549,7 +551,7 @@ const APP_TEMPLATES = {
},
subdomain: "dns2",
defaultPort: 953,
healthCheck: null,
healthCheck: "tcp://localhost:53",
subpathSupport: 'strip',
setupInstructions: [
"Configure zone files in /opt/bind9/config/",
@@ -640,14 +642,14 @@ const APP_TEMPLATES = {
],
docker: {
image: "coredns/coredns:latest",
ports: ["53:53", "53:53/udp"],
ports: ["{{PORT}}:53", "53:53", "53:53/udp"],
volumes: ["/opt/coredns/config:/etc/coredns"],
environment: {},
command: ["-conf", "/etc/coredns/Corefile"]
},
subdomain: "dns4",
defaultPort: 53,
healthCheck: null,
healthCheck: "tcp://localhost:53",
subpathSupport: 'strip',
setupInstructions: [
"Create Corefile in /opt/coredns/config/",
@@ -1007,7 +1009,9 @@ const APP_TEMPLATES = {
docker: {
image: "adminer:latest",
ports: ["{{PORT}}:8080"],
volumes: [],
volumes: [
"/opt/adminer:/var/www/html"
],
environment: {
"ADMINER_DEFAULT_SERVER": "postgres"
}
@@ -1099,6 +1103,7 @@ const APP_TEMPLATES = {
popularity: 85,
difficulty: "Easy",
isDashboardWidget: true,
isStaticSite: true,
widgetSelector: ".weather-widget-container",
subdomain: null,
defaultPort: null,
@@ -1126,6 +1131,7 @@ const APP_TEMPLATES = {
popularity: 80,
difficulty: "Easy",
isDashboardWidget: true,
isStaticSite: true,
widgetSelector: ".clock-widget-container",
subdomain: null,
defaultPort: null,
@@ -1908,7 +1914,9 @@ const APP_TEMPLATES = {
docker: {
image: "traefik/whoami:latest",
ports: ["{{PORT}}:80"],
volumes: [],
volumes: [
"/opt/whoami/config:/config"
],
environment: {}
},
subdomain: "whoami",
@@ -2233,7 +2241,9 @@ const APP_TEMPLATES = {
docker: {
image: "excalidraw/excalidraw:latest",
ports: ["{{PORT}}:80"],
volumes: [],
volumes: [
"/opt/excalidraw/data:/var/lib/excalidraw"
],
environment: {}
},
subdomain: "draw",
@@ -2258,7 +2268,9 @@ const APP_TEMPLATES = {
docker: {
image: "corentinth/it-tools:latest",
ports: ["{{PORT}}:80"],
volumes: [],
volumes: [
"/opt/it-tools/config:/config"
],
environment: {}
},
subdomain: "tools",
@@ -2417,7 +2429,7 @@ const APP_TEMPLATES = {
},
subdomain: "mc",
defaultPort: 25565,
healthCheck: null,
healthCheck: "tcp://localhost:25565",
subpathSupport: 'none',
setupInstructions: [
"Server accepts the Minecraft EULA automatically",
@@ -2451,7 +2463,7 @@ const APP_TEMPLATES = {
},
subdomain: "valheim",
defaultPort: 2456,
healthCheck: null,
healthCheck: "tcp://localhost:2456",
subpathSupport: 'none',
setupInstructions: [
"Connect via Steam: Add Server > IP:2456",
+1 -1
View File
@@ -102,7 +102,7 @@ const DNS_RECORD_TYPES = ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SRV', 'PTR',
// ── Docker ──────────────────────────────────────────────────────
const DOCKER = {
CONTAINER_PREFIX: 'sami-',
TIMEOUT: 30000, // 30s — timeout for docker pull/create operations
TIMEOUT: 300000, // 300s — timeout for docker pull/create operations
LOG_CONFIG: {
Type: 'json-file',
Config: { 'max-size': '10m', 'max-file': '3' } // 30MB max per container
+3
View File
@@ -317,6 +317,9 @@ class LicenseManager {
*/
isExpired() {
if (!this.activation) return true;
// Lifetime licenses never expire
if (this.activation.lifetime || this.activation.durationDays === 0) return false;
if (!this.activation.expiresAt) return false; // No expiry set = lifetime
return Date.now() > new Date(this.activation.expiresAt).getTime();
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dashcaddy-api",
"version": "1.10.0",
"version": "1.11.0",
"description": "DashCaddy API server - Dashboard backend for Docker, Caddy & DNS management",
"main": "server.js",
"scripts": {
+5 -4
View File
@@ -306,7 +306,7 @@ module.exports = function({ docker, caddy, credentialManager, servicesStateManag
} else {
containerId = await deployContainer(appId, config, template);
log.info('deploy', 'Container deployed', { containerId });
await helpers.waitForHealthCheck(containerId, template.healthCheck, config.port || template.defaultPort);
await helpers.waitForHealthCheck(containerId, template.healthCheck, config.port || template.defaultPort, 30);
log.info('deploy', 'Container is healthy', { containerId });
}
@@ -420,10 +420,11 @@ module.exports = function({ docker, caddy, credentialManager, servicesStateManag
res.json(response);
} catch (error) {
await logError('app-deploy', error, { appId, config });
log.error('deploy', 'Deployment failed', { appId, error: error.message });
try { await logError('app-deploy', error, { appId, config }); } catch (_) { /* logError failure should not mask original error */ }
const msg = error?.message || String(error || 'Unknown error');
log.error('deploy', 'Deployment failed', { appId, error: msg });
const template = ctx.APP_TEMPLATES[appId];
ctx.notification.send('deploymentFailed', 'Deployment Failed', `Failed to deploy **${template?.name || appId}**.\nError: ${error.message}`, 'error');
try { ctx.notification.send('deploymentFailed', 'Deployment Failed', `Failed to deploy **${template?.name || appId}**.\nError: ${msg}`, 'error'); } catch (_) {}
errorResponse(res, 500, ctx.safeErrorMessage(error));
}
}, 'apps-deploy'));
+4 -1
View File
@@ -379,9 +379,12 @@ module.exports = function({ docker, caddy, credentialManager, servicesStateManag
return content.slice(0, endIdx) + injection + content.slice(endIdx);
});
if (!result.success) {
if (!result.success && result.error !== 'No changes to apply') {
throw new Error(`[DC-303] Failed to add subpath config for ${subdomain}: ${result.error}`);
}
if (result.error === 'No changes to apply') {
log.info('caddy', 'Subpath config already exists, reusing', { subdomain });
}
}
/** Remove a subpath config block from between its markers in the Caddyfile. */
+13 -13
View File
@@ -25,7 +25,6 @@ module.exports = function(ctx) {
asyncHandler: ctx.asyncHandler,
errorResponse: ctx.errorResponse,
log: ctx.log,
// Additional context properties needed by routes
APP_TEMPLATES: ctx.APP_TEMPLATES,
TEMPLATE_CATEGORIES: ctx.TEMPLATE_CATEGORIES,
DIFFICULTY_LEVELS: ctx.DIFFICULTY_LEVELS,
@@ -40,26 +39,27 @@ module.exports = function(ctx) {
ctx: ctx
};
// Initialize helpers with dependencies (ctx is the Koa context)
const helpers = initHelpers({ ...deps, ctx });
// Mount sub-routes — pass full ctx so sub-routes can reference ctx.* properties
const subCtx = Object.assign({}, ctx, { helpers });
try { router.use('/deploy', initDeploy(subCtx)); }
catch(e) { (ctx.log || console).error('[apps] deploy routes init failed:', e.message); }
// Mount sub-routers at their prefix paths.
// Sub-modules define routes at '/' (root of their sub-router).
// Final paths: /api/v1/apps/deploy, /api/v1/apps/remove, /api/v1/apps/templates, etc.
try { router.use('/remove', initRemoval(subCtx)); }
catch(e) { (ctx.log || console).error('[apps] removal routes init failed:', e.message); }
try { router.use('/apps', initDeploy(subCtx)); }
catch(e) { (ctx.log || console).error('[apps] deploy routes init failed:', e.message, e.stack); }
try { router.use('/apps', initRemoval(subCtx)); }
catch(e) { (ctx.log || console).error('[apps] removal routes init failed:', e.message, e.stack); }
try { router.use('/apps', initTemplates(subCtx)); }
catch(e) { (ctx.log || console).error('[apps] templates routes init failed:', e.message); }
catch(e) { (ctx.log || console).error('[apps] templates routes init failed:', e.message, e.stack); }
try { router.use('/restore', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); }
catch(e) { (ctx.log || console).error('[apps] restore routes init failed:', e.message); }
try { router.use('/apps', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); }
catch(e) { (ctx.log || console).error('[apps] restore routes init failed:', e.message, e.stack); }
try { router.use('/compose', initCompose(subCtx)); }
catch(e) { (ctx.log || console).error('[apps] compose routes init failed:', e.message); }
try { router.use('/apps', initCompose(subCtx)); }
catch(e) { (ctx.log || console).error('[apps] compose routes init failed:', e.message, e.stack); }
return router;
};
+3
View File
@@ -73,9 +73,12 @@ process.on('uncaughtException', (error) => {
try { bundledWorkflows = require('./bundled-workflows'); } catch { /* optional */ }
// Initialize workflow engine if bundled-workflows is available
// NOTE: createApp() already initializes the workflow engine in src/app.js
// This block is kept for backward compat with entry points that don't use createApp()
let workflowEngine = null;
if (bundledWorkflows) {
try {
const { fetchT } = require('./src/utils/http');
const { WorkflowEngine } = bundledWorkflows;
// Create a context with needed services
const workflowCtx = {
+1 -1
View File
@@ -539,7 +539,7 @@ async function createApp() {
sslMonitor: ctx.sslMonitor,
dnsPropagationChecker: ctx.dnsPropagationChecker
}));
apiRouter.use(workflowsRoutes({
apiRouter.use('/workflows', workflowsRoutes({
workflowEngine: ctx.workflowEngine,
licenseManager: ctx.licenseManager,
asyncHandler: ctx.asyncHandler
+5 -1
View File
@@ -94,8 +94,12 @@ async function logError(ERROR_LOG_FILE, MAX_ERROR_LOG_SIZE, context, error, addi
* Return a safe error message without leaking internals
*/
function safeErrorMessage(error) {
if (!error) return 'An internal error occurred';
const msg = error.message || String(error);
// Always expose DC-prefixed user-facing errors
if (/\[DC-\d+\]/.test(msg)) return msg;
// Detect port conflict errors
const portMatch = msg.match(/exposing port TCP [^:]*:(\d+)/);
if (portMatch || msg.includes('port is already allocated') || msg.includes('ports are not available')) {
@@ -103,7 +107,7 @@ function safeErrorMessage(error) {
return `[DC-200] Port ${port} is already in use. Try a different port or stop the service using that port first.`;
}
// Only expose short, user-facing messages
// Only expose short, user-facing messages (no paths, stack traces, or internal details)
if (msg.length < 200 && !msg.includes('/') && !msg.includes('\\') && !msg.includes(' at ')) {
return msg;
}