From c6d784e6c7eb67c6a027f7f86a00d2163ab78983 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 16 May 2020 12:09:06 -0400 Subject: [PATCH 1/5] Added Try/Catch to subscribe function --- package-lock.json | 21 +++++++++++++++++++++ src/nats-pubsub.ts | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..d002bc3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,21 @@ +{ + "name": "@moonwalker/graphql-nats-subscriptions", + "version": "0.1.7", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "graphql-subscriptions": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/graphql-subscriptions/-/graphql-subscriptions-1.1.0.tgz", + "integrity": "sha512-6WzlBFC0lWmXJbIVE8OgFgXIP4RJi3OQgTPa0DVMsDXdpRDjTsM1K9wfl5HSYX7R87QAGlvcv2Y4BIZa/ItonA==", + "requires": { + "iterall": "^1.2.1" + } + }, + "iterall": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz", + "integrity": "sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg==" + } + } +} diff --git a/src/nats-pubsub.ts b/src/nats-pubsub.ts index ad27f7d..6865fce 100644 --- a/src/nats-pubsub.ts +++ b/src/nats-pubsub.ts @@ -18,7 +18,16 @@ export class NatsPubSub implements PubSubEngine { } public async subscribe(subject: string, onMessage: Function): Promise { - return await this.nats.subscribe(subject, (event: string) => onMessage(JSON.parse(event))) + return await this.nats.subscribe(subject, (event: string) => { + var payload; + try { + payload = JSON.parse(event); + } + catch (e) { + payload = event; + } + onMessage(payload); + }); } public unsubscribe(sid: number) { From 04c463ccf22ba6274a7e24f43c64eaf18c15d352 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 16 May 2020 12:29:38 -0400 Subject: [PATCH 2/5] Fixed .gitignore file --- .gitignore | 2 +- lib/index.d.ts | 2 + lib/index.js | 143 ++++++++++++++++ lib/nats-pubsub.d.ts | 12 ++ lib/pubsub-async-iterator.d.ts | 20 +++ package-lock.json | 303 +++++++++++++++++++++++++++++++++ 6 files changed, 481 insertions(+), 1 deletion(-) create mode 100644 lib/index.d.ts create mode 100644 lib/index.js create mode 100644 lib/nats-pubsub.d.ts create mode 100644 lib/pubsub-async-iterator.d.ts diff --git a/.gitignore b/.gitignore index 0388ea8..5924c60 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ .rpt2_cache node_modules -lib + diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..36f34f6 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,2 @@ +export * from './pubsub-async-iterator'; +export * from './nats-pubsub'; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..748d48c --- /dev/null +++ b/lib/index.js @@ -0,0 +1,143 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var iterall = require('iterall'); +var nats = require('nats'); + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +class PubSubAsyncIterator { + constructor(pubsub, eventNames) { + this.pubsub = pubsub; + this.pullQueue = []; + this.pushQueue = []; + this.listening = true; + this.eventsArray = typeof eventNames === 'string' ? [eventNames] : eventNames; + this.allSubscribed = this.subscribeAll(); + } + next() { + return __awaiter(this, void 0, void 0, function* () { + yield this.allSubscribed; + return this.listening ? this.pullValue() : this.return(); + }); + } + return() { + return __awaiter(this, void 0, void 0, function* () { + this.emptyQueue(yield this.allSubscribed); + return { value: undefined, done: true }; + }); + } + throw(error) { + return __awaiter(this, void 0, void 0, function* () { + this.emptyQueue(yield this.allSubscribed); + return Promise.reject(error); + }); + } + [iterall.$$asyncIterator]() { + return this; + } + pushValue(message) { + return __awaiter(this, void 0, void 0, function* () { + yield this.allSubscribed; + if (this.pullQueue.length !== 0) { + const cb = this.pullQueue.shift(); + if (!cb) { + return; + } + cb({ value: message, done: false }); + } + else { + this.pushQueue.push(message); + } + }); + } + pullValue() { + return new Promise(resolve => { + if (this.pushQueue.length !== 0) { + resolve({ value: this.pushQueue.shift(), done: false }); + } + else { + this.pullQueue.push(resolve); + } + }); + } + emptyQueue(subscriptionIds) { + if (this.listening) { + this.listening = false; + this.unsubscribeAll(subscriptionIds); + this.pullQueue.forEach(resolve => resolve({ value: undefined, done: true })); + this.pullQueue.length = 0; + this.pushQueue.length = 0; + } + } + subscribeAll() { + return Promise.all(this.eventsArray.map(eventName => this.pubsub.subscribe(eventName, this.pushValue.bind(this), {}))); + } + unsubscribeAll(subscriptionIds) { + for (const subscriptionId of subscriptionIds) { + this.pubsub.unsubscribe(subscriptionId); + } + } +} + +class NatsPubSub { + constructor(options) { + if (options.nc) { + this.nats = options.nc; + } + else { + this.nats = nats.connect(options); + } + } + publish(subject, payload) { + return __awaiter(this, void 0, void 0, function* () { + return yield this.nats.publish(subject, JSON.stringify(payload)); + }); + } + subscribe(subject, onMessage) { + return __awaiter(this, void 0, void 0, function* () { + return yield this.nats.subscribe(subject, (event) => { + var payload; + try { + payload = JSON.parse(event); + } + catch (e) { + payload = event; + } + onMessage(payload); + }); + }); + } + unsubscribe(sid) { + this.nats.unsubscribe(sid); + } + asyncIterator(subjects) { + return new PubSubAsyncIterator(this, subjects); + } +} + +exports.NatsPubSub = NatsPubSub; +exports.PubSubAsyncIterator = PubSubAsyncIterator; diff --git a/lib/nats-pubsub.d.ts b/lib/nats-pubsub.d.ts new file mode 100644 index 0000000..46d0023 --- /dev/null +++ b/lib/nats-pubsub.d.ts @@ -0,0 +1,12 @@ +import { PubSubEngine } from 'graphql-subscriptions'; +import * as nats from 'nats'; +export declare class NatsPubSub implements PubSubEngine { + private nats; + constructor(options: nats.ClientOpts & { + nc?: nats.Client; + }); + publish(subject: string, payload: any): Promise; + subscribe(subject: string, onMessage: Function): Promise; + unsubscribe(sid: number): void; + asyncIterator(subjects: string | string[]): AsyncIterator; +} diff --git a/lib/pubsub-async-iterator.d.ts b/lib/pubsub-async-iterator.d.ts new file mode 100644 index 0000000..cd29ee9 --- /dev/null +++ b/lib/pubsub-async-iterator.d.ts @@ -0,0 +1,20 @@ +import { $$asyncIterator } from 'iterall'; +import { PubSubEngine } from 'graphql-subscriptions'; +export declare class PubSubAsyncIterator implements AsyncIterator { + constructor(pubsub: PubSubEngine, eventNames: string | string[]); + next(): Promise>; + return(): Promise>; + throw(error: Error): Promise; + [$$asyncIterator](): this; + private pullQueue; + private pushQueue; + private eventsArray; + private allSubscribed; + private listening; + private pubsub; + private pushValue; + private pullValue; + private emptyQueue; + private subscribeAll; + private unsubscribeAll; +} diff --git a/package-lock.json b/package-lock.json index d002bc3..e9dad00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,116 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/estree": { + "version": "0.0.44", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.44.tgz", + "integrity": "sha512-iaIVzr+w2ZJ5HkidlZ3EJM8VTZb2MJLCjw3V+505yVts0gRC4UMvjw0d1HPtGqI/HQC/KdsYtayfzl+AXY2R8g==", + "dev": true + }, + "@types/node": { + "version": "12.12.39", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.39.tgz", + "integrity": "sha512-pADGfwnDkr6zagDwEiCVE4yQrv7XDkoeVa4OfA9Ju/zRTk6YNDLGtQbkdL4/56mCQQCs4AhNrBIag6jrp7ZuOg==", + "dev": true + }, + "acorn": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", + "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, + "find-cache-dir": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", + "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", + "dev": true + }, "graphql-subscriptions": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/graphql-subscriptions/-/graphql-subscriptions-1.1.0.tgz", @@ -12,10 +122,203 @@ "iterall": "^1.2.1" } }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, "iterall": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz", "integrity": "sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg==" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "rollup": { + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + } + }, + "rollup-plugin-typescript2": { + "version": "0.25.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.25.3.tgz", + "integrity": "sha512-ADkSaidKBovJmf5VBnZBZe+WzaZwofuvYdzGAKTN/J4hN7QJCFYAq7IrH9caxlru6T5qhX41PNFS1S4HqhsGQg==", + "dev": true, + "requires": { + "find-cache-dir": "^3.0.0", + "fs-extra": "8.1.0", + "resolve": "1.12.0", + "rollup-pluginutils": "2.8.1", + "tslib": "1.10.0" + } + }, + "rollup-pluginutils": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz", + "integrity": "sha512-J5oAoysWar6GuZo0s+3bZ6sVZAC0pfqKz68De7ZgDi5z63jOVZn1uJL/+z1jeKHNbGII8kAyHF5q8LnxSX5lQg==", + "dev": true, + "requires": { + "estree-walker": "^0.6.1" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "typescript": { + "version": "3.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.2.tgz", + "integrity": "sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw==", + "dev": true + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true } } } From 18e74cee392c2caf6fc83cea11c575add0f65436 Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 28 May 2020 12:20:27 -0400 Subject: [PATCH 3/5] :package: release 0.1.8 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e9dad00..45a3d16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@moonwalker/graphql-nats-subscriptions", - "version": "0.1.7", + "version": "0.1.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b13b1a6..bf52dca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moonwalker/graphql-nats-subscriptions", - "version": "0.1.7", + "version": "0.1.8", "description": "GraphQL subscriptions over NATS", "author": "Moon & Walker Technoligies", "license": "MIT", From 8336cbb004c120bb56e25bd1ab27a51e9c81137d Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 28 May 2020 13:12:15 -0400 Subject: [PATCH 4/5] Added public access to nats --- src/nats-pubsub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nats-pubsub.ts b/src/nats-pubsub.ts index 6865fce..a68f4da 100644 --- a/src/nats-pubsub.ts +++ b/src/nats-pubsub.ts @@ -3,7 +3,7 @@ import { PubSubEngine } from 'graphql-subscriptions' import * as nats from 'nats' export class NatsPubSub implements PubSubEngine { - private nats: nats.Client + public nats: nats.Client constructor(options: nats.ClientOpts & { nc?: nats.Client }) { if (options.nc) { From 722af0fa282ee662145643f46270b432e2e6e55f Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 28 May 2020 17:15:26 -0400 Subject: [PATCH 5/5] Added public access to nats --- src/nats-pubsub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nats-pubsub.ts b/src/nats-pubsub.ts index a68f4da..6865fce 100644 --- a/src/nats-pubsub.ts +++ b/src/nats-pubsub.ts @@ -3,7 +3,7 @@ import { PubSubEngine } from 'graphql-subscriptions' import * as nats from 'nats' export class NatsPubSub implements PubSubEngine { - public nats: nats.Client + private nats: nats.Client constructor(options: nats.ClientOpts & { nc?: nats.Client }) { if (options.nc) {