A type-safe RabbitMQ framework for Node.js (TypeScript), built on top of amqplib to simplify event-driven messaging, publishing, and consumption.
Docs · Examples · Issues · Discussions
amqplib is powerful, but it’s low-level. Rabbit Relay keeps “real RabbitMQ concepts” (exchanges, queues, routing keys), and adds:
- Type-safe events (typed payloads + versioning)
- Cleaner publish / consume APIs (less boilerplate)
- Explicit topology & ownership (no hidden abstractions)
- Reliable defaults (so every service doesn’t reinvent the same setup)
If you already use RabbitMQ and you want a better TypeScript developer experience, Rabbit Relay is for you.
npm i @bitspacerlabs/rabbit-relayTip: Rabbit Relay ships TypeScript-first and supports both ESM and CommonJS builds.
import { RabbitMQBroker, event } from "@bitspacerlabs/rabbit-relay";
const broker = new RabbitMQBroker("example.service");
// Create a publisher bound to your queue + exchange
const pub = await broker
.queue("example.q")
.exchange("example.exchange", { exchangeType: "topic" });
// Define typed events (name + version)
const send = event("send", "v1").of<{ message: string }>();
// Build a typed API and publish
const api = pub.with({ send });
await api.send({ message: "hello world" });import { RabbitMQBroker, event } from "@bitspacerlabs/rabbit-relay";
const broker = new RabbitMQBroker("example.publisher");
const pub = await broker
.queue("example.q")
.exchange("example.direct", { exchangeType: "direct" });
const hello = event("hello", "v1").of<{ msg: string }>();
await pub.produce(hello({ msg: "world" }));See runnable examples in:
- You already use RabbitMQ
- You want type-safe events
- You prefer explicit topology and ownership
- You don’t want “magic” abstractions
Rabbit Relay is actively evolving. If something is unclear or missing, please open an issue (or start a discussion) with:
- what you’re trying to build
- the RabbitMQ pattern you’re using (pub/sub, work queue, RPC, etc.)
- a small code snippet
Contributions are welcome ❤️
- Read:
CONTRIBUTING.md - Code of Conduct:
CODE_OF_CONDUCT.md - Security:
SECURITY.md
If you want to help but don’t know where to start, check issues labeled good first issue.
MIT © BitSpacer Labs