@xnestjs/rabbitmq 1.5.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Panates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @xnestjs/rabbitmq
2
+
3
+ NestJS extension library for RabbitMQ
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @xnestjs/rabbitmq
9
+ # or using yarn
10
+ yarn add @xnestjs/rabbitmq
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Register sync
16
+
17
+ An example of nestjs module that import the @xnestjs/rabbitmq
18
+
19
+ ```ts
20
+ // module.ts
21
+ import { Module } from '@nestjs/common';
22
+ import { RabbitmqModule } from '@xnestjs/rabbitmq';
23
+
24
+ @Module({
25
+ imports: [
26
+ RabbitmqModule.forRoot({
27
+ useValue: {
28
+ urls: ['amqp://localhost:5672'],
29
+ },
30
+ }),
31
+ ],
32
+ })
33
+ export class MyModule {
34
+ }
35
+ ```
36
+
37
+ ### Register async
38
+
39
+ An example of nestjs module that import the @xnestjs/rabbitmq async
40
+
41
+ ```ts
42
+ // module.ts
43
+ import { Module } from '@nestjs/common';
44
+ import { RabbitmqModule } from '@xnestjs/rabbitmq';
45
+
46
+ @Module({
47
+ imports: [
48
+ RabbitmqModule.forRootAsync({
49
+ inject: [ConfigModule],
50
+ useFactory: (config: ConfigService) => ({
51
+ urls: config.get('RMQ_URLS'),
52
+ }),
53
+ }),
54
+ ]
55
+ })
56
+ export class MyModule {
57
+ }
58
+ ```
59
+
60
+ ## Environment Variables
61
+
62
+ The library supports configuration through environment variables. Environment variables below is accepted.
63
+ All environment variables starts with prefix (RMQ_). This can be configured while registering the module.
64
+
65
+ | Environment Variable | Type | Default | Description |
66
+ |-----------------------------|-----------|---------|-------------|
67
+ | RMQ_URLS | String[]! | | |
68
+ | RMQ_PREFETCH_COUNT | Number | | |
69
+ | RMQ_MAX_CONNECTION_ATTEMPTS | Number | | |
70
+ | RMQ_RECONNECT_TIME | Number | | |
71
+ | RMQ_HEARTBEAT_INTERVAL | Number | | |
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RMQ_MODULE_ID = exports.RMQ_CONNECTION_OPTIONS = void 0;
4
+ exports.RMQ_CONNECTION_OPTIONS = Symbol('RMQ_CONNECTION_OPTIONS');
5
+ exports.RMQ_MODULE_ID = Symbol('RMQ_MODULE_ID');
package/cjs/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientRMQ = void 0;
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./constants.js"), exports);
6
+ tslib_1.__exportStar(require("./rabbitmq.module.js"), exports);
7
+ tslib_1.__exportStar(require("./types.js"), exports);
8
+ var microservices_1 = require("@nestjs/microservices");
9
+ Object.defineProperty(exports, "ClientRMQ", { enumerable: true, get: function () { return microservices_1.ClientRMQ; } });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var RabbitmqCoreModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RabbitmqCoreModule = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
7
+ const crypto = tslib_1.__importStar(require("node:crypto"));
8
+ const node_process_1 = tslib_1.__importDefault(require("node:process"));
9
+ const objects_1 = require("@jsopen/objects");
10
+ const common_1 = require("@nestjs/common");
11
+ const microservices_1 = require("@nestjs/microservices");
12
+ const colors = tslib_1.__importStar(require("ansi-colors"));
13
+ const putil_varhelpers_1 = require("putil-varhelpers");
14
+ const constants_js_1 = require("./constants.js");
15
+ const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
16
+ let RabbitmqCoreModule = RabbitmqCoreModule_1 = class RabbitmqCoreModule {
17
+ /**
18
+ *
19
+ */
20
+ static forRoot(moduleOptions) {
21
+ const connectionOptions = this._readConnectionOptions(moduleOptions.useValue || {}, moduleOptions.envPrefix);
22
+ return this._createDynamicModule(moduleOptions, {
23
+ global: moduleOptions.global,
24
+ providers: [
25
+ {
26
+ provide: constants_js_1.RMQ_CONNECTION_OPTIONS,
27
+ useValue: connectionOptions,
28
+ },
29
+ ],
30
+ });
31
+ }
32
+ /**
33
+ *
34
+ */
35
+ static forRootAsync(asyncOptions) {
36
+ node_assert_1.default.ok(asyncOptions.useFactory, 'useFactory is required');
37
+ return this._createDynamicModule(asyncOptions, {
38
+ global: asyncOptions.global,
39
+ providers: [
40
+ {
41
+ provide: constants_js_1.RMQ_CONNECTION_OPTIONS,
42
+ inject: asyncOptions.inject,
43
+ useFactory: async (...args) => {
44
+ const opts = await asyncOptions.useFactory(...args);
45
+ return this._readConnectionOptions(opts, asyncOptions.envPrefix);
46
+ },
47
+ },
48
+ ],
49
+ });
50
+ }
51
+ static _createDynamicModule(opts, metadata) {
52
+ const token = opts.token ?? microservices_1.ClientRMQ;
53
+ const name = typeof token === 'string' ? token : 'RabbitMQ';
54
+ const logger = typeof opts.logger === 'string' ? new common_1.Logger(opts.logger) : opts.logger;
55
+ const exports = [constants_js_1.RMQ_CONNECTION_OPTIONS, ...(metadata.exports ?? [])];
56
+ const providers = [
57
+ ...(metadata.providers ?? []),
58
+ {
59
+ provide: common_1.Logger,
60
+ useValue: logger,
61
+ },
62
+ {
63
+ provide: CLIENT_TOKEN,
64
+ useExisting: token,
65
+ },
66
+ {
67
+ provide: constants_js_1.RMQ_MODULE_ID,
68
+ useValue: crypto.randomUUID(),
69
+ },
70
+ ];
71
+ if (name !== token) {
72
+ exports.push(token);
73
+ providers.push({
74
+ provide: token,
75
+ useExisting: name,
76
+ });
77
+ }
78
+ return {
79
+ module: RabbitmqCoreModule_1,
80
+ providers,
81
+ imports: [
82
+ /** Import ClientsModule */
83
+ microservices_1.ClientsModule.registerAsync({
84
+ clients: [
85
+ {
86
+ name,
87
+ extraProviders: metadata.providers,
88
+ inject: [constants_js_1.RMQ_CONNECTION_OPTIONS],
89
+ useFactory: (connectionOptions) => {
90
+ return {
91
+ transport: microservices_1.Transport.RMQ,
92
+ options: connectionOptions,
93
+ };
94
+ },
95
+ },
96
+ ],
97
+ }),
98
+ ],
99
+ exports,
100
+ };
101
+ }
102
+ static _readConnectionOptions(moduleOptions, prefix = 'RMQ_') {
103
+ const options = (0, objects_1.clone)(moduleOptions);
104
+ const env = node_process_1.default.env;
105
+ options.urls = options.urls || (env[prefix + 'URLS'] ?? 'amqp://localhost:5672').split(/\s*,\s*/);
106
+ options.prefetchCount = options.prefetchCount ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'PREFETCH_COUNT']);
107
+ options.maxConnectionAttempts = options.maxConnectionAttempts ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_CONNECTION_ATTEMPTS']);
108
+ options.socketOptions = options.socketOptions ?? {};
109
+ options.socketOptions.reconnectTimeInSeconds =
110
+ options.socketOptions.reconnectTimeInSeconds ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'RECONNECT_TIME']);
111
+ options.socketOptions.heartbeatIntervalInSeconds =
112
+ options.socketOptions.heartbeatIntervalInSeconds ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'HEARTBEAT_INTERVAL']);
113
+ return options;
114
+ }
115
+ /**
116
+ *
117
+ * @constructor
118
+ */
119
+ constructor(client, connectionOptions, logger) {
120
+ this.client = client;
121
+ this.connectionOptions = connectionOptions;
122
+ this.logger = logger;
123
+ }
124
+ async onApplicationBootstrap() {
125
+ const options = this.connectionOptions;
126
+ if (!options.lazyConnect && options.urls?.length) {
127
+ this.logger?.log('Connecting to RabbitMQ at ' + colors.blue(options.urls.join(',')));
128
+ common_1.Logger.flush();
129
+ await this.client.connect().catch(e => {
130
+ this.logger?.error('RabbitMQ connection failed: ' + e.message);
131
+ throw e;
132
+ });
133
+ }
134
+ }
135
+ onApplicationShutdown() {
136
+ return this.client.close();
137
+ }
138
+ };
139
+ exports.RabbitmqCoreModule = RabbitmqCoreModule;
140
+ exports.RabbitmqCoreModule = RabbitmqCoreModule = RabbitmqCoreModule_1 = tslib_1.__decorate([
141
+ tslib_1.__param(0, (0, common_1.Inject)(CLIENT_TOKEN)),
142
+ tslib_1.__param(1, (0, common_1.Inject)(constants_js_1.RMQ_CONNECTION_OPTIONS)),
143
+ tslib_1.__metadata("design:paramtypes", [microservices_1.ClientRMQ, Object, common_1.Logger])
144
+ ], RabbitmqCoreModule);
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var RabbitmqModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RabbitmqModule = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const rabbitmq_core_module_js_1 = require("./rabbitmq-core.module.js");
8
+ let RabbitmqModule = RabbitmqModule_1 = class RabbitmqModule {
9
+ static forRoot(options) {
10
+ return {
11
+ module: RabbitmqModule_1,
12
+ imports: [rabbitmq_core_module_js_1.RabbitmqCoreModule.forRoot(options)],
13
+ };
14
+ }
15
+ static forRootAsync(options) {
16
+ return {
17
+ module: RabbitmqModule_1,
18
+ imports: [rabbitmq_core_module_js_1.RabbitmqCoreModule.forRootAsync(options)],
19
+ };
20
+ }
21
+ };
22
+ exports.RabbitmqModule = RabbitmqModule;
23
+ exports.RabbitmqModule = RabbitmqModule = RabbitmqModule_1 = tslib_1.__decorate([
24
+ (0, common_1.Module)({})
25
+ ], RabbitmqModule);
package/cjs/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export const RMQ_CONNECTION_OPTIONS = Symbol('RMQ_CONNECTION_OPTIONS');
2
+ export const RMQ_MODULE_ID = Symbol('RMQ_MODULE_ID');
package/esm/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './rabbitmq.module.js';
3
+ export * from './types.js';
4
+ export { ClientRMQ } from '@nestjs/microservices';
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,141 @@
1
+ var RabbitmqCoreModule_1;
2
+ import { __decorate, __metadata, __param } from "tslib";
3
+ import assert from 'node:assert';
4
+ import * as crypto from 'node:crypto';
5
+ import process from 'node:process';
6
+ import { clone } from '@jsopen/objects';
7
+ import { Inject, Logger } from '@nestjs/common';
8
+ import { ClientRMQ, ClientsModule, Transport } from '@nestjs/microservices';
9
+ import * as colors from 'ansi-colors';
10
+ import { toInt } from 'putil-varhelpers';
11
+ import { RMQ_CONNECTION_OPTIONS, RMQ_MODULE_ID } from './constants.js';
12
+ const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
13
+ let RabbitmqCoreModule = RabbitmqCoreModule_1 = class RabbitmqCoreModule {
14
+ /**
15
+ *
16
+ */
17
+ static forRoot(moduleOptions) {
18
+ const connectionOptions = this._readConnectionOptions(moduleOptions.useValue || {}, moduleOptions.envPrefix);
19
+ return this._createDynamicModule(moduleOptions, {
20
+ global: moduleOptions.global,
21
+ providers: [
22
+ {
23
+ provide: RMQ_CONNECTION_OPTIONS,
24
+ useValue: connectionOptions,
25
+ },
26
+ ],
27
+ });
28
+ }
29
+ /**
30
+ *
31
+ */
32
+ static forRootAsync(asyncOptions) {
33
+ assert.ok(asyncOptions.useFactory, 'useFactory is required');
34
+ return this._createDynamicModule(asyncOptions, {
35
+ global: asyncOptions.global,
36
+ providers: [
37
+ {
38
+ provide: RMQ_CONNECTION_OPTIONS,
39
+ inject: asyncOptions.inject,
40
+ useFactory: async (...args) => {
41
+ const opts = await asyncOptions.useFactory(...args);
42
+ return this._readConnectionOptions(opts, asyncOptions.envPrefix);
43
+ },
44
+ },
45
+ ],
46
+ });
47
+ }
48
+ static _createDynamicModule(opts, metadata) {
49
+ const token = opts.token ?? ClientRMQ;
50
+ const name = typeof token === 'string' ? token : 'RabbitMQ';
51
+ const logger = typeof opts.logger === 'string' ? new Logger(opts.logger) : opts.logger;
52
+ const exports = [RMQ_CONNECTION_OPTIONS, ...(metadata.exports ?? [])];
53
+ const providers = [
54
+ ...(metadata.providers ?? []),
55
+ {
56
+ provide: Logger,
57
+ useValue: logger,
58
+ },
59
+ {
60
+ provide: CLIENT_TOKEN,
61
+ useExisting: token,
62
+ },
63
+ {
64
+ provide: RMQ_MODULE_ID,
65
+ useValue: crypto.randomUUID(),
66
+ },
67
+ ];
68
+ if (name !== token) {
69
+ exports.push(token);
70
+ providers.push({
71
+ provide: token,
72
+ useExisting: name,
73
+ });
74
+ }
75
+ return {
76
+ module: RabbitmqCoreModule_1,
77
+ providers,
78
+ imports: [
79
+ /** Import ClientsModule */
80
+ ClientsModule.registerAsync({
81
+ clients: [
82
+ {
83
+ name,
84
+ extraProviders: metadata.providers,
85
+ inject: [RMQ_CONNECTION_OPTIONS],
86
+ useFactory: (connectionOptions) => {
87
+ return {
88
+ transport: Transport.RMQ,
89
+ options: connectionOptions,
90
+ };
91
+ },
92
+ },
93
+ ],
94
+ }),
95
+ ],
96
+ exports,
97
+ };
98
+ }
99
+ static _readConnectionOptions(moduleOptions, prefix = 'RMQ_') {
100
+ const options = clone(moduleOptions);
101
+ const env = process.env;
102
+ options.urls = options.urls || (env[prefix + 'URLS'] ?? 'amqp://localhost:5672').split(/\s*,\s*/);
103
+ options.prefetchCount = options.prefetchCount ?? toInt(env[prefix + 'PREFETCH_COUNT']);
104
+ options.maxConnectionAttempts = options.maxConnectionAttempts ?? toInt(env[prefix + 'MAX_CONNECTION_ATTEMPTS']);
105
+ options.socketOptions = options.socketOptions ?? {};
106
+ options.socketOptions.reconnectTimeInSeconds =
107
+ options.socketOptions.reconnectTimeInSeconds ?? toInt(env[prefix + 'RECONNECT_TIME']);
108
+ options.socketOptions.heartbeatIntervalInSeconds =
109
+ options.socketOptions.heartbeatIntervalInSeconds ?? toInt(env[prefix + 'HEARTBEAT_INTERVAL']);
110
+ return options;
111
+ }
112
+ /**
113
+ *
114
+ * @constructor
115
+ */
116
+ constructor(client, connectionOptions, logger) {
117
+ this.client = client;
118
+ this.connectionOptions = connectionOptions;
119
+ this.logger = logger;
120
+ }
121
+ async onApplicationBootstrap() {
122
+ const options = this.connectionOptions;
123
+ if (!options.lazyConnect && options.urls?.length) {
124
+ this.logger?.log('Connecting to RabbitMQ at ' + colors.blue(options.urls.join(',')));
125
+ Logger.flush();
126
+ await this.client.connect().catch(e => {
127
+ this.logger?.error('RabbitMQ connection failed: ' + e.message);
128
+ throw e;
129
+ });
130
+ }
131
+ }
132
+ onApplicationShutdown() {
133
+ return this.client.close();
134
+ }
135
+ };
136
+ RabbitmqCoreModule = RabbitmqCoreModule_1 = __decorate([
137
+ __param(0, Inject(CLIENT_TOKEN)),
138
+ __param(1, Inject(RMQ_CONNECTION_OPTIONS)),
139
+ __metadata("design:paramtypes", [ClientRMQ, Object, Logger])
140
+ ], RabbitmqCoreModule);
141
+ export { RabbitmqCoreModule };
@@ -0,0 +1,22 @@
1
+ var RabbitmqModule_1;
2
+ import { __decorate } from "tslib";
3
+ import { Module } from '@nestjs/common';
4
+ import { RabbitmqCoreModule } from './rabbitmq-core.module.js';
5
+ let RabbitmqModule = RabbitmqModule_1 = class RabbitmqModule {
6
+ static forRoot(options) {
7
+ return {
8
+ module: RabbitmqModule_1,
9
+ imports: [RabbitmqCoreModule.forRoot(options)],
10
+ };
11
+ }
12
+ static forRootAsync(options) {
13
+ return {
14
+ module: RabbitmqModule_1,
15
+ imports: [RabbitmqCoreModule.forRootAsync(options)],
16
+ };
17
+ }
18
+ };
19
+ RabbitmqModule = RabbitmqModule_1 = __decorate([
20
+ Module({})
21
+ ], RabbitmqModule);
22
+ export { RabbitmqModule };
package/esm/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@xnestjs/rabbitmq",
3
+ "version": "1.5.1",
4
+ "description": "NestJS extension library for RabbitMQ",
5
+ "author": "Panates",
6
+ "license": "MIT",
7
+ "dependencies": {
8
+ "@jsopen/objects": "^1.5.2",
9
+ "ansi-colors": "^4.1.3",
10
+ "putil-varhelpers": "^1.6.5",
11
+ "tslib": "^2.8.1"
12
+ },
13
+ "peerDependencies": {
14
+ "@nestjs/common": "^10.0.0 || ^11.0.0",
15
+ "@nestjs/core": "^10.0.0 || ^11.0.0",
16
+ "@nestjs/microservices": "^10.0.0 || ^11.0.0",
17
+ "amqp-connection-manager": "*",
18
+ "amqplib": "*"
19
+ },
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "import": {
24
+ "types": "./types/index.d.ts",
25
+ "default": "./esm/index.js"
26
+ },
27
+ "require": {
28
+ "types": "./types/index.d.cts",
29
+ "default": "./cjs/index.js"
30
+ },
31
+ "default": "./esm/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "main": "./cjs/index.js",
36
+ "module": "./esm/index.js",
37
+ "types": "./types/index.d.ts",
38
+ "repository": {
39
+ "registry": "https://github.com/panates/xnestjs.git",
40
+ "directory": "packages/rabitmq"
41
+ },
42
+ "engines": {
43
+ "node": ">=16.0",
44
+ "npm": ">=7.0.0"
45
+ },
46
+ "files": [
47
+ "cjs/",
48
+ "esm/",
49
+ "types/",
50
+ "LICENSE",
51
+ "README.md"
52
+ ],
53
+ "keywords": [
54
+ "nestjs",
55
+ "rabitmq"
56
+ ]
57
+ }
@@ -0,0 +1,2 @@
1
+ export declare const RMQ_CONNECTION_OPTIONS: unique symbol;
2
+ export declare const RMQ_MODULE_ID: unique symbol;
@@ -0,0 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './rabbitmq.module.js';
3
+ export * from './types.js';
4
+ export { ClientRMQ } from '@nestjs/microservices';
@@ -0,0 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './rabbitmq.module.js';
3
+ export * from './types.js';
4
+ export { ClientRMQ } from '@nestjs/microservices';
@@ -0,0 +1,25 @@
1
+ import { DynamicModule, Logger, OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
2
+ import { ClientRMQ } from '@nestjs/microservices';
3
+ import type { RabbitmqConnectionOptions, RabbitmqModuleAsyncOptions, RabbitmqModuleOptions } from './types.js';
4
+ export declare class RabbitmqCoreModule implements OnApplicationShutdown, OnApplicationBootstrap {
5
+ protected client: ClientRMQ;
6
+ private connectionOptions;
7
+ private logger?;
8
+ /**
9
+ *
10
+ */
11
+ static forRoot(moduleOptions: RabbitmqModuleOptions): DynamicModule;
12
+ /**
13
+ *
14
+ */
15
+ static forRootAsync(asyncOptions: RabbitmqModuleAsyncOptions): DynamicModule;
16
+ private static _createDynamicModule;
17
+ private static _readConnectionOptions;
18
+ /**
19
+ *
20
+ * @constructor
21
+ */
22
+ constructor(client: ClientRMQ, connectionOptions: RabbitmqConnectionOptions, logger?: Logger | undefined);
23
+ onApplicationBootstrap(): Promise<void>;
24
+ onApplicationShutdown(): void;
25
+ }
@@ -0,0 +1,6 @@
1
+ import { type DynamicModule } from '@nestjs/common';
2
+ import type { RabbitmqModuleAsyncOptions, RabbitmqModuleOptions } from './types.js';
3
+ export declare class RabbitmqModule {
4
+ static forRoot(options: RabbitmqModuleOptions): DynamicModule;
5
+ static forRootAsync(options: RabbitmqModuleAsyncOptions): DynamicModule;
6
+ }
@@ -0,0 +1,22 @@
1
+ import type { Logger } from '@nestjs/common';
2
+ import type { ModuleMetadata } from '@nestjs/common/interfaces';
3
+ import type { InjectionToken } from '@nestjs/common/interfaces/modules/injection-token.interface';
4
+ import type { RmqOptions } from '@nestjs/microservices';
5
+ type ExtractRmqOptions = Required<RmqOptions>['options'];
6
+ export interface RabbitmqConnectionOptions extends ExtractRmqOptions {
7
+ lazyConnect?: boolean;
8
+ }
9
+ export interface RabbitmqModuleOptions extends BaseModuleOptions {
10
+ useValue?: Partial<RabbitmqConnectionOptions>;
11
+ }
12
+ export interface RabbitmqModuleAsyncOptions extends BaseModuleOptions, Pick<ModuleMetadata, 'imports'> {
13
+ inject?: any[];
14
+ useFactory: (...args: any[]) => Promise<Partial<RabbitmqConnectionOptions>> | Partial<RabbitmqConnectionOptions>;
15
+ }
16
+ interface BaseModuleOptions {
17
+ token?: InjectionToken;
18
+ envPrefix?: string;
19
+ logger?: Logger | string;
20
+ global?: boolean;
21
+ }
22
+ export {};