From 5efc7b57bd45d7893e086268bb4015db8c355cd4 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 17 Dec 2024 16:57:47 +1300 Subject: [PATCH] add params to api docs --- src/index.js | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 888f99a..61bd055 100644 --- a/src/index.js +++ b/src/index.js @@ -93,6 +93,10 @@ app.get('/api', async (req, res) => { { "path": "/api/v1/nodes", "description": "All meshtastic nodes", + "params": { + "role": "Filter by role", + "hardware_model": "Filter by hardware model", + }, }, { "path": "/api/v1/nodes/:nodeId", @@ -101,14 +105,29 @@ app.get('/api', async (req, res) => { { "path": "/api/v1/nodes/:nodeId/device-metrics", "description": "Device metrics for a meshtastic node", + "params": { + "count": "How many results to return", + "time_from": "Only include metrics created after this unix timestamp (milliseconds)", + "time_to": "Only include metrics created before this unix timestamp (milliseconds)", + }, }, { "path": "/api/v1/nodes/:nodeId/environment-metrics", "description": "Environment metrics for a meshtastic node", + "params": { + "count": "How many results to return", + "time_from": "Only include metrics created after this unix timestamp (milliseconds)", + "time_to": "Only include metrics created before this unix timestamp (milliseconds)", + }, }, { "path": "/api/v1/nodes/:nodeId/power-metrics", "description": "Power metrics for a meshtastic node", + "params": { + "count": "How many results to return", + "time_from": "Only include metrics created after this unix timestamp (milliseconds)", + "time_to": "Only include metrics created before this unix timestamp (milliseconds)", + }, }, { "path": "/api/v1/nodes/:nodeId/neighbours", @@ -121,6 +140,10 @@ app.get('/api', async (req, res) => { { "path": "/api/v1/nodes/:nodeId/position-history", "description": "Position history for a meshtastic node", + "params": { + "time_from": "Only include positions created after this unix timestamp (milliseconds)", + "time_to": "Only include positions created before this unix timestamp (milliseconds)", + }, }, { "path": "/api/v1/stats/hardware-models", @@ -129,6 +152,15 @@ app.get('/api', async (req, res) => { { "path": "/api/v1/text-messages", "description": "Text messages", + "params": { + "to": "Only include messages to this node id", + "from": "Only include messages from this node id", + "channel_id": "Only include messages for this channel id", + "gateway_id": "Only include messages gated to mqtt by this node id", + "last_id": "Only include messages before or after this id, based on results order", + "count": "How many results to return", + "order": "Order to return results in: asc, desc", + }, }, { "path": "/api/v1/text-messages/embed", @@ -140,11 +172,21 @@ app.get('/api', async (req, res) => { }, ]; - const html = links.map((link) => { - return `
  • ${link.path} - ${link.description}
  • `; + const linksHtml = links.map((link) => { + var line = `
  • `; + line += `${link.path} - ${link.description}`; + line += ``; + return line; }).join(""); - res.send(html); + res.send(`API Docs
    `); });