https://github.com/aleksandryackovlev/nestjs-etcd
Etcd3 module for Nest framework (node.js)
https://github.com/aleksandryackovlev/nestjs-etcd
etcd etcd3 javascript nest nestjs nodejs typescript
Last synced: 11 months ago
JSON representation
Etcd3 module for Nest framework (node.js)
- Host: GitHub
- URL: https://github.com/aleksandryackovlev/nestjs-etcd
- Owner: aleksandryackovlev
- License: mit
- Created: 2020-12-28T18:25:55.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-07T13:43:05.000Z (over 5 years ago)
- Last Synced: 2025-07-15T20:21:52.668Z (11 months ago)
- Topics: etcd, etcd3, javascript, nest, nestjs, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 170 KB
- Stars: 0
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![npm][npm]][npm-url]
[![deps][deps]][deps-url]
[](https://github.com/aleksandryackovlev/nestjs-etcd/actions)
[](https://codecov.io/gh/aleksandryackovlev/nestjs-etcd)
[](https://packagephobia.now.sh/result?p=nestjs-etcd)
## Description
[Etcd3](https://github.com/microsoft/etcd3) module for [Nest](https://github.com/nestjs/nest).
## Installation
```bash
$ npm i --save nestjs-etcd
```
### Getting Started
To register the EtcdModule in `app.module.ts`
```typescript
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
```typescript
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](https://www.npmjs.com/package/etcd3) package (see https://microsoft.github.io/etcd3/interfaces/ioptions.html):
```typescript
type EtcdModuleOptions = IOptions & { name?: string }
```
### Usage
```typescript
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 {
return this.client.get(key).string();
}
}
```
## Contributing
Please take a moment to read our contributing guidelines if you haven't yet done so.
[CONTRIBUTING](./.github/CONTRIBUTING.md)
## License
[MIT](./LICENSE)
[npm]: https://img.shields.io/npm/v/nestjs-etcd.svg
[npm-url]: https://npmjs.com/package/nestjs-etcd
[deps]: https://david-dm.org/aleksandryackovlev/nestjs-etcd.svg
[deps-url]: https://david-dm.org/aleksandryackovlev/nestjs-etcd