File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,12 +16,7 @@ export async function POST(req: Request) {
1616 return NextResponse . json ( { error : "Too many requests" } , { status : 429 } ) ;
1717 }
1818
19- let body : unknown ;
20- try {
21- body = await req . json ( ) ;
22- } catch {
23- return NextResponse . json ( { error : "Invalid JSON" } , { status : 400 } ) ;
24- }
19+ const body = await req . json ( ) ;
2520
2621 const parsed = CreateOrderSchema . safeParse ( body ) ;
2722 if ( ! parsed . success ) {
@@ -34,7 +29,7 @@ export async function POST(req: Request) {
3429 const { productId, quantity, couponCode } = parsed . data ;
3530
3631 const product = await db . product . findUnique ( { where : { id : productId } } ) ;
37- if ( ! product || product . stock < quantity ) {
32+ if ( ! product ) {
3833 return NextResponse . json ( { error : "Out of stock" } , { status : 409 } ) ;
3934 }
4035
You can’t perform that action at this time.
0 commit comments