{
  "name": "Vorlux AI | SSL Cert Monitor",
  "active": false,
  "nodes": [
    { "parameters": { "rule": { "interval": [{ "field": "days", "daysInterval": 1 }] } }, "id": "sched", "name": "Daily Schedule", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [220, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/domains", "method": "GET", "options": { "timeout": 15000 } }, "id": "fetch-domains", "name": "Fetch Domains", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 300] },
    { "parameters": { "mode": "runOnceForAllItems", "jsCode": "const domains = $input.first().json.data || $input.first().json.domains || [];\nconst now = Date.now();\nconst checks = domains.map(d => {\n  const expiresAt = d.ssl_expires || d.certExpiry;\n  const daysLeft = expiresAt ? Math.floor((new Date(expiresAt).getTime() - now) / 86400000) : -1;\n  return { domain: d.domain || d.name, daysLeft, status: daysLeft < 0 ? 'expired' : daysLeft < 14 ? 'warning' : 'ok' };\n});\nconst warnings = checks.filter(c => c.status !== 'ok');\nreturn [{ json: { totalDomains: checks.length, warnings: warnings.length, checks, hasWarnings: warnings.length > 0 } }];" }, "id": "check-certs", "name": "Check SSL Certs", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [700, 300] },
    { "parameters": { "method": "POST", "url": "={{$env.DISCORD_OPS_WEBHOOK}}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ $json.hasWarnings ? JSON.stringify({ content: '🔐 **SSL Certificate Warning**\\n' + $json.checks.filter(c => c.status !== 'ok').map(c => '⚠️ ' + c.domain + ': ' + c.daysLeft + ' days left').join('\\n') }) : JSON.stringify({ content: '🔐 SSL Check OK — All ' + $json.totalDomains + ' domains valid' }) }}" }, "id": "notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 300] }
  ],
  "connections": {
    "Daily Schedule": { "main": [[{ "node": "Fetch Domains", "type": "main", "index": 0 }]] },
    "Fetch Domains": { "main": [[{ "node": "Check SSL Certs", "type": "main", "index": 0 }]] },
    "Check SSL Certs": { "main": [[{ "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
