mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-08-14 07:50:05 +00:00
fix: move bulk-health route before :pubkey wildcard — Express route ordering
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user