open-index/open-npm huggingface dataset:
npm package: @relaymesh/relaybus-amqp
Description: AMQP publisher and subscriber utilities for Relaybus.
Latest version: 0.0.9

# relaybus-amqp (TypeScript)

AMQP publisher and subscriber utilities for Relaybus.

## Install

```
npm install @relaymesh/relaybus-amqp
```

## Example

Publisher will assert the exchange/queue on first publish (defaults: `exchangeType: "topic"`, `queue: topic`).

```ts
import { AmqpPublisher, AmqpSubscriber } from "@relaymesh/relaybus-amqp";

async function main() {
  const exchange = "relaybus.events";
  const queue = "relaybus.demo";

  const publisher = await AmqpPublisher.connect({
    url: "amqp://guest:guest@localhost:5672/",
    exchange,
    exchangeType: "topic",
    queue
  });
  await publisher.publish("relaybus.demo", {
    topic: "relaybus.demo",
    payload: Buffer.from("hello")
  });
  await publisher.close();

  const subscriber = await AmqpSubscriber.connect({
    url: "amqp://guest:guest@localhost:5672/",
    exchange,
    queue,
    onMessage: (msg) => console.log(msg.topic, msg.payload.toString())
  });
  await subscriber.start("relaybus.demo");
  await subscriber.close();
}

main().catch(console.error);
```
npm package: @relaymesh/relaybus-core
Description: Core envelope encode/decode utilities for Relaybus.
Latest version: 0.0.5

# relaybus-core (TypeScript)

Core envelope encode/decode utilities for Relaybus.

## Install

```
npm install @relaymesh/relaybus-core
```

## Example

```ts
import { decodeEnvelope, encodeEnvelope } from "@relaymesh/relaybus-core";

const encoded = encodeEnvelope({
  topic: "alpha",
  payload: Buffer.from("hello"),
  meta: { source: "ts" }
});

const decoded = decodeEnvelope(encoded);
console.log(decoded.topic, decoded.payload.toString());
```
npm package: @relaymesh/relaybus-http
Description: HTTP publisher and subscriber utilities for Relaybus.
Latest version: 0.0.9

# relaybus-http (TypeScript)

HTTP publisher and subscriber utilities for Relaybus.

## Install

```
npm install @relaymesh/relaybus-http
```

## Example

```ts
import { HttpPublisher, HttpSubscriber } from "@relaymesh/relaybus-http";

async function main() {
  const subscriber = new HttpSubscriber({
    onMessage: (msg) => console.log(msg.topic, msg.payload.toString())
  });
  await subscriber.listen({ port: 8088 });

  const publisher = HttpPublisher.connect({
    endpoint: "http://localhost:8088/{topic}"
  });
  await publisher.publish("relaybus.demo", {
    topic: "relaybus.demo",
    payload: Buffer.from("hello")
  });
}

main().catch(console.error);
```
npm package: @relaymesh/relaybus-kafka
Description: Kafka publisher and subscriber utilities for Relaybus.
Latest version: 0.0.9

# relaybus-kafka (TypeScript)

Kafka publisher and subscriber utilities for Relaybus.

## Install

```
npm install @relaymesh/relaybus-kafka
```

## Example

Publisher will attempt to create the topic on first publish (requires broker permissions).

```ts
import { KafkaPublisher, KafkaSubscriber } from "@relaymesh/relaybus-kafka";

async function main() {
  const publisher = await KafkaPublisher.connect({
    brokers: ["localhost:29092"]
  });
  await publisher.publish("relaybus.demo", {
    topic: "relaybus.demo",
    payload: Buffer.from("hello")
  });
  await publisher.close();

  const subscriber = await KafkaSubscriber.connect({
    brokers: ["localhost:29092"],
    groupId: "relaybus",
    onMessage: (msg) => console.log(msg.topic, msg.payload.toString())
  });
  await subscriber.start("relaybus.demo");
}

main().catch(console.error);
```
npm package: @relaymesh/relaybus-nats
Description: NATS publisher and subscriber utilities for Relaybus.
Latest version: 0.0.9

# relaybus-nats (TypeScript)

NATS publisher and subscriber utilities for Relaybus.

## Install

```
npm install @relaymesh/relaybus-nats
```

## Example

```ts
import { NatsPublisher, NatsSubscriber } from "@relaymesh/relaybus-nats";

async function main() {
  const publisher = await NatsPublisher.connect({ url: "nats://localhost:4222" });
  await publisher.publish("alpha", {
    topic: "alpha",
    payload: Buffer.from("hello")
  });

  const subscriber = await NatsSubscriber.connect({
    url: "nats://localhost:4222",
    subjectPrefix: "relaybus",
    onMessage: (msg) => console.log(msg.topic, msg.payload.toString())
  });
  await subscriber.start("alpha");
  await subscriber.close();
}

main().catch(console.error);
```