Skip to main content

publishing

Publishing

Use the publish API to enqueue jobs. You can call the generic form or provider shortcuts.

Topics typing

Declare topics once to get type‑safe payloads everywhere:

declare module 'balda-js' {
export interface QueueTopic {
test: { name: string };
}
}

Decorated consumers

import { queue } from 'balda-js';

export class SQSHandler {
@queue.sqs('test')
async handle(payload: { name: string }) {
// ...
}
}

Publishing with shortcuts

import { publish } from 'balda-js';

await publish.bullmq('test', { name: 'Alice' });
await publish.sqs('test', { name: 'Bob' });
await publish.pgboss('test', { name: 'Charlie' });

Generic publish

import { publish } from 'balda-js';

await publish('bullmq', 'test', { name: 'Charlie' });

Provider options for first class integrations

  • BullMQ: options map to Queue.add third parameter.
  • SQS: options include MessageGroupId, MessageDeduplicationId, DelaySeconds, MessageAttributes.

Examples:

await publish.bullmq('test', { name: 'Zed' }, {
// BullMQ publish options
});

await publish.sqs('test', { name: 'Yuki' }, {
// SQS publish options
});

await publish.pgboss('test', { name: 'Charlie' }, {
// PGBoss publish options
});