Skip to content

Commit

Permalink
Refactor DELETE function in listings route to remove unnecessary semi…
Browse files Browse the repository at this point in the history
…colons and improve code readability
  • Loading branch information
GithmiHashara committed Sep 13, 2024
1 parent 9970477 commit 363d970
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/api/listings/[listingId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ 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({
where: {
id: listingId,
userId: currentUser.id
}
});
})

return NextResponse.json(listing); // Return the deleted listing
return NextResponse.json(listing)
}

0 comments on commit 363d970

Please sign in to comment.