first commit

This commit is contained in:
2026-01-17 14:17:42 +05:30
commit 0f194eb9e7
328 changed files with 73544 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { NextRequest, NextResponse } from "next/server";
import { prisma } from '@/lib/prisma'
export async function GET(request: NextRequest, props: { params: Promise<{ slug: string }> }) {
const params = await props.params;
try {
const product = await prisma.product.findUnique({
where: {
slug: params.slug,
isActive: true
},
include: {
category: {
select: {
id: true,
name: true
}
}
},
})
if (!product) {
return NextResponse.json(
{ error: 'Product not found' },
{ status: 404 }
)
}
return NextResponse.json(product)
} catch (error) {
console.error('Error fetching product by slug:', error)
return NextResponse.json(
{ error: 'Failed to fetch product' },
{ status: 500 }
)
}
}