fix build and pass lint
This commit is contained in:
1 parent
3366627835
commit
5aa0b37443
30 files changed
+193
-74
No files matched your search
@@ -132,7 +132,6 @@ export async function bookingReferenceById(
|
||||
console.log(safeBody.error);
|
||||
res.status(400).json({ message: "Invalid request body", error: safeBody.error });
|
||||
return;
|
||||
// throw new Error("Invalid request body");
|
||||
}
|
||||
await prisma.bookingReference
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -97,17 +97,7 @@ async function createOrlistAllBookingReferences(
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Bad request. BookingReference body is invalid", error: safe.error });
|
||||
return;
|
||||
// throw new Error("Invalid request body");
|
||||
}
|
||||
|
||||
const userWithBookings = await prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
include: { bookings: true },
|
||||
});
|
||||
if (!userWithBookings) {
|
||||
throw new Error("User not found");
|
||||
}
|
||||
const userBookingIds = userWithBookings.bookings.map((booking: { id: number }) => booking.id).flat();
|
||||
if (!safe.data.bookingId) throw new Error("BookingReference: bookingId not found");
|
||||
if (!userBookingIds.includes(safe.data.bookingId)) res.status(401).json({ message: "Unauthorized" });
|
||||
else {
|
||||
|
||||
@@ -106,7 +106,6 @@ export async function bookingById(
|
||||
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({
|
||||
|
||||
@@ -76,7 +76,6 @@ async function createOrlistAllBookings(
|
||||
console.log(safe.error);
|
||||
res.status(400).json({ message: "Bad request. Booking body is invalid." });
|
||||
return;
|
||||
// throw new Error("Invalid request body");
|
||||
}
|
||||
safe.data.userId = userId;
|
||||
const data = await prisma.booking.create({ data: { ...safe.data } });
|
||||
|
||||
@@ -105,7 +105,10 @@ async function eventTypeById(
|
||||
|
||||
case "PATCH":
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.eventTypeCustomInput
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -59,7 +59,10 @@ async function createOrlistAllEventTypeCustomInputs(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaEventTypeCustomInputBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
// Since we're supporting a create or connect relation on eventType, we need to treat them differently
|
||||
// When using connect on event type, check if userId is the owner of the event
|
||||
if (safe.data.eventType.connect && !userEventTypes.includes(safe.data.eventType.connect.id as number)) {
|
||||
|
||||
@@ -121,7 +121,10 @@ export async function destionationCalendarById(
|
||||
*/
|
||||
case "PATCH":
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.destinationCalendar
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -57,7 +57,10 @@ async function createOrlistAllDestinationCalendars(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaDestinationCalendarCreateBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await prisma.destinationCalendar.create({ data: { ...safe.data, userId } });
|
||||
const destination_calendar = schemaDestinationCalendarReadPublic.parse(data);
|
||||
|
||||
@@ -93,7 +93,10 @@ export async function dailyEventReferenceById(
|
||||
*/
|
||||
case "PATCH":
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.dailyEventReference
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -64,7 +64,10 @@ async function createOrlistAllDailyEventReferences(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaDailyEventReferenceCreateBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await prisma.dailyEventReference.create({ data: safe.data });
|
||||
const daily_event_reference = schemaDailyEventReferenceReadPublic.parse(data);
|
||||
|
||||
@@ -91,7 +91,10 @@ export async function eventTypeById(
|
||||
case "PATCH":
|
||||
const safeBody = schemaEventTypeEditBodyParams.safeParse(body);
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.eventType
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -16,6 +16,7 @@ async function createOrlistAllEventTypes(
|
||||
* /event-types:
|
||||
* get:
|
||||
* summary: Find all event types
|
||||
* operationId: listEventTypes
|
||||
* tags:
|
||||
* - event-types
|
||||
* externalDocs:
|
||||
@@ -43,6 +44,32 @@ async function createOrlistAllEventTypes(
|
||||
* /event-types:
|
||||
* post:
|
||||
* summary: Creates a new event type
|
||||
* operationId: addEventType
|
||||
* requestBody:
|
||||
* description: Create a new event-type related to your user or team
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - title
|
||||
* - slug
|
||||
* - length
|
||||
* - metadata
|
||||
* properties:
|
||||
* length:
|
||||
* type: number
|
||||
* example: 30
|
||||
* metadata:
|
||||
* type: object
|
||||
* example: {"smartContractAddress": "0x1234567890123456789012345678901234567890"}
|
||||
* title:
|
||||
* type: string
|
||||
* example: My Event
|
||||
* slug:
|
||||
* type: string
|
||||
* example: my-event
|
||||
* tags:
|
||||
* - event-types
|
||||
* externalDocs:
|
||||
@@ -56,7 +83,10 @@ async function createOrlistAllEventTypes(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaEventTypeCreateBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body", error: safe.error });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await prisma.eventType.create({ data: { ...safe.data, userId } });
|
||||
const event_type = schemaEventTypeReadPublic.parse(data);
|
||||
|
||||
@@ -85,7 +85,10 @@ export async function WebhookById(
|
||||
case "PATCH":
|
||||
const safeBody = schemaWebhookEditBodyParams.safeParse(body);
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.webhook
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -56,7 +56,10 @@ async function createOrlistAllWebhooks(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaWebhookCreateBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await prisma.webhook.create({ data: { ...safe.data, userId } });
|
||||
const webhook = schemaWebhookReadPublic.parse(data);
|
||||
|
||||
@@ -97,7 +97,10 @@ export async function membershipById(
|
||||
case "PATCH":
|
||||
const safeBody = schemaMembershipBodyParams.safeParse(body);
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.membership
|
||||
.update({
|
||||
|
||||
@@ -52,7 +52,10 @@ async function createOrlistAllMemberships(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaMembershipBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await prisma.membership.create({ data: { ...safe.data, userId } });
|
||||
const membership = schemaMembershipPublic.parse(data);
|
||||
|
||||
@@ -83,7 +83,10 @@ export async function scheduleById(
|
||||
*/
|
||||
case "PATCH":
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.schedule
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -54,7 +54,10 @@ async function createOrlistAllSchedules(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaScheduleBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
const data = await prisma.schedule.create({ data: { ...safe.data, userId } });
|
||||
const schedule = schemaSchedulePublic.parse(data);
|
||||
|
||||
|
||||
@@ -115,7 +115,10 @@ export async function selectedCalendarById(
|
||||
*/
|
||||
case "PATCH":
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.selectedCalendar
|
||||
.update({
|
||||
|
||||
@@ -70,7 +70,10 @@ async function createOrlistAllSelectedCalendars(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaSelectedCalendarBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
// Create new selectedCalendar connecting it to current userId
|
||||
const data = await prisma.selectedCalendar.create({
|
||||
data: { ...safe.data, user: { connect: { id: userId } } },
|
||||
|
||||
@@ -102,7 +102,10 @@ export async function teamById(
|
||||
|
||||
case "PATCH":
|
||||
if (!safeBody.success) {
|
||||
throw new Error("Invalid request body");
|
||||
{
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
await prisma.team
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
|
||||
@@ -58,7 +58,10 @@ async function createOrlistAllTeams(
|
||||
* description: Authorization information is missing or invalid.
|
||||
*/
|
||||
const safe = schemaTeamBodyParams.safeParse(body);
|
||||
if (!safe.success) throw new Error("Invalid request body");
|
||||
if (!safe.success) {
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
const team = await prisma.team.create({ data: safe.data });
|
||||
// We're also creating the relation membership of team ownership in this call.
|
||||
const membership = await prisma.membership
|
||||
|
||||
@@ -104,7 +104,7 @@ export async function userById(
|
||||
const safeBody = schemaUserEditBodyParams.safeParse(body);
|
||||
if (!safeBody.success) {
|
||||
res.status(400).json({ message: "Bad request", error: safeBody.error });
|
||||
// throw new Error("Invalid request body");
|
||||
|
||||
return;
|
||||
}
|
||||
const userSchedules = await prisma.schedule.findMany({
|
||||
|
||||
Reference in new issue
Block a user