@xnestjs/rabbitmq 1.5.3 → 1.6.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/README.md +4 -0
- package/cjs/{get-connection-options.js → get-rabbitmq-config.js} +2 -2
- package/cjs/index.js +1 -1
- package/cjs/rabbitmq-core.module.js +3 -3
- package/esm/{get-connection-options.js → get-rabbitmq-config.js} +1 -1
- package/esm/index.js +1 -1
- package/esm/rabbitmq-core.module.js +3 -3
- package/package.json +1 -1
- package/types/get-rabbitmq-config.d.ts +2 -0
- package/types/index.d.cts +1 -1
- package/types/index.d.ts +1 -1
- package/types/get-connection-options.d.ts +0 -2
package/README.md
CHANGED
|
@@ -62,6 +62,8 @@ export class MyModule {
|
|
|
62
62
|
The library supports configuration through environment variables. Environment variables below is accepted.
|
|
63
63
|
All environment variables starts with prefix (RMQ_). This can be configured while registering the module.
|
|
64
64
|
|
|
65
|
+
<--- BEGIN env --->
|
|
66
|
+
|
|
65
67
|
| Environment Variable | Type | Default | Description |
|
|
66
68
|
|-----------------------------|-----------|---------|-------------|
|
|
67
69
|
| RMQ_URLS | String[]! | | |
|
|
@@ -69,3 +71,5 @@ All environment variables starts with prefix (RMQ_). This can be configured whil
|
|
|
69
71
|
| RMQ_MAX_CONNECTION_ATTEMPTS | Number | | |
|
|
70
72
|
| RMQ_RECONNECT_TIME | Number | | |
|
|
71
73
|
| RMQ_HEARTBEAT_INTERVAL | Number | | |
|
|
74
|
+
|
|
75
|
+
<--- END env --->
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getRabbitmqConfig = getRabbitmqConfig;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
6
6
|
const objects_1 = require("@jsopen/objects");
|
|
7
7
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
8
|
-
function
|
|
8
|
+
function getRabbitmqConfig(moduleOptions, prefix = 'RMQ_') {
|
|
9
9
|
const options = (0, objects_1.clone)(moduleOptions);
|
|
10
10
|
const env = node_process_1.default.env;
|
|
11
11
|
options.urls = options.urls || (env[prefix + 'URLS'] ?? 'amqp://localhost:5672').split(/\s*,\s*/);
|
package/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClientRMQ = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./get-
|
|
6
|
+
tslib_1.__exportStar(require("./get-rabbitmq-config.js"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./rabbitmq.module.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
9
9
|
var microservices_1 = require("@nestjs/microservices");
|
|
@@ -9,14 +9,14 @@ const common_1 = require("@nestjs/common");
|
|
|
9
9
|
const microservices_1 = require("@nestjs/microservices");
|
|
10
10
|
const colors = tslib_1.__importStar(require("ansi-colors"));
|
|
11
11
|
const constants_js_1 = require("./constants.js");
|
|
12
|
-
const
|
|
12
|
+
const get_rabbitmq_config_js_1 = require("./get-rabbitmq-config.js");
|
|
13
13
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
14
14
|
let RabbitmqCoreModule = RabbitmqCoreModule_1 = class RabbitmqCoreModule {
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
18
|
static forRoot(moduleOptions) {
|
|
19
|
-
const connectionOptions = (0,
|
|
19
|
+
const connectionOptions = (0, get_rabbitmq_config_js_1.getRabbitmqConfig)(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
20
20
|
return this._createDynamicModule(moduleOptions, {
|
|
21
21
|
global: moduleOptions.global,
|
|
22
22
|
providers: [
|
|
@@ -40,7 +40,7 @@ let RabbitmqCoreModule = RabbitmqCoreModule_1 = class RabbitmqCoreModule {
|
|
|
40
40
|
inject: asyncOptions.inject,
|
|
41
41
|
useFactory: async (...args) => {
|
|
42
42
|
const opts = await asyncOptions.useFactory(...args);
|
|
43
|
-
return (0,
|
|
43
|
+
return (0, get_rabbitmq_config_js_1.getRabbitmqConfig)(opts, asyncOptions.envPrefix);
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { clone } from '@jsopen/objects';
|
|
3
3
|
import { toInt } from 'putil-varhelpers';
|
|
4
|
-
export function
|
|
4
|
+
export function getRabbitmqConfig(moduleOptions, prefix = 'RMQ_') {
|
|
5
5
|
const options = clone(moduleOptions);
|
|
6
6
|
const env = process.env;
|
|
7
7
|
options.urls = options.urls || (env[prefix + 'URLS'] ?? 'amqp://localhost:5672').split(/\s*,\s*/);
|
package/esm/index.js
CHANGED
|
@@ -6,14 +6,14 @@ import { Inject, Logger } from '@nestjs/common';
|
|
|
6
6
|
import { ClientRMQ, ClientsModule, Transport } from '@nestjs/microservices';
|
|
7
7
|
import * as colors from 'ansi-colors';
|
|
8
8
|
import { RMQ_CONNECTION_OPTIONS, RMQ_MODULE_ID } from './constants.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getRabbitmqConfig } from './get-rabbitmq-config.js';
|
|
10
10
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
11
11
|
let RabbitmqCoreModule = RabbitmqCoreModule_1 = class RabbitmqCoreModule {
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
15
|
static forRoot(moduleOptions) {
|
|
16
|
-
const connectionOptions =
|
|
16
|
+
const connectionOptions = getRabbitmqConfig(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
17
17
|
return this._createDynamicModule(moduleOptions, {
|
|
18
18
|
global: moduleOptions.global,
|
|
19
19
|
providers: [
|
|
@@ -37,7 +37,7 @@ let RabbitmqCoreModule = RabbitmqCoreModule_1 = class RabbitmqCoreModule {
|
|
|
37
37
|
inject: asyncOptions.inject,
|
|
38
38
|
useFactory: async (...args) => {
|
|
39
39
|
const opts = await asyncOptions.useFactory(...args);
|
|
40
|
-
return
|
|
40
|
+
return getRabbitmqConfig(opts, asyncOptions.envPrefix);
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
],
|
package/package.json
CHANGED
package/types/index.d.cts
CHANGED
package/types/index.d.ts
CHANGED