Skip to content

Scheduling infrastructure for absolutely everyone.

Merge pull request #71 from calcom/fix/api-production

Agusti Fernandez Pardod6aa70cdd0c1
diff --cc templates/endpoints/post.ts
index 61cff72a15e,35b3b013eb7..2b91522c62e
--- a/templates/endpoints/post.ts
+++ b/templates/endpoints/post.ts
@@@ -29,9 -29,12 +29,12 @@@ import { schemaResourceBodyParams, sche
* 401:
* description: Authorization information is missing or invalid.
*/
-async function createResource({body}: NextApiRequest, res: NextApiResponse<ResourceResponse>) {
+async function createResource({ body }: NextApiRequest, res: NextApiResponse<ResourceResponse>) {
const safe = schemaResourceBodyParams.safeParse(body);
- if (!safe.success) throw new Error("Invalid request body");
+ if (!safe.success) {
+ res.status(400).json({ message: "Invalid request body" });
+ return;
+ }
const resource = await prisma.resource.create({ data: safe.data });
const data = schemaResourcePublic.parse(resource);