From 70544cf05544effee315c319f42c2a84d369098c Mon Sep 17 00:00:00 2001 From: qweliant Date: Tue, 22 Aug 2023 21:54:07 -0400 Subject: [PATCH 1/8] create update pub function in contract. TODO: fix updaate --- core/lib/contracts/resources/pub.ts | 13 +++++++++++++ core/lib/server/index.ts | 4 ++-- core/lib/server/pub.ts | 13 +++++++++++++ core/pages/api/[...ts-rest].ts | 9 ++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/core/lib/contracts/resources/pub.ts b/core/lib/contracts/resources/pub.ts index 5382e7b782..d87eb08d2c 100644 --- a/core/lib/contracts/resources/pub.ts +++ b/core/lib/contracts/resources/pub.ts @@ -8,6 +8,19 @@ const PubFieldsSchema = z.any(); export type PubFieldsResponse = z.infer; export const pubApi = contract.router({ + createPubFields: { + method: "POST", + path: "/:instanceId/pub", + summary: "Creates a new pub", + description: "A way to create a new pub", + body: PubFieldsSchema, + pathParams: z.object({ + instanceId: z.string(), + }), + responses: { + 200: PubFieldsSchema, + }, + }, getPubFields: { method: "GET", path: "/:instanceId/pub/:pubId", diff --git a/core/lib/server/index.ts b/core/lib/server/index.ts index 9f16e4eeca..8d89357f2e 100644 --- a/core/lib/server/index.ts +++ b/core/lib/server/index.ts @@ -1,4 +1,4 @@ -import { getPub, updatePub } from "./pub"; +import { createPub, getPub, updatePub } from "./pub"; import { getMembers } from "./autosuggest"; -export { getPub, updatePub, getMembers }; +export { createPub, getPub, updatePub, getMembers }; diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index 43a08a7e3b..779a043051 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -22,6 +22,19 @@ export const getPubFields = async (pubId: string) => { }, {}); }; +export const createPub = async (fields: any) => { + const pub = await prisma.pub.create({ + data: { + values: { + createMany: { + data: fields, + }, + }, + }, + }); + return pub; +}; + export const getPub = async (pubId: string) => { const pub = await getPubFields(pubId); return pub; diff --git a/core/pages/api/[...ts-rest].ts b/core/pages/api/[...ts-rest].ts index 53cad34d2d..d0b40e9184 100644 --- a/core/pages/api/[...ts-rest].ts +++ b/core/pages/api/[...ts-rest].ts @@ -1,9 +1,16 @@ import { createNextRoute, createNextRouter } from "@ts-rest/next"; import { api } from "~/lib/contracts"; -import { getPub, getMembers, updatePub } from "~/lib/server"; +import { getPub, getMembers, updatePub, createPub } from "~/lib/server"; // TODOD: verify pub belongs to integrationInstance const pubRouter = createNextRoute(api.pub, { + createPubFields: async ({ params }) => { + const pub = await createPub(params.instanceId); + return { + status: 200, + body: pub, + }; + }, getPubFields: async ({ params }) => { const pubFieldValuePairs = await getPub(params.pubId); return { From bebd7e43f2def29c0a5425e43a6b88a924f4ce28 Mon Sep 17 00:00:00 2001 From: qweliant Date: Tue, 22 Aug 2023 22:01:42 -0400 Subject: [PATCH 2/8] update pub method to return string, rebase so i can see doc --- core/lib/server/pub.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index 779a043051..ec9a6bc6ae 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -23,7 +23,7 @@ export const getPubFields = async (pubId: string) => { }; export const createPub = async (fields: any) => { - const pub = await prisma.pub.create({ + const pub =` await prisma.pub.create({ data: { values: { createMany: { @@ -31,7 +31,7 @@ export const createPub = async (fields: any) => { }, }, }, - }); + });` return pub; }; From e163bb0109ac0850fd69ba58571605a416c2c6d0 Mon Sep 17 00:00:00 2001 From: qweliant Date: Wed, 23 Aug 2023 10:36:21 -0400 Subject: [PATCH 3/8] commit for rebase --- core/lib/server/pub.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index ec9a6bc6ae..779a043051 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -23,7 +23,7 @@ export const getPubFields = async (pubId: string) => { }; export const createPub = async (fields: any) => { - const pub =` await prisma.pub.create({ + const pub = await prisma.pub.create({ data: { values: { createMany: { @@ -31,7 +31,7 @@ export const createPub = async (fields: any) => { }, }, }, - });` + }); return pub; }; From 2f100501e694db9202faa2a94d91f6d2da566204 Mon Sep 17 00:00:00 2001 From: qweliant Date: Wed, 23 Aug 2023 13:21:16 -0400 Subject: [PATCH 4/8] figure out pubType where --- core/lib/contracts/resources/pub.ts | 7 +++- core/lib/server/pub.ts | 60 ++++++++++++++++++++++++----- core/pages/api/[...ts-rest].ts | 4 +- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/core/lib/contracts/resources/pub.ts b/core/lib/contracts/resources/pub.ts index d87eb08d2c..f4ee10edf8 100644 --- a/core/lib/contracts/resources/pub.ts +++ b/core/lib/contracts/resources/pub.ts @@ -4,8 +4,13 @@ import { initContract } from "@ts-rest/core"; const contract = initContract(); const PubFieldsSchema = z.any(); +const PubPostSchema = z.object({ + pubTypeName: z.string(), + pubFieldValues: PubFieldsSchema, +}); export type PubFieldsResponse = z.infer; +export type PubPostBody = z.infer; export const pubApi = contract.router({ createPubFields: { @@ -13,7 +18,7 @@ export const pubApi = contract.router({ path: "/:instanceId/pub", summary: "Creates a new pub", description: "A way to create a new pub", - body: PubFieldsSchema, + body: PubPostSchema, pathParams: z.object({ instanceId: z.string(), }), diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index 779a043051..585bea34a2 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -1,4 +1,5 @@ import prisma from "~/prisma/db"; +import { PubPostBody } from "~/lib/contracts/resources/pub"; export const getPubFields = async (pubId: string) => { const fields = await prisma.pubValue.findMany({ @@ -22,17 +23,58 @@ export const getPubFields = async (pubId: string) => { }, {}); }; -export const createPub = async (fields: any) => { - const pub = await prisma.pub.create({ - data: { - values: { - createMany: { - data: fields, - }, - }, +export const createPub = async (instanceId: string, body: PubPostBody) => { + console.log(body); + const { pubTypeName, pubFieldValues } = body; + + // query instance for communityId + const instance = await prisma.integrationInstance.findUnique({ + where: { id: instanceId }, + select: { + communityId: true, }, }); - return pub; + + if (!instance) { + throw new Error("Community not found"); + } + + console.log(instance.communityId); + + const { communityId } = instance; + + // query pubType for fields using the pubType name and community id from body + const pubType = await prisma.pubType.findFirst({ + where: { name: pubTypeName, communityId }, + select: { + fields: true, + }, + }); + + console.log(pubType); + + if (!pubType) { + throw new Error("Pub Type not found"); + } + + const { fields } = pubType; + + console.log(fields, pubFieldValues); + + // map field Ids to field values + + // create pub + // const pub = await prisma.pub.create({ + // data: { + // communityId: communityIdFromInstance.communityId, + // values: { + // createMany: { + // data: fields, + // }, + // }, + // }, + // }); + return "pub"; }; export const getPub = async (pubId: string) => { diff --git a/core/pages/api/[...ts-rest].ts b/core/pages/api/[...ts-rest].ts index d0b40e9184..32d8a0f50f 100644 --- a/core/pages/api/[...ts-rest].ts +++ b/core/pages/api/[...ts-rest].ts @@ -4,8 +4,8 @@ import { getPub, getMembers, updatePub, createPub } from "~/lib/server"; // TODOD: verify pub belongs to integrationInstance const pubRouter = createNextRoute(api.pub, { - createPubFields: async ({ params }) => { - const pub = await createPub(params.instanceId); + createPubFields: async ({ params, body }) => { + const pub = await createPub(params.instanceId, body); return { status: 200, body: pub, From 11d33018ec5bca347a8b624bdff32076af902455 Mon Sep 17 00:00:00 2001 From: qweliant Date: Wed, 23 Aug 2023 14:43:35 -0400 Subject: [PATCH 5/8] update pub crud --- core/lib/contracts/resources/pub.ts | 9 +-- core/lib/server/pub.ts | 93 ++++++++++++++--------------- core/pages/api/[...ts-rest].ts | 2 +- 3 files changed, 50 insertions(+), 54 deletions(-) diff --git a/core/lib/contracts/resources/pub.ts b/core/lib/contracts/resources/pub.ts index f4ee10edf8..b7afd43295 100644 --- a/core/lib/contracts/resources/pub.ts +++ b/core/lib/contracts/resources/pub.ts @@ -4,9 +4,10 @@ import { initContract } from "@ts-rest/core"; const contract = initContract(); const PubFieldsSchema = z.any(); + const PubPostSchema = z.object({ - pubTypeName: z.string(), - pubFieldValues: PubFieldsSchema, + pubTypeId: z.string(), + pubFields: PubFieldsSchema, }); export type PubFieldsResponse = z.infer; @@ -39,11 +40,11 @@ export const pubApi = contract.router({ 200: z.array(PubFieldsSchema), }, }, - putPubFields: { + patchPubFields: { method: "PATCH", path: "/:instanceId/pub/:pubId", summary: "Adds field(s) to a pub", - description: "A way to add a field to an existing pub", + description: "A way to update a field for an existing pub", body: PubFieldsSchema, pathParams: z.object({ pubId: z.string(), diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index 585bea34a2..62ef2412a9 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -23,11 +23,34 @@ export const getPubFields = async (pubId: string) => { }, {}); }; +const getPubValues = async (pubFields: any) => { + const fieldNames = Object.keys(pubFields); + + const fieldIds = await prisma.pubField.findMany({ + where: { + name: { + in: fieldNames, + }, + }, + select: { + id: true, + name: true, + }, + }); + + const values = fieldIds.map((field) => { + return { + fieldId: field.id, + value: pubFields[field.name], + }; + }); + + return values; +}; + export const createPub = async (instanceId: string, body: PubPostBody) => { - console.log(body); - const { pubTypeName, pubFieldValues } = body; + const { pubTypeId, pubFields } = body; - // query instance for communityId const instance = await prisma.integrationInstance.findUnique({ where: { id: instanceId }, select: { @@ -39,42 +62,32 @@ export const createPub = async (instanceId: string, body: PubPostBody) => { throw new Error("Community not found"); } - console.log(instance.communityId); - - const { communityId } = instance; - - // query pubType for fields using the pubType name and community id from body const pubType = await prisma.pubType.findFirst({ - where: { name: pubTypeName, communityId }, + where: { id: pubTypeId }, select: { - fields: true, + id: true, }, }); - console.log(pubType); - if (!pubType) { throw new Error("Pub Type not found"); } - const { fields } = pubType; - - console.log(fields, pubFieldValues); + const newValues = await getPubValues(pubFields); - // map field Ids to field values + const pub = await prisma.pub.create({ + data: { + pubTypeId: pubType.id, + communityId: instance.communityId, + values: { + createMany: { + data: newValues, + }, + }, + }, + }); - // create pub - // const pub = await prisma.pub.create({ - // data: { - // communityId: communityIdFromInstance.communityId, - // values: { - // createMany: { - // data: fields, - // }, - // }, - // }, - // }); - return "pub"; + return pub; }; export const getPub = async (pubId: string) => { @@ -82,27 +95,9 @@ export const getPub = async (pubId: string) => { return pub; }; -export const updatePub = async (pubId: string, fields: any) => { - const fieldNames = Object.keys(fields); - - const fieldIds = await prisma.pubField.findMany({ - where: { - name: { - in: fieldNames, - }, - }, - select: { - id: true, - name: true, - }, - }); - - const newValues = fieldIds.map((field) => { - return { - fieldId: field.id, - value: fields[field.name], - }; - }); +export const updatePub = async (pubId: string, pubFields: any) => { + console.log("pubFields", pubFields); + const newValues = await getPubValues(pubFields); await prisma.pub.update({ where: { id: pubId }, diff --git a/core/pages/api/[...ts-rest].ts b/core/pages/api/[...ts-rest].ts index 32d8a0f50f..8324874490 100644 --- a/core/pages/api/[...ts-rest].ts +++ b/core/pages/api/[...ts-rest].ts @@ -18,7 +18,7 @@ const pubRouter = createNextRoute(api.pub, { body: pubFieldValuePairs, }; }, - putPubFields: async ({ params, body }) => { + patchPubFields: async ({ params, body }) => { const updatedPub = await updatePub(params.pubId, body); return { status: 200, From c124beb9492e56b6be24274493e8b446b947f9d5 Mon Sep 17 00:00:00 2001 From: qweliant Date: Wed, 23 Aug 2023 14:44:10 -0400 Subject: [PATCH 6/8] rmv log --- core/lib/server/pub.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index 62ef2412a9..f1c4fb2b82 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -96,7 +96,6 @@ export const getPub = async (pubId: string) => { }; export const updatePub = async (pubId: string, pubFields: any) => { - console.log("pubFields", pubFields); const newValues = await getPubValues(pubFields); await prisma.pub.update({ From 84795769ea7f185fd32b90e7ea9e02d8f5f1283c Mon Sep 17 00:00:00 2001 From: qweliant Date: Tue, 29 Aug 2023 14:04:18 -0400 Subject: [PATCH 7/8] add err handling nd remove err --- core/lib/contracts/resources/pub.ts | 7 +- core/lib/server/pub.ts | 101 ++++++++++++++++++---------- core/pages/api/[...ts-rest].ts | 23 ++++--- 3 files changed, 83 insertions(+), 48 deletions(-) diff --git a/core/lib/contracts/resources/pub.ts b/core/lib/contracts/resources/pub.ts index b7afd43295..3ba946b1fd 100644 --- a/core/lib/contracts/resources/pub.ts +++ b/core/lib/contracts/resources/pub.ts @@ -14,7 +14,7 @@ export type PubFieldsResponse = z.infer; export type PubPostBody = z.infer; export const pubApi = contract.router({ - createPubFields: { + createPub: { method: "POST", path: "/:instanceId/pub", summary: "Creates a new pub", @@ -25,9 +25,10 @@ export const pubApi = contract.router({ }), responses: { 200: PubFieldsSchema, + 404: z.object({ message: z.string() }), }, }, - getPubFields: { + getPub: { method: "GET", path: "/:instanceId/pub/:pubId", summary: "Get all pubs", @@ -40,7 +41,7 @@ export const pubApi = contract.router({ 200: z.array(PubFieldsSchema), }, }, - patchPubFields: { + updatePub: { method: "PATCH", path: "/:instanceId/pub/:pubId", summary: "Adds field(s) to a pub", diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index f1c4fb2b82..09bf9991ed 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -23,20 +23,36 @@ export const getPubFields = async (pubId: string) => { }, {}); }; -const getPubValues = async (pubFields: any) => { +// 404 errors +const InstanceNotFoundError = new Error("Integration instance not found"); +const PubTypeNotFoundError = new Error("PubType not found"); +const PubNotFoundError = new Error("Pub not found"); +const PubFieldNamesNotFoundError = new Error("Pub fields not found"); + +const getPubValues = async (pubFields: any, pubTypeId?: string) => { const fieldNames = Object.keys(pubFields); - const fieldIds = await prisma.pubField.findMany({ - where: { - name: { - in: fieldNames, + let fieldIds; + try { + fieldIds = await prisma.pubField.findMany({ + where: { + name: { + in: fieldNames, + }, + pubTypes: { + some: { + id: pubTypeId, + }, + }, }, - }, - select: { - id: true, - name: true, - }, - }); + }); + } catch (error) { + throw error; + } + + if (!fieldIds) { + throw PubFieldNamesNotFoundError; + } const values = fieldIds.map((field) => { return { @@ -51,41 +67,54 @@ const getPubValues = async (pubFields: any) => { export const createPub = async (instanceId: string, body: PubPostBody) => { const { pubTypeId, pubFields } = body; - const instance = await prisma.integrationInstance.findUnique({ - where: { id: instanceId }, - select: { - communityId: true, - }, - }); + let instance; + let pubType; + try { + instance = await prisma.integrationInstance.findUnique({ + where: { id: instanceId }, + }); + } catch (error) { + throw error; + } if (!instance) { - throw new Error("Community not found"); + throw InstanceNotFoundError; } - const pubType = await prisma.pubType.findFirst({ - where: { id: pubTypeId }, - select: { - id: true, - }, - }); + try { + pubType = await prisma.pubType.findUnique({ + where: { id: pubTypeId }, + }); + } catch (error) { + throw error; + } if (!pubType) { - throw new Error("Pub Type not found"); + throw PubTypeNotFoundError; } - const newValues = await getPubValues(pubFields); - - const pub = await prisma.pub.create({ - data: { - pubTypeId: pubType.id, - communityId: instance.communityId, - values: { - createMany: { - data: newValues, + const pubValues = await getPubValues(pubFields, pubType.id); + + let pub; + try { + pub = await prisma.pub.create({ + data: { + pubTypeId: pubType.id, + communityId: instance.communityId, + values: { + createMany: { + data: pubValues, + }, }, }, - }, - }); + }); + } catch (error) { + throw error; + } + + if (!pub) { + throw PubNotFoundError; + } return pub; }; diff --git a/core/pages/api/[...ts-rest].ts b/core/pages/api/[...ts-rest].ts index 8324874490..d52d25fa2f 100644 --- a/core/pages/api/[...ts-rest].ts +++ b/core/pages/api/[...ts-rest].ts @@ -2,23 +2,28 @@ import { createNextRoute, createNextRouter } from "@ts-rest/next"; import { api } from "~/lib/contracts"; import { getPub, getMembers, updatePub, createPub } from "~/lib/server"; -// TODOD: verify pub belongs to integrationInstance +// TODO: verify pub belongs to integrationInstance const pubRouter = createNextRoute(api.pub, { - createPubFields: async ({ params, body }) => { - const pub = await createPub(params.instanceId, body); - return { - status: 200, - body: pub, - }; + createPub: async ({ params, body }) => { + let pub; + try { + pub = await createPub(params.instanceId, body); + return { status: 200, body: pub }; + } catch (error) { + return { + status: 404, + body: { message: error.message }, + }; + } }, - getPubFields: async ({ params }) => { + getPub: async ({ params }) => { const pubFieldValuePairs = await getPub(params.pubId); return { status: 200, body: pubFieldValuePairs, }; }, - patchPubFields: async ({ params, body }) => { + updatePub: async ({ params, body }) => { const updatedPub = await updatePub(params.pubId, body); return { status: 200, From f6c18065c2e9c6aa6e4fa5f0d56342ebd43a7f93 Mon Sep 17 00:00:00 2001 From: qweliant Date: Tue, 29 Aug 2023 15:36:07 -0400 Subject: [PATCH 8/8] use promise.all reduce try/catches --- core/lib/server/index.ts | 6 +-- core/lib/server/pub.ts | 82 +++++++++++++--------------------- core/pages/api/[...ts-rest].ts | 15 ++++--- 3 files changed, 44 insertions(+), 59 deletions(-) diff --git a/core/lib/server/index.ts b/core/lib/server/index.ts index 8d89357f2e..6d56b77160 100644 --- a/core/lib/server/index.ts +++ b/core/lib/server/index.ts @@ -1,4 +1,2 @@ -import { createPub, getPub, updatePub } from "./pub"; -import { getMembers } from "./autosuggest"; - -export { createPub, getPub, updatePub, getMembers }; +export * from "./pub"; +export * from "./autosuggest"; diff --git a/core/lib/server/pub.ts b/core/lib/server/pub.ts index 09bf9991ed..85df7404ae 100644 --- a/core/lib/server/pub.ts +++ b/core/lib/server/pub.ts @@ -23,32 +23,28 @@ export const getPubFields = async (pubId: string) => { }, {}); }; -// 404 errors -const InstanceNotFoundError = new Error("Integration instance not found"); -const PubTypeNotFoundError = new Error("PubType not found"); -const PubNotFoundError = new Error("Pub not found"); -const PubFieldNamesNotFoundError = new Error("Pub fields not found"); +export class NotFoundError extends Error {} + +const InstanceNotFoundError = new NotFoundError("Integration instance not found"); +const PubTypeNotFoundError = new NotFoundError("PubType not found"); +const PubNotFoundError = new NotFoundError("Pub not found"); +const PubFieldNamesNotFoundError = new NotFoundError("Pub fields not found"); const getPubValues = async (pubFields: any, pubTypeId?: string) => { const fieldNames = Object.keys(pubFields); - let fieldIds; - try { - fieldIds = await prisma.pubField.findMany({ - where: { - name: { - in: fieldNames, - }, - pubTypes: { - some: { - id: pubTypeId, - }, + const fieldIds = await prisma.pubField.findMany({ + where: { + name: { + in: fieldNames, + }, + pubTypes: { + some: { + id: pubTypeId, }, }, - }); - } catch (error) { - throw error; - } + }, + }); if (!fieldIds) { throw PubFieldNamesNotFoundError; @@ -67,50 +63,36 @@ const getPubValues = async (pubFields: any, pubTypeId?: string) => { export const createPub = async (instanceId: string, body: PubPostBody) => { const { pubTypeId, pubFields } = body; - let instance; - let pubType; - try { - instance = await prisma.integrationInstance.findUnique({ + const [instance, pubType] = await Promise.all([ + prisma.integrationInstance.findUnique({ where: { id: instanceId }, - }); - } catch (error) { - throw error; - } + }), + prisma.pubType.findUnique({ + where: { id: pubTypeId }, + }), + ]); if (!instance) { throw InstanceNotFoundError; } - try { - pubType = await prisma.pubType.findUnique({ - where: { id: pubTypeId }, - }); - } catch (error) { - throw error; - } - if (!pubType) { throw PubTypeNotFoundError; } const pubValues = await getPubValues(pubFields, pubType.id); - let pub; - try { - pub = await prisma.pub.create({ - data: { - pubTypeId: pubType.id, - communityId: instance.communityId, - values: { - createMany: { - data: pubValues, - }, + const pub = await prisma.pub.create({ + data: { + pubTypeId: pubType.id, + communityId: instance.communityId, + values: { + createMany: { + data: pubValues, }, }, - }); - } catch (error) { - throw error; - } + }, + }); if (!pub) { throw PubNotFoundError; diff --git a/core/pages/api/[...ts-rest].ts b/core/pages/api/[...ts-rest].ts index d52d25fa2f..b5f8149a7f 100644 --- a/core/pages/api/[...ts-rest].ts +++ b/core/pages/api/[...ts-rest].ts @@ -1,18 +1,23 @@ import { createNextRoute, createNextRouter } from "@ts-rest/next"; import { api } from "~/lib/contracts"; -import { getPub, getMembers, updatePub, createPub } from "~/lib/server"; +import { getPub, getMembers, updatePub, createPub, NotFoundError } from "~/lib/server"; // TODO: verify pub belongs to integrationInstance const pubRouter = createNextRoute(api.pub, { createPub: async ({ params, body }) => { - let pub; try { - pub = await createPub(params.instanceId, body); + const pub = await createPub(params.instanceId, body); return { status: 200, body: pub }; } catch (error) { + if (error instanceof NotFoundError) { + return { + status: 404, + body: { message: error.message }, + }; + } return { - status: 404, - body: { message: error.message }, + status: 500, + body: { message: "Internal Server Error" }, }; } },