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

0.2.0 • Public • Published

NestJS-Unleash-SDK

A NestJS module that uses Unleash SDK to manage feature flags.

code style: prettier


Getting Started

To start using this module, you can follow these steps:

  • Install the package by running npm install nestjs-unleash-sdk
  • Import the module into your NestJS application using the following code:

Setup the module

import { Module } from '@nestjs/common';
import { UnleashModule } from 'nestjs-unleash-sdk';

@Module({
  imports: [
    UnleashModule.forRoot({
      url: 'https://unleash.herokuapp.com/api',
      appName: 'nestjs-app',
      instanceId: 'to-define',
    }),
  ],
})
export class AppModule {}

Check a feature flag

import { Controller, Get, Query } from '@nestjs/common';
import { UnleashService } from 'nestjs-unleash-sdk';

@Controller()
export class AppController {
  constructor(private readonly unleashService: UnleashService) { }

  @Get()
  getHello(@Query('email') email: string): any {
    const options = { userId: email };
    const isEnabled = this.unleashService.client.isEnabled('feat', options);
    return isEnabled;
  }
}

TODO

  • Add feature flag decorators

Readme

Keywords

none

Package Sidebar

Install

npm i nestjs-unleash-sdk

Weekly Downloads

265

Version

0.2.0

License

MIT

Unpacked Size

23.2 kB

Total Files

30

Last publish

Collaborators

  • bamada