TS Allow Certain Response Bodies

Hello, I would like to add a type I can use on my applications for checking the type of responses based on a zod validator. I have wrote the following type:
import { z, type ZodType } from "zod";
import type { NextResponse } from "next/server";

const unauthedRes = new Response("Unauthorized", { status: 401 });
export type serverZodResponse<T extends ZodType<any, any, any>> = Promise<
undefined | NextResponse<z.infer<T>>
>;
import { z, type ZodType } from "zod";
import type { NextResponse } from "next/server";

const unauthedRes = new Response("Unauthorized", { status: 401 });
export type serverZodResponse<T extends ZodType<any, any, any>> = Promise<
undefined | NextResponse<z.infer<T>>
>;
I would like to add a Response with a body of Unauthorized and a status of 401 to the type inside the Promise. Is there anyway to do this? Thanks!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server