@postgresx/bun-listen
v0.3.1
Published
Bun-native PostgreSQL LISTEN/NOTIFY client for pgredis and standalone realtime use cases
Readme
@postgresx/bun-listen
Bun-native PostgreSQL LISTEN/NOTIFY client used by @postgresx/noredis. It is published
as a separate package so Bun projects can use it directly without installing
the full @postgresx/noredis toolkit.
It connects through Bun.connect() and implements the PostgreSQL wire protocol
for notification workloads. It supports TLS negotiation, MD5, cleartext, and
SCRAM-SHA-256 authentication.
Install
bun add @postgresx/bun-listenUsage
import { createPgListener } from "@postgresx/bun-listen";
const listener = createPgListener(process.env.DATABASE_URL!, {
channels: ["events"],
onNotify(channel, payload) {
console.log(channel, payload);
}
});
await listener.notify("events", JSON.stringify({ type: "ready" }));
listener.close();