From 4dd59c4a07fef05ed8d624acc6cdab5da6e4b332 Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Mon, 8 Jan 2024 22:16:51 -0300 Subject: [PATCH 01/22] docs: add quick start Signed-off-by: Luiz Ribeiro --- packages/nest/README.md | 73 ++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 44d4b8770..c22cf660e 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -25,12 +25,43 @@ [OpenFeature](https://openfeature.dev) is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool. + + ๐Ÿงช This SDK is experimental. -#### Here's a basic example of how to use the OpenFeature NestJS API with `InMemoryProvider`. +## Overview + +The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [OpenFeature Server SDK](). It's main capabilities are: +- Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; +- Supply custom parameter decorators (for controllers), that inject observables with feature flags resolution details; +- Inject context for flag evaluation seamlessly using NestJS interceptors +- Provide decorators for OpenFeature Client injection into NestJS services and controllers +- TODO: map other features + +## ๐Ÿš€ Quick start + +### Requirements + +- Node.js version 16+ +- NestJS + +### Install + +#### npm + +```sh +npm install --save @openfeature/nestjs-sdk +``` + +#### yarn -#### Registering the Nest.js SDK module in the App Module: +```sh +yarn add @openfeature/nestjs-sdk +``` + +### Usage +The example bellow shows how to use the `OpenFeatureModule` with OpenFeature's `InMemoryProvider`. ```ts import { Module } from '@nestjs/common'; import { FlagdProvider } from '@openfeature/flagd-provider'; @@ -46,11 +77,6 @@ import { InMemoryProvider } from '@openfeature/web-sdk'; variants: { default: true }, disabled: false }, - companyName: { - defaultVariant: 'default', - variants: { default: "BigCorp" }, - disabled: false - } }), providers: { differentProvider: new InMemoryProvider() @@ -61,7 +87,7 @@ import { InMemoryProvider } from '@openfeature/web-sdk'; export class AppModule {} ``` -#### Injecting a feature flag with header value in evaluation context into an endpoint handler method +With the `OpenFeatureModule` configured it is now possible to inject flag evaluation details into route handlers like in the following code snippet. ```ts import { Controller, ExecutionContext, Get } from '@nestjs/common'; @@ -70,19 +96,6 @@ import { BooleanFeatureFlag } from '@openfeature/nestjs-sdk'; import { EvaluationDetails } from '@openfeature/server-sdk'; import { Request } from 'express'; -function getContext(executionContext: ExecutionContext) { - const request = executionContext.switchToHttp().getRequest(); - const userId = request.header('x-user-id'); - - if (!userId) { - return undefined; - } - - return { - targetingKey: userId, - }; -} - @Controller() export class OpenFeatureController { @Get('/welcome') @@ -90,7 +103,6 @@ export class OpenFeatureController { @BooleanFeatureFlag({ flagKey: 'testBooleanFlag', defaultValue: false, - contextFactory: getContext, }) feature: Observable>, ) { @@ -103,7 +115,7 @@ export class OpenFeatureController { } ``` -#### Injecting the default and a named client into a service: +It is also possible to inject the default and a named client into a service via it's constructor. ```ts import { Injectable } from '@nestjs/common'; @@ -114,15 +126,22 @@ import { FeatureClient } from '@openfeature/nestjs-sdk'; export class OpenFeatureTestService { constructor( @FeatureClient() private defaultClient: Client, - @FeatureClient({ name: 'differentServer' }) private namedClient: Client, + @FeatureClient({ name: 'differentProvider' }) private namedClient: Client, ) { } - public async getMessage() { - const companyName = await this.defaultClient.getStringValue('companyName', 'Unknown Company'); - return `Hey User from ${companyName}`; + public async getBoolean() { + return await this.defaultClient.getBooleanValue('testBooleanFlag', false); } } ``` +## Module details + +### Configuration + +#### Flag evaluation context injection +Whenever a flag evaluation occours, context can be provided with information like user e-mail, role, targeting key, etc in order to trigger specific evaluation rules or logic. The `OpenFeatureModule` provides a way to configure context for each request using the `contextFactory` option. +The `contextFactory` is ran in a NestJS interceptor scope to configure the evaluation context and than it is used in every flag evaluation related to this request. +By default the interceptor is cofigured globally, but it can be changed by setting the `useGlobalInterceptor` to `false`. In this case it is still possible to configure a `contextFactory` that can be injected into route, module or controller bound interceptors. From d837440bebebc5240b740c8dc4355bc5c8b2e9de Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Tue, 9 Jan 2024 21:54:22 -0300 Subject: [PATCH 02/22] chore: add jsdocs Signed-off-by: Luiz Ribeiro --- packages/nest/README.md | 12 +++++----- .../src/evaluation-context-interceptor.ts | 22 +++++++++++++++++++ .../nest/src/evaluation-context-propagator.ts | 3 +-- packages/nest/src/open-feature.module.ts | 3 +++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index c22cf660e..437c13955 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -62,6 +62,7 @@ yarn add @openfeature/nestjs-sdk ### Usage The example bellow shows how to use the `OpenFeatureModule` with OpenFeature's `InMemoryProvider`. + ```ts import { Module } from '@nestjs/common'; import { FlagdProvider } from '@openfeature/flagd-provider'; @@ -115,7 +116,7 @@ export class OpenFeatureController { } ``` -It is also possible to inject the default and a named client into a service via it's constructor. +It is also possible to inject the default and a named OpenFeature client into a service via it's constructor with Nest dependency injection system. ```ts import { Injectable } from '@nestjs/common'; @@ -127,8 +128,7 @@ export class OpenFeatureTestService { constructor( @FeatureClient() private defaultClient: Client, @FeatureClient({ name: 'differentProvider' }) private namedClient: Client, - ) { - } + ) {} public async getBoolean() { return await this.defaultClient.getBooleanValue('testBooleanFlag', false); @@ -136,11 +136,9 @@ export class OpenFeatureTestService { } ``` -## Module details - -### Configuration +## Module aditional information -#### Flag evaluation context injection +### Flag evaluation context injection Whenever a flag evaluation occours, context can be provided with information like user e-mail, role, targeting key, etc in order to trigger specific evaluation rules or logic. The `OpenFeatureModule` provides a way to configure context for each request using the `contextFactory` option. The `contextFactory` is ran in a NestJS interceptor scope to configure the evaluation context and than it is used in every flag evaluation related to this request. diff --git a/packages/nest/src/evaluation-context-interceptor.ts b/packages/nest/src/evaluation-context-interceptor.ts index 154e39ce4..5bfbf6fa0 100644 --- a/packages/nest/src/evaluation-context-interceptor.ts +++ b/packages/nest/src/evaluation-context-interceptor.ts @@ -3,6 +3,28 @@ import { ContextFactory, ContextFactoryToken } from './context-factory'; import { Observable } from 'rxjs'; import { OpenFeature } from '@openfeature/server-sdk'; +/** NestJS interceptor used in {@link OpenFeatureModule} + * to configure flag evaluation context. + * + * This interceptor is configured globally by dafault, but if + * `useGlobalInterceptor` is set to `false` in {@link OpenFeatureModule} it needs to be configured for the specific controllers or routes. + * + * If just the interceptor class is passed to the `UseInterceptors` like below, the `contextFactory` provided in the {@link OpenFeatureModule} will be injected and used in order to create the context. + * ```ts + * //route interceptor + * @UseInterceptors(EvaluationContextInterceptor) + * @Get('/user-info') + * getUserInfo(){} + * ``` + * + * A different `contextFactory` can also be provided, but the interceptor instance has to be instantiated like in the following example. + * ```ts + * //route interceptor + * @UseInterceptors(new EvaluationContextInterceptor()) + * @Get('/user-info') + * getUserInfo(){} + * ``` + */ @Injectable() export class EvaluationContextInterceptor implements NestInterceptor { constructor(@Inject(ContextFactoryToken) private contextFactory?: ContextFactory) {} diff --git a/packages/nest/src/evaluation-context-propagator.ts b/packages/nest/src/evaluation-context-propagator.ts index f979e1450..8a063639a 100644 --- a/packages/nest/src/evaluation-context-propagator.ts +++ b/packages/nest/src/evaluation-context-propagator.ts @@ -1,6 +1,5 @@ -import { TransactionContextPropagator } from '@openfeature/server-sdk'; +import { TransactionContextPropagator, EvaluationContext } from '@openfeature/server-sdk'; import { AsyncLocalStorage } from 'async_hooks'; -import { EvaluationContext } from '@openfeature/server-sdk'; export class AsyncLocalStorageTransactionContext implements TransactionContextPropagator { private asyncLocalStorage = new AsyncLocalStorage(); diff --git a/packages/nest/src/open-feature.module.ts b/packages/nest/src/open-feature.module.ts index 84e84319c..c28dff9f6 100644 --- a/packages/nest/src/open-feature.module.ts +++ b/packages/nest/src/open-feature.module.ts @@ -13,6 +13,9 @@ import { APP_INTERCEPTOR } from '@nestjs/core'; import { AsyncLocalStorageTransactionContext } from './evaluation-context-propagator'; import { EvaluationContextInterceptor } from './evaluation-context-interceptor'; +/** + * NestJS OpenFeatureModule is a wraper for OpenFeature Server-SDK compatible with NestJS. + */ @Module({}) export class OpenFeatureModule { static forRoot({ useGlobalInterceptor = true, ...options }: OpenFeatureModuleOptions): DynamicModule { From cad673ae1da443d8d70d4c9d88065981a13be75f Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Wed, 10 Jan 2024 09:32:18 -0300 Subject: [PATCH 03/22] Update packages/nest/README.md Co-authored-by: Michael Beemer Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 437c13955..16d022c7b 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -31,7 +31,9 @@ for feature flagging that works with your favorite feature flag management tool. ## Overview -The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [OpenFeature Server SDK](). It's main capabilities are: +The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [OpenFeature Server SDK](). + +It's main capabilities are: - Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; - Supply custom parameter decorators (for controllers), that inject observables with feature flags resolution details; - Inject context for flag evaluation seamlessly using NestJS interceptors From 88bf4f71dc0cfdb61bd9823b4e4bd8a7b85fe2bf Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Wed, 10 Jan 2024 09:32:48 -0300 Subject: [PATCH 04/22] Update packages/nest/src/open-feature.module.ts Co-authored-by: Michael Beemer Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/src/open-feature.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/src/open-feature.module.ts b/packages/nest/src/open-feature.module.ts index c28dff9f6..2e03b401c 100644 --- a/packages/nest/src/open-feature.module.ts +++ b/packages/nest/src/open-feature.module.ts @@ -14,7 +14,7 @@ import { AsyncLocalStorageTransactionContext } from './evaluation-context-propag import { EvaluationContextInterceptor } from './evaluation-context-interceptor'; /** - * NestJS OpenFeatureModule is a wraper for OpenFeature Server-SDK compatible with NestJS. + * NestJS OpenFeatureModule is a wrapper for OpenFeature Server-SDK compatible with NestJS. */ @Module({}) export class OpenFeatureModule { From 04e92b7b2d5ab399ecb4638a0198ef600c7013e6 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Wed, 10 Jan 2024 09:33:21 -0300 Subject: [PATCH 05/22] Update packages/nest/README.md Co-authored-by: Michael Beemer Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 16d022c7b..8c0b1356f 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -142,6 +142,6 @@ export class OpenFeatureTestService { ### Flag evaluation context injection -Whenever a flag evaluation occours, context can be provided with information like user e-mail, role, targeting key, etc in order to trigger specific evaluation rules or logic. The `OpenFeatureModule` provides a way to configure context for each request using the `contextFactory` option. +Whenever a flag evaluation occurs, context can be provided with information like user e-mail, role, targeting key, etc in order to trigger specific evaluation rules or logic. The `OpenFeatureModule` provides a way to configure context for each request using the `contextFactory` option. The `contextFactory` is ran in a NestJS interceptor scope to configure the evaluation context and than it is used in every flag evaluation related to this request. By default the interceptor is cofigured globally, but it can be changed by setting the `useGlobalInterceptor` to `false`. In this case it is still possible to configure a `contextFactory` that can be injected into route, module or controller bound interceptors. From f0c9afe13cd25abda6871c956e7e0e7a925bdc2b Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Mon, 15 Jan 2024 21:34:19 -0300 Subject: [PATCH 06/22] Update packages/nest/README.md Co-authored-by: Lukas Reining Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 8c0b1356f..b554e6727 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -63,7 +63,7 @@ yarn add @openfeature/nestjs-sdk ### Usage -The example bellow shows how to use the `OpenFeatureModule` with OpenFeature's `InMemoryProvider`. +The example below shows how to use the `OpenFeatureModule` with OpenFeature's `InMemoryProvider`. ```ts import { Module } from '@nestjs/common'; From c527bc971dfc6ed503e8b9d7303a1bbde812e1e5 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Mon, 15 Jan 2024 21:35:13 -0300 Subject: [PATCH 07/22] Update packages/nest/README.md Co-authored-by: Lukas Reining Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index b554e6727..688a4fd48 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -118,7 +118,7 @@ export class OpenFeatureController { } ``` -It is also possible to inject the default and a named OpenFeature client into a service via it's constructor with Nest dependency injection system. +It is also possible to inject the default or named OpenFeature clients into a service via Nest dependency injection system. ```ts import { Injectable } from '@nestjs/common'; From 9f1b5f6acba9626244270c7fd3c13198b6184f2b Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Mon, 15 Jan 2024 21:36:21 -0300 Subject: [PATCH 08/22] Update packages/nest/src/evaluation-context-interceptor.ts Co-authored-by: Lukas Reining Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/src/evaluation-context-interceptor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nest/src/evaluation-context-interceptor.ts b/packages/nest/src/evaluation-context-interceptor.ts index 5bfbf6fa0..31c4b922c 100644 --- a/packages/nest/src/evaluation-context-interceptor.ts +++ b/packages/nest/src/evaluation-context-interceptor.ts @@ -6,8 +6,8 @@ import { OpenFeature } from '@openfeature/server-sdk'; /** NestJS interceptor used in {@link OpenFeatureModule} * to configure flag evaluation context. * - * This interceptor is configured globally by dafault, but if - * `useGlobalInterceptor` is set to `false` in {@link OpenFeatureModule} it needs to be configured for the specific controllers or routes. + * This interceptor is configured globally by default. + * If `useGlobalInterceptor` is set to `false` in {@link OpenFeatureModule} it needs to be configured for the specific controllers or routes. * * If just the interceptor class is passed to the `UseInterceptors` like below, the `contextFactory` provided in the {@link OpenFeatureModule} will be injected and used in order to create the context. * ```ts From 3de4dff8436707fc24c135d77ad48352552795d9 Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Mon, 15 Jan 2024 21:57:52 -0300 Subject: [PATCH 09/22] docs: fix minor issues Signed-off-by: Luiz Ribeiro --- packages/nest/README.md | 23 ++++++++++--------- .../src/evaluation-context-interceptor.ts | 1 + packages/nest/src/open-feature.module.ts | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 688a4fd48..126f1a82f 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -7,7 +7,7 @@

-

OpenFeature Nest.js SDK

+

OpenFeature NestJS SDK

@@ -31,9 +31,10 @@ for feature flagging that works with your favorite feature flag management tool. ## Overview -The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [OpenFeature Server SDK](). +The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [OpenFeature Server SDK](https://openfeature.dev/docs/reference/technologies/server/javascript/). It's main capabilities are: + - Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; - Supply custom parameter decorators (for controllers), that inject observables with feature flags resolution details; - Inject context for flag evaluation seamlessly using NestJS interceptors @@ -45,7 +46,7 @@ It's main capabilities are: ### Requirements - Node.js version 16+ -- NestJS +- NestJS version 8+ ### Install @@ -58,7 +59,7 @@ npm install --save @openfeature/nestjs-sdk #### yarn ```sh -yarn add @openfeature/nestjs-sdk +yarn add @openfeature/nestjs-sdk @openfeature/server-sdk @openfeature/core ``` ### Usage @@ -78,14 +79,14 @@ import { InMemoryProvider } from '@openfeature/web-sdk'; testBooleanFlag: { defaultVariant: 'default', variants: { default: true }, - disabled: false + disabled: false, }, }), providers: { - differentProvider: new InMemoryProvider() - } - }) - ] + differentProvider: new InMemoryProvider(), + }, + }), + ], }) export class AppModule {} ``` @@ -107,11 +108,11 @@ export class OpenFeatureController { flagKey: 'testBooleanFlag', defaultValue: false, }) - feature: Observable>, + feature: Observable>, ) { return feature.pipe( map((details) => - details.value ? 'Welcome to this OpenFeature-enabled Nest.js app!' : 'Welcome to this Nest.js app!', + details.value ? 'Welcome to this OpenFeature-enabled NestJS app!' : 'Welcome to this NestJS app!', ), ); } diff --git a/packages/nest/src/evaluation-context-interceptor.ts b/packages/nest/src/evaluation-context-interceptor.ts index 31c4b922c..7b24ae213 100644 --- a/packages/nest/src/evaluation-context-interceptor.ts +++ b/packages/nest/src/evaluation-context-interceptor.ts @@ -2,6 +2,7 @@ import { CallHandler, ExecutionContext, Inject, Injectable, NestInterceptor } fr import { ContextFactory, ContextFactoryToken } from './context-factory'; import { Observable } from 'rxjs'; import { OpenFeature } from '@openfeature/server-sdk'; +import { OpenFeatureModule } from './open-feature.module'; /** NestJS interceptor used in {@link OpenFeatureModule} * to configure flag evaluation context. diff --git a/packages/nest/src/open-feature.module.ts b/packages/nest/src/open-feature.module.ts index 2e03b401c..ed0927362 100644 --- a/packages/nest/src/open-feature.module.ts +++ b/packages/nest/src/open-feature.module.ts @@ -14,7 +14,7 @@ import { AsyncLocalStorageTransactionContext } from './evaluation-context-propag import { EvaluationContextInterceptor } from './evaluation-context-interceptor'; /** - * NestJS OpenFeatureModule is a wrapper for OpenFeature Server-SDK compatible with NestJS. + * OpenFeatureModule is a NestJS wrapper for OpenFeature Server-SDK. */ @Module({}) export class OpenFeatureModule { From de8aa97adc0a9214931961232e3060ae47dbf759 Mon Sep 17 00:00:00 2001 From: Lukas Reining Date: Mon, 22 Jan 2024 23:40:15 +0100 Subject: [PATCH 10/22] Update packages/nest/src/evaluation-context-interceptor.ts Signed-off-by: Lukas Reining --- packages/nest/src/evaluation-context-interceptor.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nest/src/evaluation-context-interceptor.ts b/packages/nest/src/evaluation-context-interceptor.ts index 7b24ae213..5ec04d674 100644 --- a/packages/nest/src/evaluation-context-interceptor.ts +++ b/packages/nest/src/evaluation-context-interceptor.ts @@ -4,7 +4,8 @@ import { Observable } from 'rxjs'; import { OpenFeature } from '@openfeature/server-sdk'; import { OpenFeatureModule } from './open-feature.module'; -/** NestJS interceptor used in {@link OpenFeatureModule} +/** + * NestJS interceptor used in {@link OpenFeatureModule} * to configure flag evaluation context. * * This interceptor is configured globally by default. From 87f1b516aaef668bbbe9d3c9838220c2f74ed8fe Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Mon, 22 Jan 2024 21:00:54 -0300 Subject: [PATCH 11/22] docs: specify peer deps Signed-off-by: Luiz Ribeiro --- packages/nest/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 126f1a82f..daa927924 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -56,11 +56,11 @@ It's main capabilities are: npm install --save @openfeature/nestjs-sdk ``` -#### yarn +#### Required peer dependencies -```sh -yarn add @openfeature/nestjs-sdk @openfeature/server-sdk @openfeature/core -``` +The OpenFeature SDK is required as peer dependency. + +The minimum required version of `@openfeature/server-sdk` currently is `1.7.5`. ### Usage From 34e70d57e7d926ea1f55d580ae4fb5d048f9d84d Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Mon, 22 Jan 2024 21:02:30 -0300 Subject: [PATCH 12/22] Update packages/nest/README.md Co-authored-by: Lukas Reining Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 126f1a82f..568b657f5 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -39,7 +39,7 @@ It's main capabilities are: - Supply custom parameter decorators (for controllers), that inject observables with feature flags resolution details; - Inject context for flag evaluation seamlessly using NestJS interceptors - Provide decorators for OpenFeature Client injection into NestJS services and controllers -- TODO: map other features +- Setting up logging, event handling, hooks and providers directly when registering the module ## ๐Ÿš€ Quick start From 1f932e68db7ff790cbb49f69ce40f595facbc425 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Mon, 22 Jan 2024 21:03:53 -0300 Subject: [PATCH 13/22] Update packages/nest/README.md Co-authored-by: Lukas Reining Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 568b657f5..0a4e99cff 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -37,7 +37,7 @@ It's main capabilities are: - Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; - Supply custom parameter decorators (for controllers), that inject observables with feature flags resolution details; -- Inject context for flag evaluation seamlessly using NestJS interceptors +- Injecting transaction evaluation context for flag evaluations directly from [execution context](https://docs.nestjs.com/fundamentals/execution-context) (HTTP header values, client IPs, etc.) - Provide decorators for OpenFeature Client injection into NestJS services and controllers - Setting up logging, event handling, hooks and providers directly when registering the module From 3564be5253a1215066a1b29c46bd63b3a5648d94 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Mon, 22 Jan 2024 21:04:30 -0300 Subject: [PATCH 14/22] Update packages/nest/README.md Co-authored-by: Lukas Reining Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 0a4e99cff..975b5dd05 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -36,7 +36,7 @@ The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [ It's main capabilities are: - Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; -- Supply custom parameter decorators (for controllers), that inject observables with feature flags resolution details; +- Injecting feature flags directly into controller route handlers by using decorators - Injecting transaction evaluation context for flag evaluations directly from [execution context](https://docs.nestjs.com/fundamentals/execution-context) (HTTP header values, client IPs, etc.) - Provide decorators for OpenFeature Client injection into NestJS services and controllers - Setting up logging, event handling, hooks and providers directly when registering the module From 4035c259ff62f9d6a7fd7aec3c89be2ab3f30322 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Mon, 22 Jan 2024 21:05:16 -0300 Subject: [PATCH 15/22] Update packages/nest/README.md Co-authored-by: Lukas Reining Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 975b5dd05..b95bd6668 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -38,7 +38,7 @@ It's main capabilities are: - Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; - Injecting feature flags directly into controller route handlers by using decorators - Injecting transaction evaluation context for flag evaluations directly from [execution context](https://docs.nestjs.com/fundamentals/execution-context) (HTTP header values, client IPs, etc.) -- Provide decorators for OpenFeature Client injection into NestJS services and controllers +- Injecting OpenFeature clients into NestJS services and controllers by using decorators - Setting up logging, event handling, hooks and providers directly when registering the module ## ๐Ÿš€ Quick start From 3c33c064bdc08b0f90082de4dba844ac7c7b0d3f Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Mon, 22 Jan 2024 21:16:28 -0300 Subject: [PATCH 16/22] docs: add badge Signed-off-by: Luiz Ribeiro --- packages/nest/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 78f3de658..0bb2eab65 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -19,6 +19,12 @@ codecov +
+ + + Release + +

@@ -27,8 +33,6 @@ for feature flagging that works with your favorite feature flag management tool. -๐Ÿงช This SDK is experimental. - ## Overview The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [OpenFeature Server SDK](https://openfeature.dev/docs/reference/technologies/server/javascript/). @@ -36,10 +40,10 @@ The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [ It's main capabilities are: - Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; -- Injecting feature flags directly into controller route handlers by using decorators -- Injecting transaction evaluation context for flag evaluations directly from [execution context](https://docs.nestjs.com/fundamentals/execution-context) (HTTP header values, client IPs, etc.) -- Injecting OpenFeature clients into NestJS services and controllers by using decorators -- Setting up logging, event handling, hooks and providers directly when registering the module +- Injecting feature flags directly into controller route handlers by using decorators; +- Injecting transaction evaluation context for flag evaluations directly from [execution context](https://docs.nestjs.com/fundamentals/execution-context) (HTTP header values, client IPs, etc.); +- Injecting OpenFeature clients into NestJS services and controllers by using decorators; +- Setting up logging, event handling, hooks and providers directly when registering the module. ## ๐Ÿš€ Quick start From 988853bd82e317d5b6dbeb70784ca8621eb7c606 Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Mon, 22 Jan 2024 21:28:40 -0300 Subject: [PATCH 17/22] docs: change badge order and remove line breaks Signed-off-by: Luiz Ribeiro --- packages/nest/README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 0bb2eab65..864d37be1 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -15,16 +15,14 @@ Specification -
- - codecov - -
Release + + codecov +

From c759819d1893285f26944e20e54d74749356963f Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Tue, 23 Jan 2024 21:01:02 -0300 Subject: [PATCH 18/22] docs: add missing peer deps Signed-off-by: Luiz Ribeiro --- packages/nest/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 864d37be1..08b1d676a 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -60,7 +60,12 @@ npm install --save @openfeature/nestjs-sdk #### Required peer dependencies -The OpenFeature SDK is required as peer dependency. +The following list contains the peer dependencies of `@openfeature/nestjs-sdk` with it's expected and compatible versions: + +* `@openfeature/server-sdk`: >=1.7.5 +* `@nestjs/common`: ^8.0.0 || ^9.0.0 || ^10.0.0 +* `@nestjs/core`: ^8.0.0 || ^9.0.0 || ^10.0.0 +* `rxjs`: ^6.0.0 || ^7.0.0 The minimum required version of `@openfeature/server-sdk` currently is `1.7.5`. From 49072d60ae109f9a600382dbb3935ca7b9411874 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Tue, 23 Jan 2024 21:58:04 -0300 Subject: [PATCH 19/22] Update packages/nest/README.md Co-authored-by: Michael Beemer Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 08b1d676a..d19e81192 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -35,7 +35,7 @@ for feature flagging that works with your favorite feature flag management tool. The OpenFeature NestJS SDK is a package that provides a NestJS wrapper for the [OpenFeature Server SDK](https://openfeature.dev/docs/reference/technologies/server/javascript/). -It's main capabilities are: +Capabilities include: - Provide a NestJS global module to simplify OpenFeature configuration and usage within NestJS; - Injecting feature flags directly into controller route handlers by using decorators; From 8948edaadc0a5367bf148823032a15c205142dc5 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Tue, 23 Jan 2024 21:58:13 -0300 Subject: [PATCH 20/22] Update packages/nest/README.md Co-authored-by: Michael Beemer Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index d19e81192..67d561840 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -98,7 +98,7 @@ import { InMemoryProvider } from '@openfeature/web-sdk'; export class AppModule {} ``` -With the `OpenFeatureModule` configured it is now possible to inject flag evaluation details into route handlers like in the following code snippet. +With the `OpenFeatureModule` configured, it's possible to inject flag evaluation details into route handlers like in the following code snippet. ```ts import { Controller, ExecutionContext, Get } from '@nestjs/common'; From 82ede1ea03bbf720a3d3821a1de641d6d66cc331 Mon Sep 17 00:00:00 2001 From: Luiz Guilherme Ribeiro Date: Tue, 23 Jan 2024 21:58:48 -0300 Subject: [PATCH 21/22] Update packages/nest/README.md Co-authored-by: Michael Beemer Signed-off-by: Luiz Guilherme Ribeiro --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 67d561840..97fc75791 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -152,4 +152,4 @@ export class OpenFeatureTestService { Whenever a flag evaluation occurs, context can be provided with information like user e-mail, role, targeting key, etc in order to trigger specific evaluation rules or logic. The `OpenFeatureModule` provides a way to configure context for each request using the `contextFactory` option. The `contextFactory` is ran in a NestJS interceptor scope to configure the evaluation context and than it is used in every flag evaluation related to this request. -By default the interceptor is cofigured globally, but it can be changed by setting the `useGlobalInterceptor` to `false`. In this case it is still possible to configure a `contextFactory` that can be injected into route, module or controller bound interceptors. +By default, the interceptor is configured globally, but it can be changed by setting the `useGlobalInterceptor` to `false`. In this case, it is still possible to configure a `contextFactory` that can be injected into route, module or controller bound interceptors. From 529178b46ea9f8e42bc7776fe34918609d473f14 Mon Sep 17 00:00:00 2001 From: Lukas Reining Date: Wed, 24 Jan 2024 09:49:05 +0100 Subject: [PATCH 22/22] Update packages/nest/README.md Signed-off-by: Lukas Reining --- packages/nest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nest/README.md b/packages/nest/README.md index 97fc75791..c6770aeec 100644 --- a/packages/nest/README.md +++ b/packages/nest/README.md @@ -65,7 +65,7 @@ The following list contains the peer dependencies of `@openfeature/nestjs-sdk` w * `@openfeature/server-sdk`: >=1.7.5 * `@nestjs/common`: ^8.0.0 || ^9.0.0 || ^10.0.0 * `@nestjs/core`: ^8.0.0 || ^9.0.0 || ^10.0.0 -* `rxjs`: ^6.0.0 || ^7.0.0 +* `rxjs`: ^6.0.0 || ^7.0.0 || ^8.0.0 The minimum required version of `@openfeature/server-sdk` currently is `1.7.5`.