@xnestjs/elasticsearch 1.6.2 → 1.6.3

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.
@@ -106,16 +106,16 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
106
106
  this.connectionOptions = connectionOptions;
107
107
  }
108
108
  async onApplicationBootstrap() {
109
- if (this.logger) {
110
- const options = this.connectionOptions;
111
- const nodes = options.node || options.nodes;
112
- this.logger.log(`Connecting to ElasticSearch at ${colors.blue(String(nodes))}`);
113
- common_1.Logger.flush();
114
- await this.client.ping({}).catch(e => {
115
- this.logger.error('ElasticSearch connection failed: ' + e.message);
116
- throw e;
117
- });
118
- }
109
+ const options = this.connectionOptions;
110
+ if (options.lazyConnect)
111
+ return;
112
+ const nodes = options.node || options.nodes;
113
+ this.logger?.log(`Connecting to ElasticSearch at ${colors.blue(String(nodes))}`);
114
+ common_1.Logger.flush();
115
+ await this.client.ping({}).catch(e => {
116
+ this.logger.error('ElasticSearch connection failed: ' + e.message);
117
+ throw e;
118
+ });
119
119
  }
120
120
  onApplicationShutdown() {
121
121
  return this.client.close();
@@ -103,16 +103,16 @@ let ElasticsearchCoreModule = ElasticsearchCoreModule_1 = class ElasticsearchCor
103
103
  this.connectionOptions = connectionOptions;
104
104
  }
105
105
  async onApplicationBootstrap() {
106
- if (this.logger) {
107
- const options = this.connectionOptions;
108
- const nodes = options.node || options.nodes;
109
- this.logger.log(`Connecting to ElasticSearch at ${colors.blue(String(nodes))}`);
110
- Logger.flush();
111
- await this.client.ping({}).catch(e => {
112
- this.logger.error('ElasticSearch connection failed: ' + e.message);
113
- throw e;
114
- });
115
- }
106
+ const options = this.connectionOptions;
107
+ if (options.lazyConnect)
108
+ return;
109
+ const nodes = options.node || options.nodes;
110
+ this.logger?.log(`Connecting to ElasticSearch at ${colors.blue(String(nodes))}`);
111
+ Logger.flush();
112
+ await this.client.ping({}).catch(e => {
113
+ this.logger.error('ElasticSearch connection failed: ' + e.message);
114
+ throw e;
115
+ });
116
116
  }
117
117
  onApplicationShutdown() {
118
118
  return this.client.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xnestjs/elasticsearch",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "NestJS extension library for ElasticSearch",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
package/types/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Logger } from '@nestjs/common';
3
3
  import type { ModuleMetadata } from '@nestjs/common/interfaces';
4
4
  import type { InjectionToken } from '@nestjs/common/interfaces/modules/injection-token.interface';
5
5
  export interface ElasticsearchConnectionOptions extends ClientOptions {
6
+ lazyConnect?: boolean;
6
7
  }
7
8
  interface BaseModuleOptions {
8
9
  token?: InjectionToken;