fix: wrap entire invite POST handler in top-level try-catch
Catches errors from the circle_members SELECT query and auth that were escaping the narrower try-catch and returning empty 500s. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3d7ff9adb5
commit
21f88459d7
1 changed files with 19 additions and 19 deletions
|
|
@ -8,6 +8,7 @@ export async function POST(
|
||||||
_req: Request,
|
_req: Request,
|
||||||
{ params }: { params: Promise<{ id: string }> }
|
{ params }: { params: Promise<{ id: string }> }
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
const auth = await requireFamily();
|
const auth = await requireFamily();
|
||||||
if (!auth.success) return NextResponse.json({ error: auth.error }, { status: auth.status });
|
if (!auth.success) return NextResponse.json({ error: auth.error }, { status: auth.status });
|
||||||
|
|
||||||
|
|
@ -27,7 +28,6 @@ export async function POST(
|
||||||
const token = randomBytes(32).toString("hex");
|
const token = randomBytes(32).toString("hex");
|
||||||
const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000); // 7 days
|
const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000); // 7 days
|
||||||
|
|
||||||
try {
|
|
||||||
const [invite] = await sql.unsafe(
|
const [invite] = await sql.unsafe(
|
||||||
`INSERT INTO circle_invites (circle_id, token, created_by, expires_at)
|
`INSERT INTO circle_invites (circle_id, token, created_by, expires_at)
|
||||||
VALUES ($1, $2, $3, $4)
|
VALUES ($1, $2, $3, $4)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue