@arrirpc/typebox-adapter
TypeScript icon, indicating that this package has built-in type declarations

0.79.0 • Public • Published

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;
    },
});

Readme

Keywords

none

Package Sidebar

Install

npm i @arrirpc/typebox-adapter

Weekly Downloads

5

Version

0.79.0

License

MIT

Unpacked Size

8.84 kB

Total Files

8

Last publish

Collaborators

  • joshmossas