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>
2026-04-29 15:14:40 +02:00
|
|
|
import { withAuth, withPermission } from '@/lib/api/helpers';
|
2026-04-24 12:55:12 +02:00
|
|
|
|
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>
2026-04-29 15:14:40 +02:00
|
|
|
import { getHandler, patchHandler, deleteHandler } from './handlers';
|
2026-04-24 12:55:12 +02:00
|
|
|
|
|
|
|
|
export const GET = withAuth(withPermission('reservations', 'view', getHandler));
|
|
|
|
|
// PATCH cannot use `withPermission` wrapper — the required permission depends
|
|
|
|
|
// on the `action` field in the body. `requirePermission` is called inside the
|
|
|
|
|
// handler after the body is parsed.
|
|
|
|
|
export const PATCH = withAuth(patchHandler);
|
|
|
|
|
export const DELETE = withAuth(withPermission('reservations', 'cancel', deleteHandler));
|