Detalhes do pacote

nestjs-etcd

aleksandryackovlev1.1kMIT0.2.0

Etcd3 module for Nest framework

nestjs, nest, nodejs, typescript

readme (leia-me)

npm deps Build Status codecov size

Description

Etcd3 module for Nest.

Installation

$ npm i --save nestjs-etcd

Getting Started

To register the EtcdModule in app.module.ts

import { Module } from '@nestjs/common';
import { EtcdModule} from 'nestjs-etcd';

@Module({
    imports: [
        EtcdModule.forRoot({
            name: 'client_name', // optional, default to 'default'
            hosts: `http://0.0.0.0:2379`,
        }),
    ],
})
export class AppModule {}

With Async

import { Module } from '@nestjs/common';
import { EtcdModule} from 'nestjs-etcd';

@Module({
    imports: [
        EtcdModule.forRootAsync({
                name: 'client_name', // optional, default to 'default'
                useFactory: (configService: ConfigService) => ({
                hosts: configService.get('hosts'),
            }),
            inject:[ConfigService],
        }),
    ],
})
export class AppModule {}

Module supports all the options for Etcd3 package (see https://microsoft.github.io/etcd3/interfaces/ioptions.html):

type EtcdModuleOptions = IOptions & { name?: string }

Usage

import { Injectable } from '@nestjs/common';
import { Etcd3 } from 'etcd3';
import { InjectClient } from 'nestjs-etcd';

@Injectable()
export class TestService {
    // client_name is optional for InjectClient, default to 'default'
    constructor(@InjectClient('client_name') private readonly client: Etcd3) {}

    find(key: string): Promise<string> {
        return this.client.get(key).string();
    }
}

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING

License

MIT

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.2.0 (2021-01-07)

Features

  • options: add namespace to module options (836a3ec)
  • utils: export utils from the module (fe640ac)

0.1.1 (2021-01-06)

0.1.0 (2021-01-06)

Features

  • constants: change the format for constants (a1bff3f)
  • core: add forRootAsync method to the core module (6c5a99b)
  • core: extend the core module for working with multiple clients (19ada8d)
  • decorators: add decorator for injecting clients (28437b7)
  • etcd3: add basic etcd module (920d0c8)
  • module: export forRootAsync from the module (12bbeca)
  • options: add async options interfaces (cd49688)
  • options: extend options interface with the name option (aa78cd4)
  • utils: add utils for working with multiple clients (997f311)

Bug Fixes

  • configs: fix typos in configs (54ce781)