17 lines
586 B
TypeScript
17 lines
586 B
TypeScript
|
|
import { NextResponse } from 'next/server';
|
||
|
|
|
||
|
|
import { withAuth, withPermission, type RouteHandler } from '@/lib/api/helpers';
|
||
|
|
import { errorResponse } from '@/lib/errors';
|
||
|
|
import { listOwnershipHistory } from '@/lib/services/yachts.service';
|
||
|
|
|
||
|
|
export const historyHandler: RouteHandler = async (req, ctx, params) => {
|
||
|
|
try {
|
||
|
|
const history = await listOwnershipHistory(params.id!, ctx.portId);
|
||
|
|
return NextResponse.json({ data: history });
|
||
|
|
} catch (error) {
|
||
|
|
return errorResponse(error);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
export const GET = withAuth(withPermission('yachts', 'view', historyHandler));
|