lzo-sapphire
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

LZO: Sapphire

Pub/Sub messaging using RabbitMQ.

Sponsor Commitizen friendly TypeScript version Node.js version MIT Build Status - GitHub Actions

Installation

npm install lzo-sapphire OR yarn add lzo-sapphire

Configuration

Please input the credentials of your RabbitMQ server in the .env file.

See the example in the .env.example file.

RABBITMQ_URL="amqp://admin:admin@rabbitmq:5672"
RABBITMQ_PORT=5672

Usage

import { sapphire } from 'lzo-sapphire';

Sapphire.subscribe(
  (value) => console.log(typeof value, value), // object, { name: 'John Doe' }
  'testing',
);

setTimeout(() => {
  Sapphire.publish({ name: 'John Doe' }, 'testing');
});

API

Sapphire.publish<T>(value: T, ...channels: string[]): Promise<string[]>

Publishes a message to a channel or multiple channels.

Sapphire.subscribe<T>(callback: (message: T) => Promise<void>, ...channels: string[]): Promise<void>

Subscribes to a channel or multiple channels.

Backers & Sponsors

Support this project by becoming a sponsor.

License

Licensed under the MIT. See the LICENSE file for details.

/lzo-sapphire/

    Package Sidebar

    Install

    npm i lzo-sapphire

    Weekly Downloads

    2

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    11.5 kB

    Total Files

    5

    Last publish

    Collaborators

    • guilhermesantos001