src/app/api/blog-likes/route.tsimport { prisma } from '@/utils/prisma'import {getLikeCountFromDb,getLikesBatch,invalidateLike,} from '@/utils/blog-likes'import { NextRequest, NextResponse } from 'next/server'export const runtime = 'nodejs'export const dynamic = 'force-dynamic'export async function POST(request: NextRequest) {try {const { postId, anonId, action } = await request.json()const id = Number(postId)if (!Number.isInteger(id) || id <= 0 || !anonId || (action !== 'like' && action !== 'unlike')) {return NextResponse.json({ error: 'postId (positive int), anonId, and action ("like" | "unlike") are required' },{ status: 400 }
Showing the first 20 lines.
Get full code