discord.js/packages/brokers
Jiralite 346d1be72b
build: Bump dependencies (#10322)
* build: bump dependencies

* build: update pnpm to 9.1.4
2024-06-05 09:42:33 +00:00
..
__tests__ refactor(brokers): make option props more correct (#10242) 2024-05-11 15:54:06 +00:00
docs chore: refactor workspace 2023-05-03 02:14:22 +02:00
scripts feat: @discordjs/brokers (#8548) 2022-10-13 22:20:36 +02:00
src refactor(brokers): re-design API to make groups a constructor option (#10297) 2024-06-02 12:35:16 +00:00
.cliff-jumperrc.json chore: No identifier base in development versions (#9848) 2023-10-03 19:24:13 +00:00
.gitignore chore: refactor workspace 2023-05-03 02:14:22 +02:00
.lintstagedrc.js build: multi-config build and dep update 2023-11-14 01:26:22 +01:00
.prettierignore build: ignores/swap/concurrency 2023-08-24 21:58:34 +02:00
.prettierrc.js build: refactor linting setup 2023-08-24 06:43:23 +02:00
api-extractor.json feat(website): add support for source file links (#9048) 2023-01-12 13:49:11 +01:00
CHANGELOG.md chore(brokers): release @discordjs/brokers@0.3.0 2024-05-04 20:50:15 +03:00
cliff.toml build: git-cliff config 2023-04-02 01:55:39 +02:00
LICENSE chore: update license files (#9862) 2023-09-30 00:42:43 +00:00
package.json build: Bump dependencies (#10322) 2024-06-05 09:42:33 +00:00
README.md refactor(brokers): make option props more correct (#10242) 2024-05-11 15:54:06 +00:00
tsconfig.docs.json build: fix the messy dependency graph 2023-11-09 00:13:01 +01:00
tsconfig.eslint.json build: fix the messy dependency graph 2023-11-09 00:13:01 +01:00
tsconfig.json build: fix the messy dependency graph 2023-11-09 00:13:01 +01:00
tsup.config.ts build: multi-config build and dep update 2023-11-14 01:26:22 +01:00


discord.js


Discord server npm version npm downloads Build status Code coverage

Vercel Cloudflare Workers

About

@discordjs/brokers is a powerful set of message brokers

Installation

Node.js 18 or newer is required.

npm install @discordjs/brokers
yarn add @discordjs/brokers
pnpm add @discordjs/brokers

Example usage

pub sub

// publisher.js
import { PubSubRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new PubSubRedisBroker(new Redis());

await broker.publish('test', 'Hello World!');
await broker.destroy();

// subscriber.js
import { PubSubRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new PubSubRedisBroker(new Redis());
broker.on('test', ({ data, ack }) => {
	console.log(data);
	void ack();
});

await broker.subscribe('subscribers', ['test']);

RPC

// caller.js
import { RPCRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new RPCRedisBroker(new Redis());

console.log(await broker.call('testcall', 'Hello World!'));
await broker.destroy();

// responder.js
import { RPCRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new RPCRedisBroker(new Redis());
broker.on('testcall', ({ data, ack, reply }) => {
	console.log('responder', data);
	void ack();
	void reply(`Echo: ${data}`);
});

await broker.subscribe('responders', ['testcall']);

Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the documentation.
See the contribution guide if you'd like to submit a PR.

Help

If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official discord.js Server.