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
});
Distributed under the MIT License. See LICENSE for more information.