From 6b09fb24ab5d09efba0953f6458f6bc72631c2f7 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 8 Jul 2022 17:23:06 +0200 Subject: [PATCH] fix: adds returns, no breaks --- pages/api/bookings/[id].ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pages/api/bookings/[id].ts b/pages/api/bookings/[id].ts index 6897cb0464..f24a90bad0 100644 --- a/pages/api/bookings/[id].ts +++ b/pages/api/bookings/[id].ts @@ -62,7 +62,6 @@ export async function bookingById( error, }) ); - break; /** * @swagger * /bookings/{id}: @@ -110,12 +109,12 @@ export async function bookingById( res.status(400).json({ message: "Bad request", error: safeBody.error }); return; } - await prisma.booking + return await prisma.booking .update({ where: { id: safeQuery.data.id }, data: safeBody.data, }) - // .then((data) => schemaBookingReadPublic.parse(data)) + .then((data) => schemaBookingReadPublic.parse(data)) .then((booking) => res.status(200).json({ booking })) .catch((error: Error) => res.status(404).json({ @@ -123,7 +122,6 @@ export async function bookingById( error, }) ); - break; /** * @swagger * /bookings/{id}: @@ -148,7 +146,7 @@ export async function bookingById( * description: Authorization information is missing or invalid. */ case "DELETE": - await prisma.booking + return await prisma.booking .delete({ where: { id: safeQuery.data.id } }) .then(() => res.status(200).json({ @@ -161,13 +159,11 @@ export async function bookingById( error, }) ); - break; default: - res.status(405).json({ message: "Method not allowed" }); - break; + return res.status(405).json({ message: "Method not allowed" }); } } } -export default withMiddleware("HTTP_GET_DELETE_PATCH")(bookingById); +export default withMiddleware("HTTP_GET_DELETE_PATCH")(withValidQueryIdTransformParseInt(bookingById));