Nuanced Pterodactyl Monk

    nestjs-etcd
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.0 • Public • Published

    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

    Install

    npm i nestjs-etcd

    DownloadsWeekly Downloads

    33

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    19 kB

    Total Files

    20

    Last publish

    Collaborators

    • aleksandryackovlev