feat: display runs and create run and update run endpoint

This commit is contained in:
BennyKok
2023-12-10 16:06:20 +08:00
parent 6a1c1d0ff5
commit 9c8a518c46
11 changed files with 335 additions and 219 deletions
+4 -3
View File
@@ -1,10 +1,11 @@
import { NextResponse } from "next/server";
import { ZodError, ZodType, z } from "zod";
import type { ZodType, z } from "zod";
import { ZodError } from "zod";
export async function parseDataSafe<T extends ZodType<any, any, any>>(
schema: T,
request: Request,
headers?: HeadersInit,
headers?: HeadersInit
): Promise<[z.infer<T> | undefined, NextResponse | undefined]> {
let data: z.infer<T> | undefined = undefined;
try {
@@ -30,7 +31,7 @@ export async function parseDataSafe<T extends ZodType<any, any, any>>(
{
message: "Invalid request",
},
{ status: 500, statusText: "Invalid request", headers: headers },
{ status: 500, statusText: "Invalid request", headers: headers }
),
];