Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-notify

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-notify

Postgres pubsub client

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
increased by115.05%
Maintainers
1
Weekly downloads
 
Created
Source

pg-notify

Version Maintenance License: MIT Coverage Status CI

Postgres PubSub client using NOTIFY/LISTEN

Features

  • Auto reconnect
  • Payload size validation
  • Channel and payload sanitization

Install

npm install pg-notify
yarn add pg-notify
pnpm add pg-notify

Usage

PGPubSub accepts the same config as pg.

import PGPubSub from 'pg-notify'
//const PGPubSub = require('pg-notify')

;(async () => {
  const pubsub = new PGPubSub({ 
    connectionString: 'postgres://postgres:postgres@localhost:5432/db'
  })

  await pubsub.connect()

  await pubsub.on('test', (payload) => {
    console.log('payload: ', payload)
  })

  await pubsub.emit('test', 'this is the payload')
  await pubsub.emit('test', { foo: 'bar' })

  await pubsub.close()
})()

API

new PubSub(options)

  • options (object) Configuration options for pg-notify pubsub instance. Accepts same options as pg with few custom ones described below.

emit(channel, payload)

  • channel (string)
  • payload (string or object)

on(channel, listener)

  • channel (string)
  • listener (function accepting single argument payload)

removeListener(listener)

  • listener (function accepting single argument payload)

close()

connect()

Contributing

Contributions, issues and feature requests are welcome!

License

Copyright © 2020 Aldis Ameriks.
This project is MIT licensed.

Keywords

FAQs

Package last updated on 13 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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