@palmetto/nestjs-pubsub 3.5.0 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/pubsub-module.d.ts +6 -1
- package/dist/pubsub-module.js +16 -4
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -122,6 +122,21 @@ class MyModelHandler {
|
|
|
122
122
|
export class AppModule {}
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
+
### Disable subscribers
|
|
126
|
+
|
|
127
|
+
To disable all subscribers when running code locally or in a script, use `PubSubModule.registerAsync` and set `disableSubscribers` to `true`
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
PubSubModule.registerAsync({
|
|
131
|
+
inject: [ZOD_CONFIG_TOKEN],
|
|
132
|
+
useFactory(appConfig: AppConfig) {
|
|
133
|
+
return {
|
|
134
|
+
disableSubsribers: appConfig.pubsub.disableSubscribers,
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
```
|
|
139
|
+
|
|
125
140
|
### pubsub
|
|
126
141
|
|
|
127
142
|
For details about pubsub, see [@palmetto/pubsub readme](../pubsub/README.md)
|
package/dist/pubsub-module.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface PubSubModuleOptions {
|
|
2
|
+
disableSubscribers?: boolean;
|
|
2
3
|
}
|
|
4
|
+
declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<PubSubModuleOptions, "register", "create", {}>;
|
|
5
|
+
export declare class PubSubModule extends ConfigurableModuleClass {
|
|
6
|
+
}
|
|
7
|
+
export {};
|
package/dist/pubsub-module.js
CHANGED
|
@@ -8,6 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
15
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
16
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -25,6 +28,7 @@ const common_1 = require("@nestjs/common");
|
|
|
25
28
|
const nestjs_discovery_1 = require("@golevelup/nestjs-discovery");
|
|
26
29
|
const subscriber_1 = require("./subscriber");
|
|
27
30
|
const pubsub_provider_module_1 = require("./pubsub-provider-module");
|
|
31
|
+
const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = new common_1.ConfigurableModuleBuilder().build();
|
|
28
32
|
function isPublisherProvider(obj) {
|
|
29
33
|
return "publish" in obj && typeof obj.publish === "function";
|
|
30
34
|
}
|
|
@@ -32,7 +36,8 @@ function isSubscriberProvider(obj) {
|
|
|
32
36
|
return "startSubscribe" in obj && typeof obj.startSubscribe === "function";
|
|
33
37
|
}
|
|
34
38
|
let PubSubManager = PubSubManager_1 = class PubSubManager {
|
|
35
|
-
constructor(discover, publisher, subscriber, pubSubFactory) {
|
|
39
|
+
constructor(options, discover, publisher, subscriber, pubSubFactory) {
|
|
40
|
+
this.options = options;
|
|
36
41
|
this.discover = discover;
|
|
37
42
|
this.publisher = publisher;
|
|
38
43
|
this.subscriber = subscriber;
|
|
@@ -55,6 +60,7 @@ let PubSubManager = PubSubManager_1 = class PubSubManager {
|
|
|
55
60
|
}
|
|
56
61
|
onApplicationBootstrap() {
|
|
57
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
var _a;
|
|
58
64
|
if (this.bootstrapped) {
|
|
59
65
|
this.logger.warn("already bootstrapped");
|
|
60
66
|
return;
|
|
@@ -70,6 +76,11 @@ let PubSubManager = PubSubManager_1 = class PubSubManager {
|
|
|
70
76
|
this.subscriber.addProvider(provider);
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.disableSubscribers) {
|
|
80
|
+
this.logger.warn("pubsub subscribers are disabled via module options. No subscriber methods will be registered.");
|
|
81
|
+
this.logger.debug("bootstrapping completed");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
73
84
|
const handlers = (yield this.discover.providerMethodsWithMetaAtKey(subscriber_1.EVENT_HANDLER)).concat(yield this.discover.controllerMethodsWithMetaAtKey(subscriber_1.EVENT_HANDLER));
|
|
74
85
|
for (const handler of handlers) {
|
|
75
86
|
const method = handler.discoveredMethod;
|
|
@@ -82,12 +93,14 @@ let PubSubManager = PubSubManager_1 = class PubSubManager {
|
|
|
82
93
|
};
|
|
83
94
|
PubSubManager = PubSubManager_1 = __decorate([
|
|
84
95
|
(0, common_1.Injectable)(),
|
|
85
|
-
|
|
96
|
+
__param(0, (0, common_1.Inject)(MODULE_OPTIONS_TOKEN)),
|
|
97
|
+
__param(0, (0, common_1.Optional)()),
|
|
98
|
+
__metadata("design:paramtypes", [Object, nestjs_discovery_1.DiscoveryService,
|
|
86
99
|
pubsub_1.Publisher,
|
|
87
100
|
pubsub_1.Subscriber,
|
|
88
101
|
pubsub_provider_module_1.PubSubProviderFactory])
|
|
89
102
|
], PubSubManager);
|
|
90
|
-
let PubSubModule = class PubSubModule {
|
|
103
|
+
let PubSubModule = class PubSubModule extends ConfigurableModuleClass {
|
|
91
104
|
};
|
|
92
105
|
exports.PubSubModule = PubSubModule;
|
|
93
106
|
exports.PubSubModule = PubSubModule = __decorate([
|
|
@@ -110,5 +123,4 @@ exports.PubSubModule = PubSubModule = __decorate([
|
|
|
110
123
|
],
|
|
111
124
|
exports: [pubsub_1.Publisher, pubsub_1.Subscriber],
|
|
112
125
|
})
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
114
126
|
], PubSubModule);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palmetto/nestjs-pubsub",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/palmetto/galaxy"
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"rxjs": "^7.8.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@google-cloud/pubsub": "^5",
|
|
56
55
|
"@nestjs/common": "^11",
|
|
57
56
|
"@nestjs/core": "^11",
|
|
58
57
|
"@palmetto/nestjs-errors": "^3 || ^2",
|