import { NextRequest, NextResponse } from 'next/server'; import { prisma } from '@/lib/prisma'; import type { TrackShareClickResponse, ApiError } from '@/types/api-types'; export async function POST( request: NextRequest, { params }: { params: Promise<{ token: string }> } ) { try { const { token } = await params; const share = await prisma.share.update({ where: { token }, data: { clickCount: { increment: 1 } }, }); const response: TrackShareClickResponse = { success: true, clickCount: share.clickCount, }; return NextResponse.json(response); } catch (error) { return NextResponse.json({ error: 'Share not found' }, { status: 404 }); } }