Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nestjs-opensearch

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-opensearch

OpenSearch module for NestJS framework

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by1.64%
Maintainers
1
Weekly downloads
 
Created
Source

Nest Logo

nestjs-opensearch

OpenSearch module for NestJS framework
Installation · Usage · Issues
NPM Version Package License NPM Downloads


Installation

For NPM:

$ npm i --save nestjs-opensearch @opensearch-project/opensearch

For Yarn:

$ yarn add nestjs-opensearch @opensearch-project/opensearch

Usage

Module for single connection:

import { OpensearchModule } from 'nestjs-opensearch';

@Module({
  imports: [
    OpensearchModule.forRoot({
      node: 'https://*****.es.amazonaws.com',
    }),
  ],
  providers: (...),
})
export class SearchModule { }

Module for multiple connections:

import { OpensearchModule } from 'nestjs-opensearch';

@Module({
  imports: [
    OpensearchModule.forRoot({
      clientName: 'foo',
      node: 'https://*****.es.amazonaws.com',
    }),
    OpensearchModule.forRoot({
      clientName: 'bar',
      node: 'https://*****.es.amazonaws.com',
    }),
  ],
  providers: (...),
})
export class SearchModule { }

Module for async configuration:

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:

import { InjectOpensearchClient, OpensearchClient } from 'nestjs-opensearch';

@Injectable()
export class SearchService {
  public constructor(
    // Inject the default client
    private readonly searchClient: OpensearchClient,

    // Also inject the default client
    @InjectOpensearchClient()
    private readonly alsoSearchClient: OpensearchClient,

    // Inject the 'foo' named client
    @InjectOpensearchClient('foo')
    private readonly fooSearchClient: OpensearchClient,
  ) { }
}

Keywords

FAQs

Package last updated on 11 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc