trpc-iina

0.1.0 • Public • Published

trpc-iina

trpc adapter for use in IINA

Install

$ pnpm add trpc-iina

Setup

server

// trpc-server.ts

import { initTRPC } from '@trpc/server'
import { z } from 'zod'

const t = initTRPC.create({
  isServer: false,
  allowOutsideOfServer: true,
})

const appRouter = t.router({
  // ...procedures
  echo: t.procedure.input(z.string()).query(async ({ input }): Promise<string> => {
    return Promise.resolve(input)
  }),
})

export type AppRouter = typeof appRouter

// here is the magic
import { createIINATrpcServer } from 'trpc-iina/server'
createIINATrpcServer(appRouter, {
  nsp: 'foo',
  debug: true,
})

client

import { createTRPCProxyClient } from '@trpc/client'
import type { AppRouter } from 'somewhere-of-server'
import { createIINATrpcLink } from 'trpc-iina/client'

const trpc = createTRPCProxyClient<AppRouter>({
  links: [
    createIINATrpcLink({
      nsp: 'foo',
    }),
  ],
})

Changelog

CHANGELOG.md

License

the MIT License http://magicdawn.mit-license.org

Package Sidebar

Install

npm i trpc-iina

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

21.2 kB

Total Files

16

Last publish

Collaborators

  • magicdawn