fix(build): extract route.ts handlers to handlers.ts (CLAUDE.md convention)

8 API route files were exporting handler functions directly from route.ts,
which Next.js 15 rejects with "$NAME is not a valid Route export field".
Per CLAUDE.md convention, service-tested handler functions live in sibling
handlers.ts files and route.ts only re-exports the GET/POST/etc. wrapped
in withAuth(withPermission(...)).

Discovered during the mobile-foundation Task 24 build validation; the route
files predate this branch but the build was never re-run on data-model.

Files:
- berth-reservations/[id], companies/autocomplete, companies/[id]/members
  + nested mid/set-primary, yachts/autocomplete, yachts/[id]/transfer,
  yachts/[id]/ownership-history
- Integration tests updated to import from handlers.ts (companies,
  memberships, reservations, yachts-detail)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-04-29 15:14:40 +02:00
parent 0e9c24e222
commit d0540dca55
20 changed files with 309 additions and 285 deletions

View File

@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
import { listHandler, createHandler } from '@/app/api/v1/companies/handlers';
import { getHandler, patchHandler, deleteHandler } from '@/app/api/v1/companies/[id]/handlers';
import { autocompleteHandler } from '@/app/api/v1/companies/autocomplete/route';
import { autocompleteHandler } from '@/app/api/v1/companies/autocomplete/handlers';
import { db } from '@/lib/db';
import { companies } from '@/lib/db/schema';
import { eq } from 'drizzle-orm';

View File

@@ -1,9 +1,9 @@
import { describe, it, expect } from 'vitest';
import { eq } from 'drizzle-orm';
import { listHandler, createHandler } from '@/app/api/v1/companies/[id]/members/route';
import { patchHandler, deleteHandler } from '@/app/api/v1/companies/[id]/members/[mid]/route';
import { setPrimaryHandler } from '@/app/api/v1/companies/[id]/members/[mid]/set-primary/route';
import { listHandler, createHandler } from '@/app/api/v1/companies/[id]/members/handlers';
import { patchHandler, deleteHandler } from '@/app/api/v1/companies/[id]/members/[mid]/handlers';
import { setPrimaryHandler } from '@/app/api/v1/companies/[id]/members/[mid]/set-primary/handlers';
import { db } from '@/lib/db';
import { companyMemberships } from '@/lib/db/schema';
import { makeMockCtx, makeMockRequest } from '../../helpers/route-tester';

View File

@@ -9,7 +9,7 @@ import {
getHandler as getReservationHandler,
patchHandler as patchReservationHandler,
deleteHandler as deleteReservationHandler,
} from '@/app/api/v1/berth-reservations/[id]/route';
} from '@/app/api/v1/berth-reservations/[id]/handlers';
import { db } from '@/lib/db';
import { berthReservations } from '@/lib/db/schema/reservations';
import { makeMockCtx, makeMockRequest } from '../../helpers/route-tester';

View File

@@ -1,9 +1,9 @@
import { describe, it, expect } from 'vitest';
import { getHandler, patchHandler, deleteHandler } from '@/app/api/v1/yachts/[id]/handlers';
import { transferHandler } from '@/app/api/v1/yachts/[id]/transfer/route';
import { historyHandler } from '@/app/api/v1/yachts/[id]/ownership-history/route';
import { autocompleteHandler } from '@/app/api/v1/yachts/autocomplete/route';
import { transferHandler } from '@/app/api/v1/yachts/[id]/transfer/handlers';
import { historyHandler } from '@/app/api/v1/yachts/[id]/ownership-history/handlers';
import { autocompleteHandler } from '@/app/api/v1/yachts/autocomplete/handlers';
import { withPermission } from '@/lib/api/helpers';
import { db } from '@/lib/db';
import { yachts } from '@/lib/db/schema';