@xnestjs/elasticsearch 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/elasticsearch-core.module.js +4 -4
- package/cjs/{get-connection-options.js → get-elasticsearch-config.js} +2 -2
- package/cjs/index.js +1 -1
- package/esm/elasticsearch-core.module.js +4 -4
- package/esm/{get-connection-options.js → get-elasticsearch-config.js} +1 -1
- package/esm/index.js +1 -1
- package/package.json +1 -1
- package/types/get-elasticsearch-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 (MONGODB_). 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
|
| ELASTIC_NODE | String | http://localhost:9200 | Elasticsearch node settings, if there is only one node. Required if `NODES` or `CLOUD_ID` is not set. |
|
|
@@ -84,3 +86,5 @@ All environment variables starts with prefix (MONGODB_). This can be configured
|
|
|
84
86
|
| ELASTIC_TLS_KEY_PASSPHRASE | String | | PFX or PKCS12 encoded private key and certificate chain. |
|
|
85
87
|
| ELASTIC_TLS_REJECT_UNAUTHORIZED | Boolean | False | If true the server will reject any connection which is notauthorized with the list of supplied CAs. This option only has an effect if requestCert is true. |
|
|
86
88
|
| ELASTIC_CA_FINGERPRINT | String | | If configured, verifies that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint; only accepts SHA256 digest fingerprints |
|
|
89
|
+
|
|
90
|
+
<--- END env --->
|
|
@@ -9,14 +9,14 @@ const common_1 = require("@nestjs/common");
|
|
|
9
9
|
const elasticsearch_1 = require("@nestjs/elasticsearch");
|
|
10
10
|
const colors = tslib_1.__importStar(require("ansi-colors"));
|
|
11
11
|
const constants_js_1 = require("./constants.js");
|
|
12
|
-
const
|
|
12
|
+
const get_elasticsearch_config_js_1 = require("./get-elasticsearch-config.js");
|
|
13
13
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
14
14
|
let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCoreModule {
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
18
|
static forRoot(moduleOptions) {
|
|
19
|
-
const connectionOptions = (0,
|
|
19
|
+
const connectionOptions = (0, get_elasticsearch_config_js_1.getElasticsearchConfig)(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
20
20
|
return this._createDynamicModule(moduleOptions, {
|
|
21
21
|
global: moduleOptions.global,
|
|
22
22
|
providers: [
|
|
@@ -40,7 +40,7 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
|
|
|
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_elasticsearch_config_js_1.getElasticsearchConfig)(opts, asyncOptions.envPrefix);
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
],
|
|
@@ -77,7 +77,7 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
|
|
|
77
77
|
return {
|
|
78
78
|
module: ElasticsearchCoreModule_1,
|
|
79
79
|
providers,
|
|
80
|
-
|
|
80
|
+
global: opts.global,
|
|
81
81
|
imports: [
|
|
82
82
|
elasticsearch_1.ElasticsearchModule.registerAsync({
|
|
83
83
|
imports: [
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getElasticsearchConfig = getElasticsearchConfig;
|
|
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 getElasticsearchConfig(moduleOptions, prefix = 'ELASTIC_') {
|
|
9
9
|
const options = (0, objects_1.clone)(moduleOptions);
|
|
10
10
|
const env = node_process_1.default.env;
|
|
11
11
|
options.node = options.node || env[prefix + 'NODE'];
|
package/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.ElasticsearchService = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./elasticsearch.module.js"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./get-
|
|
7
|
+
tslib_1.__exportStar(require("./get-elasticsearch-config.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
9
9
|
var elasticsearch_1 = require("@nestjs/elasticsearch");
|
|
10
10
|
Object.defineProperty(exports, "ElasticsearchService", { enumerable: true, get: function () { return elasticsearch_1.ElasticsearchService; } });
|
|
@@ -6,14 +6,14 @@ import { Inject, Logger } from '@nestjs/common';
|
|
|
6
6
|
import { ElasticsearchModule, ElasticsearchService } from '@nestjs/elasticsearch';
|
|
7
7
|
import * as colors from 'ansi-colors';
|
|
8
8
|
import { ELASTICSEARCH_CONNECTION_OPTIONS, ELASTICSEARCH_MODULE_ID } from './constants.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getElasticsearchConfig } from './get-elasticsearch-config.js';
|
|
10
10
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
11
11
|
let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCoreModule {
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
15
|
static forRoot(moduleOptions) {
|
|
16
|
-
const connectionOptions =
|
|
16
|
+
const connectionOptions = getElasticsearchConfig(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
17
17
|
return this._createDynamicModule(moduleOptions, {
|
|
18
18
|
global: moduleOptions.global,
|
|
19
19
|
providers: [
|
|
@@ -37,7 +37,7 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
|
|
|
37
37
|
inject: asyncOptions.inject,
|
|
38
38
|
useFactory: async (...args) => {
|
|
39
39
|
const opts = await asyncOptions.useFactory(...args);
|
|
40
|
-
return
|
|
40
|
+
return getElasticsearchConfig(opts, asyncOptions.envPrefix);
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
],
|
|
@@ -74,7 +74,7 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
|
|
|
74
74
|
return {
|
|
75
75
|
module: ElasticsearchCoreModule_1,
|
|
76
76
|
providers,
|
|
77
|
-
|
|
77
|
+
global: opts.global,
|
|
78
78
|
imports: [
|
|
79
79
|
ElasticsearchModule.registerAsync({
|
|
80
80
|
imports: [
|
|
@@ -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 getElasticsearchConfig(moduleOptions, prefix = 'ELASTIC_') {
|
|
5
5
|
const options = clone(moduleOptions);
|
|
6
6
|
const env = process.env;
|
|
7
7
|
options.node = options.node || env[prefix + 'NODE'];
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
package/types/index.d.cts
CHANGED
package/types/index.d.ts
CHANGED