New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pg-listen

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-listen - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

dist/event-emitter.js

5

package.json
{
"name": "pg-listen",
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",

@@ -47,2 +47,5 @@ "description": "PostgreSQL LISTEN & NOTIFY that finally works.",

},
"files": [
"dist/**"
],
"ava": {

@@ -49,0 +52,0 @@ "serial": true

17

README.md

@@ -1,2 +0,2 @@

# pg-listen - PostgreSQL LISTEN & NOTIFY that finally works
# pg-listen - Postgres LISTEN & NOTIFY that works

@@ -20,3 +20,3 @@ [![Build Status](https://travis-ci.org/andywer/pg-listen.svg?branch=master)](https://travis-ci.org/andywer/pg-listen) [![NPM Version](https://img.shields.io/npm/v/pg-listen.svg)](https://www.npmjs.com/package/pg-listen)

Using the `NOTIFY` and `LISTEN` features is not trivial using [`node-postgres` (`pg`)](https://www.npmjs.com/package/pg), since you cannot use connection pools and also distinct client connections also tend to time out.
Using the `NOTIFY` and `LISTEN` features is not trivial using [`node-postgres` (`pg`)](https://www.npmjs.com/package/pg), since you cannot use connection pools and even distinct client connections also tend to time out.

@@ -43,2 +43,3 @@ There are already a few packages out there, like `pg-pubsub`, but neither of them seems to work reliably. Errors are being swallowed, the code is hard to reason about, there is no type-safety, ...

import createPostgresSubscriber from "pg-listen"
import { databaseURL } from "./config"

@@ -51,2 +52,8 @@ const subscriber = createPostgresSubscriber({ connectionString: databaseURL })

subscriber.events.on("error", (error) => {
// Usually triggered if reconnection attempts have failed repeatedly
console.error("Fatal database connection error:", error)
process.exit(1)
})
process.on("exit", () => {

@@ -56,3 +63,3 @@ subscriber.close()

export async function setUp (databaseURL) {
export async function connect () {
await subscriber.connect()

@@ -89,3 +96,7 @@ await subscriber.listenTo("my-channel")

### `instance.notifications.on(channelName: string, listener: (payload: any) => void)`
The convenient way of subscribing to notifications. Don't forget to call `.listenTo(channelName)` to subscribe the Postgres client to this channel in order to receive notifications.
## Debugging

@@ -92,0 +103,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc