
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@exact-team/nestjs-feature-toggle
Advanced tools
Библиотека для условного включения и отключения контроллеров и методов в NestJS на основе фич-флагов, хранящихся в ConfigService
(.env)
@FeatureToggle('FLAG_NAME')
для классов и методовFeatureToggleGuard
для проверки фич-флаговFeatureToggleModule.forRoot()
для простого подключенияnpm install @exact-tema/nestjs-feature-toggle
или
yarn add @exact-tema/nestjs-feature-toggle
// src/app.module.ts
import { Module } from '@nestjs/common';
import { FeatureToggleModule } from 'nestjs-feature-toggle-lib';
@Module({
imports: [
FeatureToggleModule.forRoot(),
// ... другие модули
],
})
export class AppModule {}
// src/new-api.controller.ts
import { Controller, Get } from '@nestjs/common';
import { FeatureToggle } from 'nestjs-feature-toggle-lib';
@FeatureToggle('NEW_API')
@Controller('new-api')
export class NewApiController {
@Get()
findAll() {
return ['item1', 'item2'];
}
@Get('beta')
@FeatureToggle('BETA_FEATURE')
findBeta() {
return ['beta-item'];
}
}
.env
NEW_API=true
BETA_FEATURE=false
Метод или контроллер будут доступны только при значении флага true
.
FeatureToggleModule.forRoot(): DynamicModule
Подключает глобальный Guard и ConfigModule
:
ConfigModule
{ provide: APP_GUARD, useClass: FeatureToggleGuard }
@FeatureToggle(featureName: string)
Декоратор, который можно применять к:
Параметры:
featureName: string
— ключ флага в ConfigService
FeatureToggleGuard
(CanActivate)featureName
с метода или классаConfigService
true
— пропускает, иначе кидает NotFoundException()
// src/app.module.ts
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { FeatureToggleModule } from 'nestjs-feature-toggle-lib';
import { NewApiController } from './new-api.controller';
@Module({
imports: [ConfigModule.forRoot({ isGlobal: true }), FeatureToggleModule.forRoot()],
controllers: [NewApiController],
})
export class AppModule {}
MIT
FAQs
feature toggle for nestjs
The npm package @exact-team/nestjs-feature-toggle receives a total of 1 weekly downloads. As such, @exact-team/nestjs-feature-toggle popularity was classified as not popular.
We found that @exact-team/nestjs-feature-toggle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.