import { NextResponse } from "next/server";
import { getVisitorCount, incrementVisitorCount } from "@/lib/visitorTracking";

export const dynamic = "force-dynamic";

export async function GET() {
  try {
    const count = await getVisitorCount();
    return NextResponse.json({ success: true, count });
  } catch (error) {
    return NextResponse.json({ success: true, count: 74790 });
  }
}

export async function POST(req: Request) {
  try {
    const count = await incrementVisitorCount(1);
    return NextResponse.json({ success: true, count });
  } catch (error) {
    return NextResponse.json({ success: true, count: 74790 });
  }
}
