diff --git a/app/api/v1/ai/usage/route.ts b/app/api/v1/ai/usage/route.ts index 8c709fcbe..f38dead76 100644 --- a/app/api/v1/ai/usage/route.ts +++ b/app/api/v1/ai/usage/route.ts @@ -38,10 +38,8 @@ export async function GET(request: Request) { } catch (err) { return Response.json( { - error: { - message: - err instanceof Error ? err.message : 'Failed to get AI usage', - }, + error: + err instanceof Error ? err.message : 'Failed to get AI usage', }, { status: 500 }, ); diff --git a/app/api/v1/analytics/trends/route.ts b/app/api/v1/analytics/trends/route.ts index dd63541f4..1cb26406c 100644 --- a/app/api/v1/analytics/trends/route.ts +++ b/app/api/v1/analytics/trends/route.ts @@ -24,7 +24,7 @@ export async function GET(request: Request) { if (!from || !to) { return Response.json( - { error: { message: 'from and to query parameters are required' } }, + { error: 'from and to query parameters are required' }, { status: 400 }, ); } @@ -55,11 +55,7 @@ export async function GET(request: Request) { return jsonWithContext(auth.context, { data: snapshots }); } catch (err) { return Response.json( - { - error: { - message: err instanceof Error ? err.message : 'Failed to get trends', - }, - }, + { error: err instanceof Error ? err.message : 'Failed to get trends' }, { status: 500 }, ); } diff --git a/app/api/v1/forms/[formId]/analytics/route.ts b/app/api/v1/forms/[formId]/analytics/route.ts index 6225fd368..91b17756e 100644 --- a/app/api/v1/forms/[formId]/analytics/route.ts +++ b/app/api/v1/forms/[formId]/analytics/route.ts @@ -29,9 +29,7 @@ export async function GET( return jsonWithContext( auth.context, { - error: { - message: 'Form analytics requires a Growth or Enterprise entitlement', - }, + error: 'Form analytics requires a Growth or Enterprise entitlement', }, { status: 403 }, ); @@ -46,10 +44,8 @@ export async function GET( } catch (err) { return Response.json( { - error: { - message: - err instanceof Error ? err.message : 'Failed to get analytics', - }, + error: + err instanceof Error ? err.message : 'Failed to get analytics', }, { status: 500 }, ); diff --git a/app/api/v1/forms/[formId]/duplicate/route.ts b/app/api/v1/forms/[formId]/duplicate/route.ts index 84f5412a2..3b2fb7e66 100644 --- a/app/api/v1/forms/[formId]/duplicate/route.ts +++ b/app/api/v1/forms/[formId]/duplicate/route.ts @@ -31,10 +31,8 @@ export async function POST( } catch (err) { return Response.json( { - error: { - message: - err instanceof Error ? err.message : 'Failed to duplicate form', - }, + error: + err instanceof Error ? err.message : 'Failed to duplicate form', }, { status: 500 }, ); diff --git a/app/api/v1/forms/[formId]/publish/route.ts b/app/api/v1/forms/[formId]/publish/route.ts index cc12764ab..d2f2a4b4c 100644 --- a/app/api/v1/forms/[formId]/publish/route.ts +++ b/app/api/v1/forms/[formId]/publish/route.ts @@ -26,10 +26,8 @@ export async function POST( } catch (err) { return Response.json( { - error: { - message: - err instanceof Error ? err.message : 'Failed to publish form', - }, + error: + err instanceof Error ? err.message : 'Failed to publish form', }, { status: 500 }, ); diff --git a/app/api/v1/forms/[formId]/route.ts b/app/api/v1/forms/[formId]/route.ts index 7a9cd4c45..ebe76b487 100644 --- a/app/api/v1/forms/[formId]/route.ts +++ b/app/api/v1/forms/[formId]/route.ts @@ -27,7 +27,7 @@ export async function GET( return jsonWithContext(auth.context, { data: form }); } catch { return Response.json( - { error: { message: 'Form not found' } }, + { error: 'Form not found' }, { status: 404 }, ); } @@ -65,11 +65,7 @@ export async function PATCH( return jsonWithContext(auth.context, { data: form }); } catch (err) { return Response.json( - { - error: { - message: err instanceof Error ? err.message : 'Failed to update form', - }, - }, + { error: err instanceof Error ? err.message : 'Failed to update form' }, { status: 500 }, ); } @@ -93,7 +89,7 @@ export async function DELETE( return jsonWithContext(auth.context, { data: form }); } catch { return Response.json( - { error: { message: 'Form not found' } }, + { error: 'Form not found' }, { status: 404 }, ); } diff --git a/app/api/v1/forms/[formId]/submissions/[submissionId]/route.ts b/app/api/v1/forms/[formId]/submissions/[submissionId]/route.ts index f35afaf36..326ce5f33 100644 --- a/app/api/v1/forms/[formId]/submissions/[submissionId]/route.ts +++ b/app/api/v1/forms/[formId]/submissions/[submissionId]/route.ts @@ -27,11 +27,7 @@ export async function GET( return jsonWithContext(auth.context, { data: submission }); } catch (err) { return Response.json( - { - error: { - message: err instanceof Error ? err.message : 'Submission not found', - }, - }, + { error: err instanceof Error ? err.message : 'Submission not found' }, { status: 404 }, ); } @@ -53,7 +49,7 @@ export async function PATCH( if (!body.status || !['approved', 'rejected'].includes(body.status)) { return Response.json( - { error: { message: 'status must be "approved" or "rejected"' } }, + { error: 'status must be "approved" or "rejected"' }, { status: 400 }, ); } @@ -70,11 +66,7 @@ export async function PATCH( return jsonWithContext(auth.context, { data: submission }); } catch (err) { return Response.json( - { - error: { - message: err instanceof Error ? err.message : 'Review failed', - }, - }, + { error: err instanceof Error ? err.message : 'Review failed' }, { status: 500 }, ); } diff --git a/app/api/v1/forms/[formId]/submissions/export/route.ts b/app/api/v1/forms/[formId]/submissions/export/route.ts index fe58b4ef8..c0946aca8 100644 --- a/app/api/v1/forms/[formId]/submissions/export/route.ts +++ b/app/api/v1/forms/[formId]/submissions/export/route.ts @@ -54,7 +54,7 @@ export async function GET( if (!isUuid(formId)) { return jsonWithContext( auth.context, - { error: { message: 'Invalid formId' } }, + { error: 'Invalid formId' }, { status: 400 }, ); } @@ -73,7 +73,7 @@ export async function GET( if (formError) { return jsonWithContext( auth.context, - { error: { message: 'Failed to load form for export' } }, + { error: 'Failed to load form for export' }, { status: 500 }, ); } @@ -81,7 +81,7 @@ export async function GET( if (!form) { return jsonWithContext( auth.context, - { error: { message: 'Form not found' } }, + { error: 'Form not found' }, { status: 404 }, ); } @@ -102,7 +102,7 @@ export async function GET( if (submissionsError) { return jsonWithContext( auth.context, - { error: { message: 'Failed to load form submissions for export' } }, + { error: 'Failed to load form submissions for export' }, { status: 500 }, ); } diff --git a/app/api/v1/forms/[formId]/submissions/route.ts b/app/api/v1/forms/[formId]/submissions/route.ts index ca745af0d..d23de4b47 100644 --- a/app/api/v1/forms/[formId]/submissions/route.ts +++ b/app/api/v1/forms/[formId]/submissions/route.ts @@ -48,10 +48,8 @@ export async function GET( } catch (err) { return Response.json( { - error: { - message: - err instanceof Error ? err.message : 'Failed to list submissions', - }, + error: + err instanceof Error ? err.message : 'Failed to list submissions', }, { status: 500 }, ); @@ -90,20 +88,14 @@ export async function POST( if (err instanceof FormValidationError) { return Response.json( { - error: { - message: 'Validation failed', - details: err.validationErrors, - }, + error: 'Validation failed', + details: err.validationErrors, }, { status: 422 }, ); } return Response.json( - { - error: { - message: err instanceof Error ? err.message : 'Submission failed', - }, - }, + { error: err instanceof Error ? err.message : 'Submission failed' }, { status: 500 }, ); } diff --git a/app/api/v1/forms/route.ts b/app/api/v1/forms/route.ts index 6b2d70324..bdeb42e03 100644 --- a/app/api/v1/forms/route.ts +++ b/app/api/v1/forms/route.ts @@ -33,11 +33,7 @@ export async function GET(request: Request) { ); } catch (err) { return Response.json( - { - error: { - message: err instanceof Error ? err.message : 'Failed to list forms', - }, - }, + { error: err instanceof Error ? err.message : 'Failed to list forms' }, { status: 500 }, ); } @@ -60,7 +56,7 @@ export async function POST(request: Request) { if (!title || typeof title !== 'string') { return Response.json( - { error: { message: 'title is required' } }, + { error: 'title is required' }, { status: 400 }, ); } @@ -90,11 +86,7 @@ export async function POST(request: Request) { return Response.json({ data: form }, { status: 201 }); } catch (err) { return Response.json( - { - error: { - message: err instanceof Error ? err.message : 'Failed to create form', - }, - }, + { error: err instanceof Error ? err.message : 'Failed to create form' }, { status: 500 }, ); } diff --git a/app/api/v1/reports/custom/_entitlement.ts b/app/api/v1/reports/custom/_entitlement.ts index 7a578151b..7111f94a1 100644 --- a/app/api/v1/reports/custom/_entitlement.ts +++ b/app/api/v1/reports/custom/_entitlement.ts @@ -17,9 +17,7 @@ export async function requireCustomReportsEntitlement( return jsonWithContext( context, { - error: { - message: 'Custom reports require a Growth or Enterprise entitlement', - }, + error: 'Custom reports require a Growth or Enterprise entitlement', }, { status: 403 }, ); diff --git a/app/api/v1/reports/custom/route.ts b/app/api/v1/reports/custom/route.ts index be6adbc1c..60df31d17 100644 --- a/app/api/v1/reports/custom/route.ts +++ b/app/api/v1/reports/custom/route.ts @@ -35,10 +35,8 @@ export async function GET(request: Request) { } catch (err) { return Response.json( { - error: { - message: - err instanceof Error ? err.message : 'Failed to list reports', - }, + error: + err instanceof Error ? err.message : 'Failed to list reports', }, { status: 500 }, ); @@ -60,7 +58,7 @@ export async function POST(request: Request) { if (!name || typeof name !== 'string') { return Response.json( - { error: { message: 'name is required' } }, + { error: 'name is required' }, { status: 400 }, ); } @@ -83,10 +81,8 @@ export async function POST(request: Request) { } catch (err) { return Response.json( { - error: { - message: - err instanceof Error ? err.message : 'Failed to create report', - }, + error: + err instanceof Error ? err.message : 'Failed to create report', }, { status: 500 }, );