Files
valknarandClaude Sonnet 5 9e0380ec75
CI / Build and push image (push) Successful in 1m10s
CI / Static checks (push) Successful in 1m39s
Add consistent API request logging and a themed 404 page, bump to 0.4.0
Every app/api route handler now goes through withRouteLogging, which logs
a correlated reqId/method/path/status/duration for each request and turns
any uncaught error into a logged stack trace plus a clean JSON 500 instead
of Next's default opaque failure. proxy.ts logs rejected auth attempts, and
instrumentation.ts's onRequestError catches anything that still escapes a
route handler. Also adds a minimal not-found page matching the app's card
styling.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-26 08:45:15 +02:00

11 lines
612 B
TypeScript

import { NextResponse } from "next/server";
import { getDeviceCommandCounts, getDeviceUsageStats } from "@/lib/db/queries/stats";
import { withRouteLogging } from "@/lib/api/with-route-logging";
export const GET = withRouteLogging("stats.devices", async () => {
const [usage, commandCounts] = await Promise.all([getDeviceUsageStats(), getDeviceCommandCounts()]);
const commandCountByDevice = new Map(commandCounts.map((c) => [c.deviceId, c.commandCount]));
const devices = usage.map((d) => ({ ...d, commandCount: commandCountByDevice.get(d.deviceId) ?? 0 }));
return NextResponse.json({ devices });
});