// app/api/stats/route.ts import { NextResponse } from "next/server"; const stats = { views: 0, projectsViewed: {} as { [key: string]: number }, }; export async function GET() { return NextResponse.json(stats); } export async function POST(request: Request) { const { type, projectId } = await request.json(); if (type === "page_view") { stats.views += 1; } if (type === "project_view" && projectId) { if (stats.projectsViewed[projectId]) { stats.projectsViewed[projectId] += 1; } else { stats.projectsViewed[projectId] = 1; } } return NextResponse.json({ message: "Stats updated", stats }); }