From a90adb5b522daf300f5e8255ec9437eb4b6ebd0d Mon Sep 17 00:00:00 2001 From: Wild Dragon Dev Date: Thu, 4 Jun 2026 01:40:44 +0000 Subject: [PATCH] feat(node-agent): add /containers and /sidecar/:id/logs endpoints --- services/node-agent/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/services/node-agent/index.js b/services/node-agent/index.js index 958a248..2201ca6 100644 --- a/services/node-agent/index.js +++ b/services/node-agent/index.js @@ -856,6 +856,15 @@ async function handleSidecarStop(containerId, res) { } } +async function handleSidecarLogs(containerId, res) { + try { + const logs = await fetchContainerLogs(containerId); + jsonResponse(res, 200, { logs: logs || '(no logs)' }); + } catch (err) { + jsonResponse(res, 500, { error: err.message }); + } +} + async function handleSidecarStatus(containerId, res) { try { const inspectRes = await dockerApi('GET', `/containers/${containerId}/json`); @@ -1458,6 +1467,15 @@ const server = http.createServer((req, res) => { const id = pathname.slice('/sidecar/'.length, -'/status'.length); handleSidecarStatus(id, res); + } else if (req.method === 'GET' && pathname === '/containers') { + if (!checkAgentAuth(req)) return jsonResponse(res, 401, { error: 'Unauthorized' }); + const cRes = await dockerApi('GET', '/containers/json?all=true'); + jsonResponse(res, cRes.status, cRes.data); + + } else if (req.method === 'GET' && /^\/sidecar\/[^/]+\/logs$/.test(pathname)) { + const id = pathname.slice('/sidecar/'.length, -'/logs'.length); + handleSidecarLogs(id, res); + } else if (req.method === 'GET' && pathname === '/driver/status') { if (!checkAgentAuth(req)) return jsonResponse(res, 401, { error: 'Unauthorized' }); handleDriverStatus(res);