feat: adds auth/signup for ee customers
This commit is contained in:
1 parent
08eeb36d47
commit
4c131fbcdd
8 files changed
+280
-10
No files matched your search
@@ -64,11 +64,11 @@ export async function bookingReferenceById(
|
||||
* 404:
|
||||
* description: BookingReference was not found
|
||||
*/
|
||||
console.log(safeQuery.data.id);
|
||||
// console.log(safeQuery.data.id);
|
||||
const bookingReference = await prisma.bookingReference.findFirst().catch((error: Error) => {
|
||||
console.log("hoerr:", error);
|
||||
});
|
||||
console.log(bookingReference);
|
||||
// console.log(bookingReference);
|
||||
if (!bookingReference) res.status(404).json({ message: "Booking reference not found" });
|
||||
else res.status(200).json({ booking_reference: bookingReference });
|
||||
|
||||
@@ -92,6 +92,23 @@ export async function bookingReferenceById(
|
||||
* patch:
|
||||
* operationId: editBookingReferenceById
|
||||
* summary: Edit an existing booking reference
|
||||
* requestBody:
|
||||
* description: Edit an existing booking reference related to one of your bookings
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* days:
|
||||
* type: array
|
||||
* example: [email protected]
|
||||
* startTime:
|
||||
* type: string
|
||||
* example: 1970-01-01T17:00:00.000Z
|
||||
* endTime:
|
||||
* type: string
|
||||
* example: 1970-01-01T17:00:00.000Z
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
@@ -112,7 +129,8 @@ export async function bookingReferenceById(
|
||||
|
||||
const safeBody = schemaBookingEditBodyParams.safeParse(body);
|
||||
if (!safeBody.success) {
|
||||
res.status(401).json({ message: "Invalid request body", error: safeBody.error });
|
||||
console.log(safeBody.error);
|
||||
res.status(400).json({ message: "Invalid request body", error: safeBody.error });
|
||||
return;
|
||||
// throw new Error("Invalid request body");
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ export async function bookingById(
|
||||
* /bookings/{id}:
|
||||
* get:
|
||||
* summary: Find a booking
|
||||
* operationId: getBookingById
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
@@ -64,6 +65,24 @@ export async function bookingById(
|
||||
* /bookings/{id}:
|
||||
* patch:
|
||||
* summary: Edit an existing booking
|
||||
* operationId: editBookingById
|
||||
* requestBody:
|
||||
* description: Edit an existing booking related to one of your event-types
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* title:
|
||||
* type: string
|
||||
* example: 15min
|
||||
* startTime:
|
||||
* type: string
|
||||
* example: 1970-01-01T17:00:00.000Z
|
||||
* endTime:
|
||||
* type: string
|
||||
* example: 1970-01-01T17:00:00.000Z
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
@@ -84,14 +103,17 @@ export async function bookingById(
|
||||
case "PATCH":
|
||||
const safeBody = schemaBookingEditBodyParams.safeParse(body);
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
console.log(safeBody.error);
|
||||
res.status(400).json({ message: "Bad request", error: safeBody.error });
|
||||
return;
|
||||
// throw new Error("Invalid request body");
|
||||
}
|
||||
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({
|
||||
@@ -105,6 +127,7 @@ export async function bookingById(
|
||||
* /bookings/{id}:
|
||||
* delete:
|
||||
* summary: Remove an existing booking
|
||||
* operationId: removeBookingById
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
|
||||
@@ -16,6 +16,7 @@ async function createOrlistAllBookings(
|
||||
* /bookings:
|
||||
* get:
|
||||
* summary: Find all bookings
|
||||
* operationId: listBookings
|
||||
* tags:
|
||||
* - bookings
|
||||
* responses:
|
||||
@@ -41,6 +42,24 @@ async function createOrlistAllBookings(
|
||||
* /bookings:
|
||||
* post:
|
||||
* summary: Creates a new booking
|
||||
* operationId: addBooking
|
||||
* requestBody:
|
||||
* description: Edit an existing booking related to one of your event-types
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* title:
|
||||
* type: string
|
||||
* example: 15min
|
||||
* startTime:
|
||||
* type: string
|
||||
* example: 1970-01-01T17:00:00.000Z
|
||||
* endTime:
|
||||
* type: string
|
||||
* example: 1970-01-01T17:00:00.000Z
|
||||
* tags:
|
||||
* - bookings
|
||||
* responses:
|
||||
@@ -52,18 +71,25 @@ async function createOrlistAllBookings(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaBookingCreateBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
console.log(safe.error);
|
||||
res.status(400).json({ message: "Bad request. Booking body is invalid." });
|
||||
return;
|
||||
// throw new Error("Invalid request body");
|
||||
}
|
||||
|
||||
const data = await prisma.booking.create({ data: { ...safe.data, userId } });
|
||||
const booking = schemaBookingReadPublic.parse(data);
|
||||
|
||||
if (booking) res.status(201).json({ booking, message: "Booking created successfully" });
|
||||
else
|
||||
(error: Error) =>
|
||||
(error: Error) => {
|
||||
console.log(error);
|
||||
res.status(400).json({
|
||||
message: "Could not create new booking",
|
||||
error,
|
||||
});
|
||||
};
|
||||
} else res.status(405).json({ message: `Method ${method} not allowed` });
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user