1.7.0 • Published 10 months ago

@xnestjs/elasticsearch v1.7.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

@xnestjs/elasticsearch

NestJS extension library for ElasticSearch

Install

npm install @xnestjs/elasticsearch
# or using yarn
yarn add @xnestjs/elasticsearch

Usage

Register sync

An example of nestjs module that import the @xnestjs/elasticsearch

// module.ts
import { Module } from '@nestjs/common';
import { ElasticsearchModule } from '@xnestjs/elasticsearch';

@Module({
    imports: [
        ElasticsearchModule.forRoot({
            useValue: {
                node: 'http://localhost:9201',
            },
        }),
    ],
})
export class MyModule {
}

Register async

An example of nestjs module that import the @xnestjs/elasticsearch async

// module.ts
import { Module } from '@nestjs/common';
import { ElasticsearchModule } from '@xnestjs/elasticsearch';

@Module({
    imports: [
        ElasticsearchModule.forRootAsync({
            inject: [ConfigModule],
            useFactory: (config: ConfigService) => ({
                node: config.get('ELASTIC_NODE'),
            }),
        }),
    ]
})
export class MyModule {
}

Environment Variables

The library supports configuration through environment variables. Environment variables below is accepted. All environment variables starts with prefix (MONGODB_). This can be configured while registering the module.

<--- BEGIN env --->

Environment VariableTypeDefaultDescription
ELASTIC_NODEStringhttp://localhost:9200Elasticsearch node settings, if there is only one node. Required if NODES or CLOUD_ID is not set.
ELASTIC_NODESStringElasticsearch node settings, if there is only one node. Required if NODE or CLOUD_ID is not set.
ELASTIC_NAMEStringelasticsearch-jsA name for client
ELASTIC_MAX_RESPONSE_SIZENumberWhen configured, verifies that the uncompressed response size is lower than the configured number. If it's higher, it will abort the request.
ELASTIC_MAX_COMPRESSED_RESPONSE_SIZENumberWhen configured, verifies that the compressed response size is lower than the configured number. If it's higher, it will abort the request.
ELASTIC_MAX_RETRIESNumber3Max number of retries for each request
ELASTIC_REQUEST_TIMEOUTNumber30000Max request timeout in milliseconds for each request
ELASTIC_PING_TIMEOUTNumber3000Max number of milliseconds a ClusterConnectionPool will wait when pinging nodes before marking them dead
ELASTIC_AUTH_USERNAMEStringBasicAuth username
ELASTIC_AUTH_PASSWORDStringBasicAuth password
ELASTIC_AUTH_BEARERStringBearerAuth bearer header value
ELASTIC_AUTH_API_KEYStringApiKeyAuth api key
ELASTIC_API_KEY_IDStringApiKeyAuth api key id
ELASTIC_TLSBooleanFalseEnabled the TLS connection
ELASTIC_TLS_CA_CERTStringOptionally override the trusted CA certificates. Default is to trust the well-known CAs curated by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly specified using this option.
ELASTIC_TLS_CERT_FILEStringThe File that contains Cert chains in PEM format.
ELASTIC_TLS_KEY_FILEStringThe File that contains private keys in PEM format.
ELASTIC_TLS_KEY_PASSPHRASEStringPFX or PKCS12 encoded private key and certificate chain.
ELASTIC_TLS_REJECT_UNAUTHORIZEDBooleanFalseIf 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.
ELASTIC_CA_FINGERPRINTStringIf 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

<--- END env --->

1.7.0

10 months ago

1.6.4

10 months ago

1.6.3

10 months ago

1.6.2

10 months ago

1.5.3

10 months ago

1.6.1

10 months ago

1.5.2

10 months ago

1.6.0

10 months ago

1.5.1

10 months ago

1.5.0

10 months ago

1.3.0

10 months ago