@xnestjs/elasticsearch 1.7.1 → 1.8.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/README.md
CHANGED
|
@@ -22,16 +22,15 @@ import { Module } from '@nestjs/common';
|
|
|
22
22
|
import { ElasticsearchModule } from '@xnestjs/elasticsearch';
|
|
23
23
|
|
|
24
24
|
@Module({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
imports: [
|
|
26
|
+
ElasticsearchModule.forRoot({
|
|
27
|
+
useValue: {
|
|
28
|
+
node: 'http://localhost:9201',
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
32
|
})
|
|
33
|
-
export class MyModule {
|
|
34
|
-
}
|
|
33
|
+
export class MyModule {}
|
|
35
34
|
```
|
|
36
35
|
|
|
37
36
|
### Register async
|
|
@@ -44,28 +43,27 @@ import { Module } from '@nestjs/common';
|
|
|
44
43
|
import { ElasticsearchModule } from '@xnestjs/elasticsearch';
|
|
45
44
|
|
|
46
45
|
@Module({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
imports: [
|
|
47
|
+
ElasticsearchModule.forRootAsync({
|
|
48
|
+
inject: [ConfigModule],
|
|
49
|
+
useFactory: (config: ConfigService) => ({
|
|
50
|
+
node: config.get('ELASTIC_NODE'),
|
|
51
|
+
}),
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
55
54
|
})
|
|
56
|
-
export class MyModule {
|
|
57
|
-
}
|
|
55
|
+
export class MyModule {}
|
|
58
56
|
```
|
|
59
57
|
|
|
60
58
|
## Environment Variables
|
|
61
59
|
|
|
62
60
|
The library supports configuration through environment variables. Environment variables below is accepted.
|
|
63
|
-
All environment variables starts with prefix (
|
|
61
|
+
All environment variables starts with prefix (MONGODB\_). This can be configured while registering the module.
|
|
64
62
|
|
|
65
|
-
|
|
63
|
+
<!--- BEGIN env --->
|
|
66
64
|
|
|
67
65
|
| Environment Variable | Type | Default | Description |
|
|
68
|
-
|
|
66
|
+
| ------------------------------------ | ------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
69
67
|
| ELASTIC_NODE | String | http://localhost:9200 | Elasticsearch node settings, if there is only one node. Required if `NODES` or `CLOUD_ID` is not set. |
|
|
70
68
|
| ELASTIC_NODES | String | | Elasticsearch node settings, if there is only one node. Required if `NODE` or `CLOUD_ID` is not set. |
|
|
71
69
|
| ELASTIC_NAME | String | elasticsearch-js | A name for client |
|
|
@@ -87,4 +85,4 @@ All environment variables starts with prefix (MONGODB_). This can be configured
|
|
|
87
85
|
| 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. |
|
|
88
86
|
| 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
87
|
|
|
90
|
-
|
|
88
|
+
<!--- END env --->
|
|
@@ -46,8 +46,13 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
|
|
|
46
46
|
}
|
|
47
47
|
static _createDynamicModule(moduleOptions, metadata) {
|
|
48
48
|
const token = moduleOptions.token ?? elasticsearch_1.ElasticsearchService;
|
|
49
|
-
const logger = typeof moduleOptions.logger === 'string'
|
|
50
|
-
|
|
49
|
+
const logger = typeof moduleOptions.logger === 'string'
|
|
50
|
+
? new common_1.Logger(moduleOptions.logger)
|
|
51
|
+
: moduleOptions.logger;
|
|
52
|
+
const exports = [
|
|
53
|
+
constants_js_1.ELASTICSEARCH_CONNECTION_OPTIONS,
|
|
54
|
+
...(metadata.exports ?? []),
|
|
55
|
+
];
|
|
51
56
|
const providers = [
|
|
52
57
|
...(metadata.providers ?? []),
|
|
53
58
|
{
|
|
@@ -23,8 +23,10 @@ function getElasticsearchConfig(moduleOptions, prefix = 'ELASTIC_') {
|
|
|
23
23
|
if (!(options.node || options.nodes))
|
|
24
24
|
options.node = 'http://localhost:9200';
|
|
25
25
|
options.maxRetries = options.maxRetries ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_RETRIES']);
|
|
26
|
-
options.requestTimeout =
|
|
27
|
-
|
|
26
|
+
options.requestTimeout =
|
|
27
|
+
options.requestTimeout ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'REQUEST_TIMEOUT']);
|
|
28
|
+
options.pingTimeout =
|
|
29
|
+
options.pingTimeout ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'PING_TIMEOUT']);
|
|
28
30
|
if (options.tls == null && (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS'])) {
|
|
29
31
|
options.tls = {
|
|
30
32
|
ca: [env[prefix + 'TLS_CA_CERT'] || ''],
|
|
@@ -65,9 +67,12 @@ function getElasticsearchConfig(moduleOptions, prefix = 'ELASTIC_') {
|
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
|
-
options.caFingerprint =
|
|
69
|
-
|
|
70
|
+
options.caFingerprint =
|
|
71
|
+
options.caFingerprint ?? env[prefix + 'CA_FINGERPRINT'];
|
|
72
|
+
options.maxResponseSize =
|
|
73
|
+
options.maxResponseSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_RESPONSE_SIZE']);
|
|
70
74
|
options.maxCompressedResponseSize =
|
|
71
|
-
options.maxCompressedResponseSize ??
|
|
75
|
+
options.maxCompressedResponseSize ??
|
|
76
|
+
(0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_COMPRESSED_RESPONSE_SIZE']);
|
|
72
77
|
return options;
|
|
73
78
|
}
|
|
@@ -2,10 +2,10 @@ var ElasticsearchCoreModule_1;
|
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
3
|
import assert from 'node:assert';
|
|
4
4
|
import * as crypto from 'node:crypto';
|
|
5
|
-
import { Inject, Logger } from '@nestjs/common';
|
|
6
|
-
import { ElasticsearchModule, ElasticsearchService } from '@nestjs/elasticsearch';
|
|
5
|
+
import { Inject, Logger, } from '@nestjs/common';
|
|
6
|
+
import { ElasticsearchModule, ElasticsearchService, } from '@nestjs/elasticsearch';
|
|
7
7
|
import colors from 'ansi-colors';
|
|
8
|
-
import { ELASTICSEARCH_CONNECTION_OPTIONS, ELASTICSEARCH_MODULE_ID } from './constants.js';
|
|
8
|
+
import { ELASTICSEARCH_CONNECTION_OPTIONS, ELASTICSEARCH_MODULE_ID, } from './constants.js';
|
|
9
9
|
import { getElasticsearchConfig } from './get-elasticsearch-config.js';
|
|
10
10
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
11
11
|
let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCoreModule {
|
|
@@ -43,8 +43,13 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
|
|
|
43
43
|
}
|
|
44
44
|
static _createDynamicModule(moduleOptions, metadata) {
|
|
45
45
|
const token = moduleOptions.token ?? ElasticsearchService;
|
|
46
|
-
const logger = typeof moduleOptions.logger === 'string'
|
|
47
|
-
|
|
46
|
+
const logger = typeof moduleOptions.logger === 'string'
|
|
47
|
+
? new Logger(moduleOptions.logger)
|
|
48
|
+
: moduleOptions.logger;
|
|
49
|
+
const exports = [
|
|
50
|
+
ELASTICSEARCH_CONNECTION_OPTIONS,
|
|
51
|
+
...(metadata.exports ?? []),
|
|
52
|
+
];
|
|
48
53
|
const providers = [
|
|
49
54
|
...(metadata.providers ?? []),
|
|
50
55
|
{
|
|
@@ -19,8 +19,10 @@ export function getElasticsearchConfig(moduleOptions, prefix = 'ELASTIC_') {
|
|
|
19
19
|
if (!(options.node || options.nodes))
|
|
20
20
|
options.node = 'http://localhost:9200';
|
|
21
21
|
options.maxRetries = options.maxRetries ?? toInt(env[prefix + 'MAX_RETRIES']);
|
|
22
|
-
options.requestTimeout =
|
|
23
|
-
|
|
22
|
+
options.requestTimeout =
|
|
23
|
+
options.requestTimeout ?? toInt(env[prefix + 'REQUEST_TIMEOUT']);
|
|
24
|
+
options.pingTimeout =
|
|
25
|
+
options.pingTimeout ?? toInt(env[prefix + 'PING_TIMEOUT']);
|
|
24
26
|
if (options.tls == null && toBoolean(env[prefix + 'TLS'])) {
|
|
25
27
|
options.tls = {
|
|
26
28
|
ca: [env[prefix + 'TLS_CA_CERT'] || ''],
|
|
@@ -61,9 +63,12 @@ export function getElasticsearchConfig(moduleOptions, prefix = 'ELASTIC_') {
|
|
|
61
63
|
};
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
|
-
options.caFingerprint =
|
|
65
|
-
|
|
66
|
+
options.caFingerprint =
|
|
67
|
+
options.caFingerprint ?? env[prefix + 'CA_FINGERPRINT'];
|
|
68
|
+
options.maxResponseSize =
|
|
69
|
+
options.maxResponseSize ?? toInt(env[prefix + 'MAX_RESPONSE_SIZE']);
|
|
66
70
|
options.maxCompressedResponseSize =
|
|
67
|
-
options.maxCompressedResponseSize ??
|
|
71
|
+
options.maxCompressedResponseSize ??
|
|
72
|
+
toInt(env[prefix + 'MAX_COMPRESSED_RESPONSE_SIZE']);
|
|
68
73
|
return options;
|
|
69
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnestjs/elasticsearch",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "NestJS extension library for ElasticSearch",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,5 +52,8 @@
|
|
|
52
52
|
"keywords": [
|
|
53
53
|
"nestjs",
|
|
54
54
|
"elasticsearch"
|
|
55
|
-
]
|
|
55
|
+
],
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
}
|
|
56
59
|
}
|