From 363d9701c7ccb87deab499a55c794379e15cd116 Mon Sep 17 00:00:00 2001 From: Githmi Hashara Date: Fri, 13 Sep 2024 21:20:30 +0530 Subject: [PATCH] Refactor DELETE function in listings route to remove unnecessary semicolons and improve code readability --- app/api/listings/[listingId]/route.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/api/listings/[listingId]/route.ts b/app/api/listings/[listingId]/route.ts index 3399958..0e53446 100644 --- a/app/api/listings/[listingId]/route.ts +++ b/app/api/listings/[listingId]/route.ts @@ -4,20 +4,20 @@ import getCurrentUser from '@/app/actions/getCurrentUser' import prisma from '@/app/libs/prismadb' interface IParams { - listingId?: string; + listingId?: string } export async function DELETE(request: Request, { params }: { params: IParams }) { - const currentUser = await getCurrentUser(); + const currentUser = await getCurrentUser() if (!currentUser) { - return NextResponse.error(); + return NextResponse.error() } const { listingId } = params if (!listingId || typeof listingId !== 'string') { - throw new Error('Invalid ID'); + throw new Error('Invalid ID') } const listing = await prisma.listing.deleteMany({ @@ -25,7 +25,7 @@ export async function DELETE(request: Request, { params }: { params: IParams }) id: listingId, userId: currentUser.id } - }); + }) - return NextResponse.json(listing); // Return the deleted listing + return NextResponse.json(listing) }