@postgresx/bun-listen
v0.1.0
Published
Bun-native PostgreSQL LISTEN/NOTIFY client for pgredis and standalone realtime use cases
Downloads
83
Readme
@postgresx/bun-listen
Bun-native PostgreSQL LISTEN/NOTIFY client used by @postgrex/noredis. It is published
as a separate package so Bun projects can use it directly without installing
the full @postgrex/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();