fix(api): resolve /me 500 and revoke not persisting (GRO-206) #161

Closed
groombook-engineer[bot] wants to merge 10 commits from fix/gro-206-superuser-revoke-bug into main
Showing only changes of commit 7523d4cbd9 - Show all commits
+8 -1
View File
@@ -24,8 +24,11 @@ const updateStaffSchema = z.object({
}); });
staffRouter.get("/me", async (c) => { staffRouter.get("/me", async (c) => {
try {
const staffRow = c.get("staff"); const staffRow = c.get("staff");
if (!staffRow) return c.json({ error: "Staff record not found" }, 404); if (!staffRow) {
return c.json({ error: "Staff record not found in context" }, 500);
}
// Explicitly pick serializable fields to avoid BigInt/Date/undefined serialization issues // Explicitly pick serializable fields to avoid BigInt/Date/undefined serialization issues
return c.json({ return c.json({
id: staffRow.id, id: staffRow.id,
@@ -39,6 +42,10 @@ staffRouter.get("/me", async (c) => {
createdAt: staffRow.createdAt, createdAt: staffRow.createdAt,
updatedAt: staffRow.updatedAt, updatedAt: staffRow.updatedAt,
}); });
} catch (err) {
console.error("[/api/staff/me] error:", err, "staffRow:", c.get("staff"));
return c.json({ error: "Internal error", detail: String(err) }, 500);
}
}); });
staffRouter.get("/", async (c) => { staffRouter.get("/", async (c) => {