fix(api): add 404 guard when logo confirm returns no rows
The returning() on the update query can produce undefined when zero rows match. Added explicit 404 if updated is falsy. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -132,6 +132,10 @@ settingsRouter.post(
|
|||||||
.where(eq(businessSettings.id, settingsId))
|
.where(eq(businessSettings.id, settingsId))
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
|
if (!updated) {
|
||||||
|
return c.json({ error: "Settings not found" }, 404);
|
||||||
|
}
|
||||||
|
|
||||||
return c.json({ ok: true, logoKey: updated.logoKey });
|
return c.json({ ok: true, logoKey: updated.logoKey });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user