1.1.0 • Published 1 year ago

lzo-sapphire v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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.