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

@nestjs/elasticsearch

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/elasticsearch - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

dist/elasticsearch.constants.d.ts

8

dist/elasticsearch-client.provider.d.ts

@@ -1,6 +0,8 @@

import { Client, ConfigOptions } from 'elasticsearch';
import { Client } from 'elasticsearch';
import { ElasticsearchModuleOptions } from './intefaces';
export declare const ELASTICSEARCH_CLIENT = "ELASTICSEARCH_CLIENT";
export declare const createElasticsearchClient: (options: ConfigOptions) => {
export declare const createElasticsearchClient: () => {
provide: string;
useFactory: () => Client;
useFactory: (options: ElasticsearchModuleOptions) => Client;
inject: string[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const elasticsearch_1 = require("elasticsearch");
const elasticsearch_constants_1 = require("./elasticsearch.constants");
exports.ELASTICSEARCH_CLIENT = 'ELASTICSEARCH_CLIENT';
exports.createElasticsearchClient = (options) => ({
exports.createElasticsearchClient = () => ({
provide: exports.ELASTICSEARCH_CLIENT,
useFactory: () => {
useFactory: (options) => {
return new elasticsearch_1.Client(options);
},
inject: [elasticsearch_constants_1.ELASTICSEARCH_MODULE_OPTIONS]
});
import { DynamicModule } from '@nestjs/common';
import { ConfigOptions } from 'elasticsearch';
import { ElasticsearchModuleAsyncOptions, ElasticsearchModuleOptions } from './intefaces/elasticsearch-module-options.interface';
export declare class ElasticsearchModule {
static register(options: ConfigOptions): DynamicModule;
static register(options: ElasticsearchModuleOptions): DynamicModule;
static registerAsync(options: ElasticsearchModuleAsyncOptions): DynamicModule;
private static createAsyncProviders;
private static createAsyncOptionsProvider;
}

@@ -8,2 +8,10 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,2 +21,3 @@ var ElasticsearchModule_1;

const elasticsearch_client_provider_1 = require("./elasticsearch-client.provider");
const elasticsearch_constants_1 = require("./elasticsearch.constants");
const elasticsearch_service_1 = require("./elasticsearch.service");

@@ -19,5 +28,43 @@ let ElasticsearchModule = ElasticsearchModule_1 = class ElasticsearchModule {

module: ElasticsearchModule_1,
providers: [elasticsearch_client_provider_1.createElasticsearchClient(options)]
providers: [
elasticsearch_client_provider_1.createElasticsearchClient(),
{ provide: elasticsearch_constants_1.ELASTICSEARCH_MODULE_OPTIONS, useValue: options }
]
};
}
static registerAsync(options) {
return {
module: ElasticsearchModule_1,
providers: [
elasticsearch_client_provider_1.createElasticsearchClient(),
...this.createAsyncProviders(options)
]
};
}
static createAsyncProviders(options) {
if (options.useExisting || options.useFactory) {
return [this.createAsyncOptionsProvider(options)];
}
return [
this.createAsyncOptionsProvider(options),
{
provide: options.useClass,
useClass: options.useClass
}
];
}
static createAsyncOptionsProvider(options) {
if (options.useFactory) {
return {
provide: elasticsearch_constants_1.ELASTICSEARCH_MODULE_OPTIONS,
useFactory: options.useFactory,
inject: options.inject || []
};
}
return {
provide: elasticsearch_constants_1.ELASTICSEARCH_MODULE_OPTIONS,
useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () { return yield optionsFactory.createElasticsearchOptions(); }),
inject: [options.useExisting || options.useClass]
};
}
};

@@ -24,0 +71,0 @@ ElasticsearchModule = ElasticsearchModule_1 = __decorate([

export * from './elasticsearch.module';
export * from './elasticsearch.service';
export * from './intefaces';
{
"name": "@nestjs/elasticsearch",
"version": "0.0.1",
"version": "0.1.0",
"description": "Nest - modern, fast, powerful node.js web framework (@elasticsearch)",

@@ -8,3 +8,3 @@ "author": "Kamil Mysliwiec",

"scripts": {
"build": "tsc -p tsconfig.json",
"build": "rm -rf dist && tsc -p tsconfig.json",
"precommit": "lint-staged",

@@ -11,0 +11,0 @@ "prepublish:npm": "npm run build",

@@ -39,7 +39,28 @@ <p align="center">

TBC
1. Import `ElasticsearchModule`:
```typescript
@Module({
imports: [ElasticsearchModule.register({
host: 'localhost:9200',
log: 'trace',
})],
providers: [...],
})
export class SearchModule {}
```
2. Inject `ElasticsearchService`:
```typescript
@Injectable()
export class SearchService {
constructor(private readonly elasticsearchService: ElasticsearchService) {}
}
```
## API Spec
TBC
The `ElasticsearchService` exposes native [elasticsearch](https://www.npmjs.com/package/elasticsearch) methods and wraps them in the Observable, [read more](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html). The `ElasticsearchModule.register()` takes `options` object as an argument, [read more](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html).

@@ -46,0 +67,0 @@ ## Support

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