Comparing version 0.6.1 to 0.7.0
export = PGPubsub; | ||
/** @typedef {(payload: any) => void} PGPubsubCallback */ | ||
declare class PGPubsub extends NodeJS.EventEmitter { | ||
declare class PGPubsub extends EventEmitter { | ||
/** | ||
@@ -11,4 +11,4 @@ * @param {string | import('pg').ClientConfig} [conString] | ||
constructor(conString?: string | import("pg").ClientConfig | undefined, { log, retryLimit }?: { | ||
log?: ((message?: any, ...optionalParams: any[]) => void) | undefined; | ||
retryLimit?: number | undefined; | ||
log?: typeof console.log; | ||
retryLimit?: number; | ||
} | undefined); | ||
@@ -68,3 +68,4 @@ /** | ||
} | ||
import EventEmitter = require("events"); | ||
type PGPubsubCallback = (payload: any) => void; | ||
//# sourceMappingURL=index.d.ts.map |
29
index.js
@@ -0,1 +1,2 @@ | ||
/* eslint-disable promise/prefer-await-to-then */ | ||
// @ts-check | ||
@@ -9,5 +10,4 @@ /// <reference types="node" /> | ||
/** @type {typeof NodeJS.EventEmitter} */ | ||
const EventEmitter = require('events'); | ||
const VError = require('verror'); | ||
const { ErrorWithCause } = require('pony-cause'); | ||
@@ -25,4 +25,4 @@ const { pgClientRetry } = require('./lib/client'); | ||
*/ | ||
// eslint-disable-next-line node/no-process-env | ||
constructor (conString = process.env.DATABASE_URL, { log, retryLimit } = {}) { | ||
// eslint-disable-next-line n/no-process-env | ||
constructor (conString = process.env['DATABASE_URL'], { log, retryLimit } = {}) { | ||
super(); | ||
@@ -51,3 +51,6 @@ | ||
.catch(err => { | ||
this.emit('error', new VError(err, 'Failed to set up channels on new connection')); | ||
this.emit( | ||
'error', | ||
new ErrorWithCause('Failed to set up channels on new connection', { cause: err }) | ||
); | ||
}); | ||
@@ -67,3 +70,5 @@ | ||
return this.retry.try(!noNewConnections) | ||
.catch(err => { throw new VError(err, 'Failed to establish database connection'); }); | ||
.catch(err => { | ||
throw new ErrorWithCause('Failed to establish database connection', { cause: err }); | ||
}); | ||
} | ||
@@ -100,3 +105,3 @@ | ||
} catch (err) { | ||
throw new VError(err, 'Failed to listen to channel'); | ||
throw new ErrorWithCause('Failed to listen to channel', { cause: err }); | ||
} | ||
@@ -131,5 +136,9 @@ } | ||
this._getDB(true) | ||
// eslint-disable-next-line promise/prefer-await-to-then | ||
.then(db => db.query('UNLISTEN "' + channel + '"')) | ||
.catch(err => { this.emit('error', new VError(err, 'Failed to stop listening to channel')); }); | ||
.catch(err => { | ||
this.emit( | ||
'error', | ||
new ErrorWithCause('Failed to stop listening to channel', { cause: err }) | ||
); | ||
}); | ||
} | ||
@@ -152,3 +161,3 @@ | ||
} catch (err) { | ||
throw new VError(err, 'Failed to publish to channel'); | ||
throw new ErrorWithCause('Failed to publish to channel', { cause: err }); | ||
} | ||
@@ -155,0 +164,0 @@ } |
@@ -13,4 +13,4 @@ // @ts-check | ||
const getDefaultLog = () => | ||
// eslint-disable-next-line node/no-process-env | ||
process.env.NODE_ENV === 'production' | ||
// eslint-disable-next-line n/no-process-env | ||
process.env['NODE_ENV'] === 'production' | ||
? () => {} | ||
@@ -17,0 +17,0 @@ // eslint-disable-next-line no-console |
{ | ||
"name": "pg-pubsub", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "A Publish/Subscribe implementation on top of PostgreSQL NOTIFY/LISTEN", | ||
@@ -17,3 +17,3 @@ "homepage": "http://github.com/voxpelli/node-pg-pubsub", | ||
"engines": { | ||
"node": ">=12.0.0" | ||
"node": "^14.17.0 || >=16.0.0" | ||
}, | ||
@@ -36,3 +36,3 @@ "main": "index.js", | ||
"check:dependency-check": "dependency-check *.js 'test/**/*.js' --no-dev", | ||
"check:installed-check": "installed-check -i eslint", | ||
"check:installed-check": "installed-check -i eslint-plugin-jsdoc", | ||
"check:lint": "eslint .", | ||
@@ -47,50 +47,45 @@ "check:types": "tsc", | ||
"test-ci": "run-s test:*", | ||
"test": "run-s check test:*" | ||
"test": "run-s check test:*", | ||
"prepare": "husky install" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-push": "npm test" | ||
} | ||
}, | ||
"dependencies": { | ||
"pg": "^8.5.1", | ||
"pg": "^8.7.3", | ||
"pg-format": "^1.0.2", | ||
"promised-retry": "^0.4.0", | ||
"verror": "^1.10.0" | ||
"pony-cause": "^1.1.1", | ||
"promised-retry": "^0.4.0" | ||
}, | ||
"devDependencies": { | ||
"@hdsydsvenskan/ts-ignore-import": "^2.0.0", | ||
"@types/chai": "^4.2.15", | ||
"@types/chai-as-promised": "^7.1.3", | ||
"@types/mocha": "^8.2.0", | ||
"@types/node": "^12.20.1", | ||
"@types/pg": "^7.14.10", | ||
"@types/pg-format": "^1.0.1", | ||
"@types/verror": "^1.10.4", | ||
"@voxpelli/eslint-config": "11.0.1", | ||
"@voxpelli/eslint-config-jsdoc-ts": "^0.3.1", | ||
"@voxpelli/tsconfig": "^1.0.0", | ||
"c8": "^7.5.0", | ||
"chai": "^4.3.0", | ||
"@types/chai": "^4.3.0", | ||
"@types/chai-as-promised": "^7.1.5", | ||
"@types/mocha": "^9.1.0", | ||
"@types/node": "^14.18.12", | ||
"@types/pg": "^8.6.4", | ||
"@types/pg-format": "^1.0.2", | ||
"@voxpelli/eslint-config": "^13.0.3", | ||
"@voxpelli/eslint-config-jsdoc-ts": "^1.0.0", | ||
"@voxpelli/tsconfig": "^3.2.0", | ||
"c8": "^7.11.0", | ||
"chai": "^4.3.6", | ||
"chai-as-promised": "^7.1.1", | ||
"cross-env": "^7.0.3", | ||
"dependency-check": "^4.1.0", | ||
"dependency-check": "^5.0.0-4", | ||
"dotenv": "^8.2.0", | ||
"eslint": "^7.20.0", | ||
"eslint-config-standard": "^16.0.2", | ||
"eslint": "^8.9.0", | ||
"eslint-config-standard": "^17.0.0-1", | ||
"eslint-plugin-es": "^4.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsdoc": "^30.7.9", | ||
"eslint-plugin-mocha": "^8.0.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^4.3.1", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-jsdoc": "^37.9.4", | ||
"eslint-plugin-mocha": "^10.0.3", | ||
"eslint-plugin-n": "^14.0.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"eslint-plugin-security": "^1.4.0", | ||
"eslint-plugin-unicorn": "^28.0.1", | ||
"eslint-plugin-unicorn": "^41.0.0", | ||
"ghat": "^0.14.0", | ||
"husky": "^4.3.8", | ||
"installed-check": "^4.0.0", | ||
"mocha": "^8.3.0", | ||
"husky": "^7.0.0", | ||
"installed-check": "^5.0.0", | ||
"mocha": "^9.2.1", | ||
"npm-run-all": "^4.1.5", | ||
"typescript": "^4.1.5" | ||
"typescript": "~4.6.0" | ||
} | ||
} |
@@ -7,4 +7,2 @@ # PG PubSub | ||
[![Node CI Build Status](https://github.com/voxpelli/node-pg-pubsub/workflows/Node%20CI/badge.svg)](https://github.com/voxpelli/webpage-webmentions/actions) | ||
[![Coverage Status](https://coveralls.io/repos/voxpelli/node-pg-pubsub/badge.svg)](https://coveralls.io/r/voxpelli/node-pg-pubsub) | ||
[![dependencies Status](https://david-dm.org/voxpelli/node-pg-pubsub/status.svg)](https://david-dm.org/voxpelli/node-pg-pubsub) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/voxpelli/node-pg-pubsub/badge.svg?targetFile=package.json)](https://snyk.io/test/github/voxpelli/node-pg-pubsub?targetFile=package.json) | ||
@@ -21,4 +19,4 @@ [![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat)](https://github.com/Flet/semistandard) | ||
Node.js >= 10.x | ||
Postgres >= 9.4 | ||
* Node.js ^14.17.0 || >=16.0.0 | ||
* Postgres >= 9.4 | ||
@@ -25,0 +23,0 @@ ## Usage |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
32
295
18201
9
92
+ Addedpony-cause@^1.1.1
+ Addedpony-cause@1.1.1(transitive)
- Removedverror@^1.10.0
- Removedassert-plus@1.0.0(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedextsprintf@1.4.1(transitive)
- Removedverror@1.10.1(transitive)
Updatedpg@^8.7.3