fix(api): add error handling to /api/staff/me endpoint

Wrap c.json() in try/catch to surface serialization errors rather
than crashing silently. Also guard against null staff context.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
groombook-ci[bot]
2026-03-29 14:05:52 +00:00
parent 7a0a97aea3
commit 1bd30807fb
+9 -1
View File
@@ -25,7 +25,15 @@ const updateStaffSchema = z.object({
staffRouter.get("/me", async (c) => {
const staffRow = c.get("staff");
return c.json(staffRow);
if (!staffRow) {
return c.json({ error: "Staff record not found in context" }, 500);
}
try {
return c.json(staffRow);
} catch (err) {
console.error("[/api/staff/me] serialization error:", err, "staffRow:", staffRow);
return c.json({ error: "Serialization error", detail: String(err) }, 500);
}
});
staffRouter.get("/", async (c) => {