@xnestjs/rabbitmq 1.13.0 → 1.14.0
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/get-rabbitmq-config.d.ts +1 -1
- package/package.json +3 -3
- package/rabbitmq-core.module.d.ts +1 -1
- package/rabbitmq-core.module.js +15 -2
- package/types.d.ts +1 -3
package/get-rabbitmq-config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RabbitmqConnectionOptions } from './types';
|
|
1
|
+
import type { RabbitmqConnectionOptions } from './types.js';
|
|
2
2
|
export declare function getRabbitmqConfig(init?: string | string[] | Partial<RabbitmqConnectionOptions>, prefix?: string): RabbitmqConnectionOptions;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnestjs/rabbitmq",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "NestJS extension library for RabbitMQ",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@jsopen/objects": "^2.
|
|
8
|
+
"@jsopen/objects": "^2.2.3",
|
|
9
9
|
"ansi-colors": "^4.1.3",
|
|
10
|
-
"putil-varhelpers": "^1.
|
|
10
|
+
"putil-varhelpers": "^1.7.0",
|
|
11
11
|
"tslib": "^2.8.1"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DynamicModule, Logger, OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
|
|
1
|
+
import { type DynamicModule, Logger, type OnApplicationBootstrap, type OnApplicationShutdown } from '@nestjs/common';
|
|
2
2
|
import { type RabbitmqConnectionOptions, type RabbitmqModuleAsyncOptions, type RabbitmqModuleOptions, RmqClient } from './types.js';
|
|
3
3
|
export declare class RabbitmqCoreModule implements OnApplicationShutdown, OnApplicationBootstrap {
|
|
4
4
|
protected client: RmqClient;
|
package/rabbitmq-core.module.js
CHANGED
|
@@ -97,14 +97,27 @@ let RabbitmqCoreModule = RabbitmqCoreModule_1 = class RabbitmqCoreModule {
|
|
|
97
97
|
this.client = client;
|
|
98
98
|
this.connectionOptions = connectionOptions;
|
|
99
99
|
this.logger = logger;
|
|
100
|
+
this.logger = logger || new Logger('RabbitMQ');
|
|
100
101
|
}
|
|
101
102
|
async onApplicationBootstrap() {
|
|
102
103
|
const options = this.connectionOptions;
|
|
103
104
|
if (options.lazyConnect || !options.hosts?.length)
|
|
104
105
|
return;
|
|
105
|
-
|
|
106
|
+
const logTimer = setTimeout(() => {
|
|
107
|
+
this.logger?.verbose(`Waiting to connect to RabbitMQ [${colors.blue(options.hosts.toString())}]`);
|
|
108
|
+
}, 1000);
|
|
106
109
|
Logger.flush();
|
|
107
|
-
await this.client
|
|
110
|
+
await this.client
|
|
111
|
+
.onConnect()
|
|
112
|
+
.catch(e => {
|
|
113
|
+
clearTimeout(logTimer);
|
|
114
|
+
this.logger?.error('RabbitMQ connection failed: ' + e.message);
|
|
115
|
+
throw e;
|
|
116
|
+
})
|
|
117
|
+
.then(() => {
|
|
118
|
+
clearTimeout(logTimer);
|
|
119
|
+
this.logger?.log(`RabbitMQ connection established`);
|
|
120
|
+
});
|
|
108
121
|
}
|
|
109
122
|
onApplicationShutdown() {
|
|
110
123
|
return this.client.close();
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { LoggerService } from '@nestjs/common';
|
|
2
|
-
import type { ModuleMetadata } from '@nestjs/common/interfaces';
|
|
3
|
-
import type { InjectionToken } from '@nestjs/common/interfaces/modules/injection-token.interface';
|
|
1
|
+
import type { InjectionToken, LoggerService, ModuleMetadata } from '@nestjs/common';
|
|
4
2
|
import * as rabbit from 'rabbitmq-client';
|
|
5
3
|
export type RmqClient = rabbit.Connection;
|
|
6
4
|
export declare const RmqClient: typeof rabbit.Connection;
|