remove typebox, not used

This commit is contained in:
Avraham Sakal
2025-09-21 19:42:29 -04:00
parent 680d734f85
commit bb4a581154
3 changed files with 0 additions and 29 deletions
-20
View File
@@ -1,5 +1,3 @@
import type { TSchema } from "@sinclair/typebox";
import { TypeCompiler } from "@sinclair/typebox/compiler";
import { initTRPC, TRPCError } from "@trpc/server";
import type { getDbClient } from "../../database/postgres";
import type { getOpenrouter } from "@server/provider.js";
@@ -53,22 +51,4 @@ export const authProcedure = publicProcedure.use(
}
);
/**
* Generate a TRPC-compatible validator function given a Typebox schema.
* This was copied from [https://github.com/sinclairzx81/typebox/blob/6cfcdc02cc813af2f1be57407c771fc4fadfc34a/example/trpc/readme.md].
* @param schema A Typebox schema
* @returns A TRPC-compatible validator function
*/
export function Validator<T extends TSchema>(schema: T) {
const check = TypeCompiler.Compile(schema);
return (value: unknown) => {
if (check.Check(value)) return value;
const err = check.Errors(value).First();
throw new TRPCError({
message: `${err?.message} for ${err?.path}`,
code: "BAD_REQUEST",
});
};
}
export const createCallerFactory = t.createCallerFactory;