@xnestjs/kafka 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-kafka-config.js} +2 -2
- package/cjs/index.js +1 -1
- package/cjs/kafka-core.module.js +3 -3
- package/esm/{get-connection-options.js → get-kafka-config.js} +1 -1
- package/esm/index.js +1 -1
- package/esm/kafka-core.module.js +3 -3
- package/package.json +2 -2
- package/types/get-kafka-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 (KAFKA_). 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
|
| KAFKA_BROKERS | String[]! | localhost | Host names of Kafka brokers |
|
|
@@ -100,3 +102,5 @@ The environment variables are available when KAFKA_SASL is `aws`
|
|
|
100
102
|
| AWS_ACCESS_KEY_ID | String! | | |
|
|
101
103
|
| AWS_SECRET_ACCESS_KEY | String! | | |
|
|
102
104
|
| AWS_SESSION_TOKEN | String | | |
|
|
105
|
+
|
|
106
|
+
<--- END env --->
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getKafkaConfig = getKafkaConfig;
|
|
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 getKafkaConfig(moduleOptions, envPrefix = 'KAFKA_') {
|
|
9
9
|
const options = (0, objects_1.clone)(moduleOptions);
|
|
10
10
|
const env = node_process_1.default.env;
|
|
11
11
|
options.brokers = options.brokers || (env[envPrefix + 'BROKERS'] ?? 'localhost').split(/\s*,\s*/);
|
package/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClientKafka = 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-kafka-config.js"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./kafka.module.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
9
9
|
var microservices_1 = require("@nestjs/microservices");
|
package/cjs/kafka-core.module.js
CHANGED
|
@@ -10,14 +10,14 @@ 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
12
|
const create_log_creator_js_1 = require("./create-log-creator.js");
|
|
13
|
-
const
|
|
13
|
+
const get_kafka_config_js_1 = require("./get-kafka-config.js");
|
|
14
14
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
15
15
|
let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
static forRoot(moduleOptions) {
|
|
20
|
-
const connectionOptions = (0,
|
|
20
|
+
const connectionOptions = (0, get_kafka_config_js_1.getKafkaConfig)(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
21
21
|
return this._createDynamicModule(moduleOptions, {
|
|
22
22
|
global: moduleOptions.global,
|
|
23
23
|
providers: [
|
|
@@ -41,7 +41,7 @@ let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
|
41
41
|
inject: asyncOptions.inject,
|
|
42
42
|
useFactory: async (...args) => {
|
|
43
43
|
const opts = await asyncOptions.useFactory(...args);
|
|
44
|
-
return (0,
|
|
44
|
+
return (0, get_kafka_config_js_1.getKafkaConfig)(opts, asyncOptions.envPrefix);
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { clone } from '@jsopen/objects';
|
|
3
3
|
import { toBoolean, toInt } from 'putil-varhelpers';
|
|
4
|
-
export function
|
|
4
|
+
export function getKafkaConfig(moduleOptions, envPrefix = 'KAFKA_') {
|
|
5
5
|
const options = clone(moduleOptions);
|
|
6
6
|
const env = process.env;
|
|
7
7
|
options.brokers = options.brokers || (env[envPrefix + 'BROKERS'] ?? 'localhost').split(/\s*,\s*/);
|
package/esm/index.js
CHANGED
package/esm/kafka-core.module.js
CHANGED
|
@@ -7,14 +7,14 @@ import { ClientKafka, ClientsModule, Transport } from '@nestjs/microservices';
|
|
|
7
7
|
import * as colors from 'ansi-colors';
|
|
8
8
|
import { KAFKA_CONNECTION_OPTIONS, KAFKA_MODULE_ID } from './constants.js';
|
|
9
9
|
import { createLogCreator } from './create-log-creator.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getKafkaConfig } from './get-kafka-config.js';
|
|
11
11
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
12
12
|
let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
static forRoot(moduleOptions) {
|
|
17
|
-
const connectionOptions =
|
|
17
|
+
const connectionOptions = getKafkaConfig(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
18
18
|
return this._createDynamicModule(moduleOptions, {
|
|
19
19
|
global: moduleOptions.global,
|
|
20
20
|
providers: [
|
|
@@ -38,7 +38,7 @@ let KafkaCoreModule = KafkaCoreModule_1 = class KafkaCoreModule {
|
|
|
38
38
|
inject: asyncOptions.inject,
|
|
39
39
|
useFactory: async (...args) => {
|
|
40
40
|
const opts = await asyncOptions.useFactory(...args);
|
|
41
|
-
return
|
|
41
|
+
return getKafkaConfig(opts, asyncOptions.envPrefix);
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnestjs/kafka",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "NestJS extension library for Kafka",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
15
15
|
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
16
16
|
"@nestjs/microservices": "^10.0.0 || ^11.0.0",
|
|
17
|
-
"kafkajs": "^2.
|
|
17
|
+
"kafkajs": "^2.2.4"
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
package/types/index.d.cts
CHANGED
package/types/index.d.ts
CHANGED