Merge pull request #57 from ianmcorvidae/non-json-traceroutes

Parse traceroute arrays when they don't show up as JSON already
This commit is contained in:
Liam Cottle
2024-08-20 11:34:59 +12:00
committed by GitHub

View File

@ -417,7 +417,12 @@ app.get('/api/v1/nodes/:nodeId/traceroutes', async (req, res) => {
const traceroutes = await prisma.$queryRaw`SELECT * FROM traceroutes WHERE want_response = false and \`to\` = ${node.node_id} and gateway_id is not null order by id desc limit ${count}`; const traceroutes = await prisma.$queryRaw`SELECT * FROM traceroutes WHERE want_response = false and \`to\` = ${node.node_id} and gateway_id is not null order by id desc limit ${count}`;
res.json({ res.json({
traceroutes: traceroutes, traceroutes: traceroutes.map((trace) => {
if (typeof(trace.route) === "string") {
trace.route = JSON.parse(trace.route);
}
return trace;
}),
}); });
} catch(err) { } catch(err) {