nestjs-opensearch
Advanced tools
Comparing version 0.0.1 to 0.1.0
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -1,1 +0,1 @@ | ||
export declare const InjectOpensearchClient: (clientName?: string | symbol | undefined) => (target: object, key: string | symbol, index?: number | undefined) => void; | ||
export declare const InjectOpensearchClient: (clientName?: string | symbol) => (target: object, key: string | symbol, index?: number | undefined) => void; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
{ | ||
"name": "nestjs-opensearch", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"author": "neoatlan", | ||
@@ -25,15 +25,15 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"@nestjs/common": "^8.0.0", | ||
"@opensearch-project/opensearch": "^1.0.0" | ||
"@nestjs/common": "^8.0.0 || ^9.0.0", | ||
"@opensearch-project/opensearch": "^1.0.0 || ^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/common": "^8.2.2", | ||
"@opensearch-project/opensearch": "^1.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"eslint": "^8.3.0", | ||
"@nestjs/common": "^9.0.3", | ||
"@opensearch-project/opensearch": "^2.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.30.6", | ||
"@typescript-eslint/parser": "^5.30.6", | ||
"eslint": "^8.20.0", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.4.0", | ||
"typescript": "^4.5.2" | ||
"rxjs": "^7.5.6", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
# nestjs-opensearch | ||
OpenSearch (alternative to Elasticsearch) module for NestJS framework | ||
OpenSearch module for NestJS framework | ||
@@ -15,3 +15,3 @@ ## Installation | ||
## Usage | ||
Module for only one connection: | ||
Module for single connection: | ||
```typescript | ||
@@ -31,3 +31,3 @@ import { OpensearchModule } from 'nestjs-opensearch'; | ||
Module for multiple connection: | ||
Module for multiple connections: | ||
```typescript | ||
@@ -54,2 +54,23 @@ import { OpensearchModule } from 'nestjs-opensearch'; | ||
Module for async configuration: | ||
```typescript | ||
import { OpensearchModule } from 'nestjs-opensearch'; | ||
@Module({ | ||
imports: [ | ||
// See also: https://docs.nestjs.com/techniques/configuration | ||
ConfigModule, | ||
OpensearchModule.forRootAsync({ | ||
clientName: 'baz', | ||
inject: [ ConfigService ], | ||
useFactory: (configService) => ({ | ||
node: configService.get<string>('opensearch.node'), | ||
}), | ||
}), | ||
], | ||
providers: (...), | ||
}) | ||
export class SearchModule { } | ||
``` | ||
Client injection: | ||
@@ -62,13 +83,14 @@ ```typescript | ||
public constructor( | ||
// For default | ||
// Inject the default client | ||
private readonly searchClient: OpensearchClient, | ||
// Also for default | ||
@InjectOpensearchClient() private readonly searchClient: OpensearchClient, | ||
// Also inject the default client | ||
@InjectOpensearchClient() | ||
private readonly alsoSearchClient: OpensearchClient, | ||
// For 'foo' client | ||
@InjectOpensearchClient('foo') private readonly searchClient: OpensearchClient, | ||
// Inject the 'foo' named client | ||
@InjectOpensearchClient('foo') | ||
private readonly fooSearchClient: OpensearchClient, | ||
) { } | ||
} | ||
``` | ||
11664
164
93