0.2.5 • Published 6 years ago
@penguinhouse/cyrus v0.2.5
Cyrus
 
 
 
Pubsub library for Postgres.
Install
npm install @penguinhouse/cyrusUsage
Options
- appName (required): string- name of the application (used for logging)
 
- user (optional): string- option for Postgres Pool Connection
 
- password (optional): string- option for Postgres Pool Connection
 
- host (optional): string- option for Postgres Pool Connection
 
- port (optional): number- option for Postgres Pool Connection
 
- database (optional): string- option for Postgres Pool Connection
 
import cyrus from '@penguinhouse/cyrus';
const notifier = cyrus({ appName: 'cyrus-example' });
// It needs to be connected before user
const connectedSuccessfully = await notifier.connect();
if (connectedSuccessfully) {
  // Create an observable to with a channel to listen to
  // Rx.Observable
  const observable = notifier.on('example-channel');
  // Sends this to postgres
  // The message will show up in the observable.
  notifier.notify('example-channel', 'example-message');
}
// disconnect from the database by ending the pool
notifier.disconnect()