Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 1.24 KB

README.md

File metadata and controls

58 lines (44 loc) · 1.24 KB
trpc-rabbitmq

trpc-rabbitmq



Usage

1. Install trpc-rabbitmq.

# npm
npm install trpc-rabbitmq
# yarn
yarn add trpc-rabbitmq
# pnpm
pnpm add trpc-rabbitmq

2. Use rmqLink in your client code.

import { createTRPCProxyClient } from '@trpc/client';
import { rmqLink } from 'trpc-rabbitmq/link';

import type { AppRouter } from './appRouter';

export const trpc = createTRPCProxyClient<AppRouter>({
  links: [
    rmqLink({
      url: "amqp://localhost",
      queue: "app"
    })
  ],
});

3. Use createRMQHandler to handle incoming calls via RabbitMQ on the server.

import { createRMQHandler } from 'trpc-rabbitmq/adapter';

import { appRouter } from './appRouter';

createRMQHandler({ 
  url: "amqp://localhost",
  queue: "app",
  router: appRouter
});

License

Distributed under the MIT License. See LICENSE for more information.