This commit is contained in:
2025-09-03 14:32:02 -04:00
parent c6e2b6e4d3
commit 03b751dda6
22 changed files with 1429 additions and 150 deletions

View File

@@ -1,5 +1,5 @@
import { Context, Next } from "@hono/hono";
import { HonoEnv } from "./types.ts";
import { type HonoEnv } from "./types.ts";
import Logging from "@proxnet/undead-logging";
import z from "zod";
import { verify } from "@hono/hono/jwt";

View File

@@ -1,23 +1,24 @@
import { zValidator } from "@hono/zod-validator";
import type { MiddlewareHandler } from "@hono/hono";
import { z, ZodObject } from "zod";
import { z } from "zod";
import type { HonoEnv } from "./types.ts";
import { ZodSchema } from "zod/v4";
// thanks claude, this hurt my brain!
export const typedZValidator = <
Target extends 'query' | 'json' | 'form' | 'header' | 'param' | 'cookie',
Schema extends ZodObject
T extends 'query' | 'json' | 'form' | 'header' | 'param' | 'cookie',
S extends ZodSchema
>(
target: Target,
schema: Schema
target: T,
schema: S
) => {
return zValidator(target, schema) as MiddlewareHandler<
HonoEnv,
string,
{
in: { [K in Target]: z.input<Schema> };
out: { [K in Target]: z.output<Schema> };
in: { [K in T]: z.input<S> };
out: { [K in T]: z.output<S> };
}
>;
};