@josemarinho/unleash
v0.0.21
Published
NestJS library integrate with Unleash
Downloads
2
Readme
Description
Nest Lib To Communicate With Unleash Feature Toggle.
Installation
$ npm install @josemarinho/unleash
Running the app
Once the installation process is complete, we can import the UnleashModule into the root AppModule.
import { Module } from '@nestjs/common';
import { UnleashModule } from '@josemarinho/unleash';
@Module({
imports: [
UnleashModule.forRoot({
appName: 'app-name',
url: 'unleash-url',
instanceId: 'instance-id',
http: {
headers: {
Authorization: 'UNLEASH_API_TOKEN',
},
},
}),
],
...
})
export class AppModule {}
Utilization
For get feature toggles from unleash, its necessary inject UnleashService
import { Injectable } from '@nestjs/common';
import { UnleashService } from '@josemarinho/unleash';
@Injectable()
export class AppService {
constructor(private readonly unleash: UnleashService) {}
async get(key: string) {
return await this.unleash.isEnabled(key);
}
}
After your app it's ready to running.