fix(api): resolve /me 500 and revoke not persisting (GRO-206) #161
@@ -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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user