Skip to content

Commit 10988ed

Browse files
Add audit stats endpoint and integrate Recharts for dashboard visualizations: Implement a new API route for aggregated audit statistics in the backend, enhance the DashboardHome component to display these stats, and utilize Recharts for visual representation of service availability metrics, improving user insights into platform performance.
1 parent 4fc2ed9 commit 10988ed

8 files changed

Lines changed: 879 additions & 46 deletions

File tree

backend/src/server.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,53 @@ app.get("/api/sla/metrics", async (_req: Request, res: Response) => {
4949
}
5050
});
5151

52+
/** Proxy to Gateway audit stats (aggregated counts for dashboard overview) */
53+
app.get("/api/audit/stats", async (_req: Request, res: Response) => {
54+
try {
55+
const r = await fetch(`${GATEWAY_URL}/api/audit/stats`, { headers: { Accept: "application/json" } });
56+
const text = await r.text();
57+
if (!r.ok) {
58+
try {
59+
return res.status(r.status).json(JSON.parse(text));
60+
} catch {
61+
return res.status(r.status).json({ error: "Gateway error", body: text.slice(0, 200) });
62+
}
63+
}
64+
try {
65+
res.json(JSON.parse(text));
66+
} catch {
67+
res.status(503).json({
68+
error: "Gateway returned invalid response",
69+
totalRequests: 0,
70+
get: 0,
71+
post: 0,
72+
put: 0,
73+
patch: 0,
74+
delete: 0,
75+
other: 0,
76+
granted: 0,
77+
denied: 0,
78+
timestamp: new Date().toISOString(),
79+
});
80+
}
81+
} catch (e) {
82+
console.error("Audit stats proxy error:", e);
83+
res.status(503).json({
84+
error: "Gateway unavailable",
85+
totalRequests: 0,
86+
get: 0,
87+
post: 0,
88+
put: 0,
89+
patch: 0,
90+
delete: 0,
91+
other: 0,
92+
granted: 0,
93+
denied: 0,
94+
timestamp: new Date().toISOString(),
95+
});
96+
}
97+
});
98+
5299
/** Proxy to Gateway request audit log (who requested what, granted/denied) */
53100
app.get("/api/audit/recent", async (req: Request, res: Response) => {
54101
try {

0 commit comments

Comments
 (0)