fix(reports): fix churn query crash and improve error reporting (#51)

The /api/reports/clients endpoint was crashing with a 500 on every request
because a raw JavaScript Date passed into a sql template literal in .having()
cannot be serialized by postgres-js. The fix serializes it as an ISO string
with an explicit ::timestamptz cast.

Also adds reportsRouter.onError() and improves the frontend error message
to surface which specific endpoint failed and why.

Fixes #49
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit was merged in pull request #51.
This commit is contained in:
groombook-paperclip[bot]
2026-03-18 13:36:31 +00:00
committed by GitHub
parent 639429d73d
commit 21c0a7b59c
2 changed files with 22 additions and 2 deletions
+5
View File
@@ -16,6 +16,11 @@ import {
export const reportsRouter = new Hono();
reportsRouter.onError((err, c) => {
console.error("[reports] unhandled error:", err);
return c.json({ error: "Internal server error", message: err.message }, 500);
});
// ─── Helpers ──────────────────────────────────────────────────────────────────
function parseDate(value: string | undefined, fallback: Date): Date {