Skip to content

Commit

Permalink
refactor: Use findUniqueOrThrow instead of guard
Browse files Browse the repository at this point in the history
  • Loading branch information
emrysal committed Oct 1, 2024
1 parent eba8fc7 commit 6f7ebeb
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/features/bookings/lib/handleCancelBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import cancelAttendeeSeat from "./handleSeats/cancel/cancelAttendeeSeat";
const log = logger.getSubLogger({ prefix: ["handleCancelBooking"] });

async function getBookingToDelete(id: number | undefined, uid: string | undefined) {
return await prisma.booking.findUnique({
return await prisma.booking.findUniqueOrThrow({
where: {
id,
uid,
Expand Down Expand Up @@ -172,10 +172,6 @@ async function handler(req: CustomRequest) {
arePlatformEmailsEnabled,
} = req;

if (!bookingToDelete || !bookingToDelete.user) {
throw new HttpError({ statusCode: 400, message: "Booking not found" });
}

if (!bookingToDelete.userId) {
throw new HttpError({ statusCode: 400, message: "User not found" });
}
Expand Down

0 comments on commit 6f7ebeb

Please sign in to comment.