From 8897057aa87f9790433978ab5907884ff4ffa13e Mon Sep 17 00:00:00 2001 From: you Date: Thu, 19 Mar 2026 22:49:24 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20move=20bulk-health=20route=20before=20:p?= =?UTF-8?q?ubkey=20wildcard=20=E2=80=94=20Express=20route=20ordering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server.js b/server.js index 249de366..e4d870d4 100644 --- a/server.js +++ b/server.js @@ -1260,13 +1260,7 @@ app.get('/api/traces/:hash', (req, res) => { res.json({ traces }); }); -app.get('/api/nodes/:pubkey/health', (req, res) => { - const health = db.getNodeHealth(req.params.pubkey); - if (!health) return res.status(404).json({ error: 'Not found' }); - res.json(health); -}); - -// Bulk health summary for analytics — single query approach +// Bulk health summary for analytics — single query approach (MUST be before :pubkey routes) app.get('/api/nodes/bulk-health', (req, res) => { const limit = Math.min(Number(req.query.limit) || 50, 200); const nodes = db.db.prepare(`SELECT * FROM nodes ORDER BY last_seen DESC LIMIT ?`).all(limit); @@ -1307,6 +1301,12 @@ app.get('/api/nodes/bulk-health', (req, res) => { res.json(results); }); +app.get('/api/nodes/:pubkey/health', (req, res) => { + const health = db.getNodeHealth(req.params.pubkey); + if (!health) return res.status(404).json({ error: 'Not found' }); + res.json(health); +}); + app.get('/api/nodes/:pubkey/analytics', (req, res) => { const days = Math.min(Math.max(Number(req.query.days) || 7, 1), 365); const data = db.getNodeAnalytics(req.params.pubkey, days);