@arrirpc/typebox-adapter
v0.67.0
Published
Currently not in development. Doesn't work with latest Arri version or Typescript version. I may resurrect this down the road if I have time. Although I probably will want to rethink the proper way to approach supporting different validation libraries (i.
Downloads
459
Readme
NOTICE:
Currently not in development. Doesn't work with latest Arri version or Typescript version. I may resurrect this down the road if I have time. Although I probably will want to rethink the proper way to approach supporting different validation libraries (i.e. TypeBox, Zod, etc)
Arri Typebox Adapter
Let's you reuse your Typebox schemas with Arri-RPC
Installation
npm install @arrirpc/typebox-adapter
pnpm install @arrirpc/typebox-adapter
Usage
Simply wrap your typebox schemas with typeboxAdapter()
to use them with arrirpc. Additionally metadata such as $id
and description
will be converted over.
// updateUser.rpc.ts
import { defineRpc } from "@arrirpc/server";
import { typeboxAdapter } from "@arrripc/typebox-adapter";
import { Type } from "typebox";
const User = Type.Object(
{
id: Type.String(),
name: Type.String(),
},
{
$id: "User",
},
);
export default defineRpc({
params: typeboxAdapter(User),
response: typeboxAdapter(User),
handler({ params }) {
// typebox keys are now available
console.log(params.id);
return params;
},
});