lzo-sapphire
v1.1.0
Published
Pub/Sub messaging using RabbitMQ.
Downloads
6
Maintainers
Readme
LZO: Sapphire
Pub/Sub messaging using RabbitMQ.
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.