Commit Graph

6 Commits

Author SHA1 Message Date
Kaushal Kapasi 59b8fe904f
feat: adds RequireFlagsEnabled decorator (#1159)
## This PR
- Feature: Adds a `RequireFlagsEnabled` decorator to allow a simple,
reusable way to block access to a specific controller or endpoint based
on the value of a list of one, or many, boolean flags

### Notes
- Discussions on the approach & implementation are welcome!

### Follow-up Tasks
- Update OpenFeature NestJS docs to include new `RequireFlagsEnabled`
decorator & usage examples

### How to test
`npx jest --selectProject=nest`

---------

Signed-off-by: Kaushal Kapasi <kaushal.kapasi@taplytics.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
2025-04-24 13:32:55 +00:00
Todd Baert 01fcb933d2
chore: import type lint rule and fixes (#1039)
Inspired by [this
comment](https://github.com/open-feature/js-sdk/pull/1020#discussion_r1777829664)
I've added a lint rule to enforce `import type`, and some additional
package changes to add a `lint:fix`.

The only changes I made manually here is to add the lint rule, and the
package.json script. All the changes are auto-generated by the
`lint:fix`.

---------

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
2024-10-16 14:33:47 -04:00
Lukas Reining 840d7acaa3
feat(nestjs)!: add domains (#831)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

- adds support for domains
- removes named clients

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

relates to https://github.com/open-feature/spec/pull/229

---------

Signed-off-by: Lukas Reining <lukas.reining@codecentric.de>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
2024-02-25 12:01:55 +00:00
Lukas Reining 80a9ba1e51
feat: add logger, event handlers and hooks to nest sdk (#761)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

Adds options for logger, event handlers and hooks to Nest SDK
initialization.
This change makes the SDK completely configurable during the
initialization without the need to explicitly call the OpenFeature API.

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

Relates to #705

---------

Signed-off-by: Lukas Reining <lukas.reining@codecentric.de>
Signed-off-by: Luiz Guilherme Ribeiro <ltrindaderibeiro@gmail.com>
Signed-off-by: Luiz Guilherme Ribeiro <luizgribeiro@ufrj.br>
Co-authored-by: Luiz Guilherme Ribeiro <ltrindaderibeiro@gmail.com>
2024-01-18 20:25:26 +00:00
Lukas Reining 1fa53c9058
feat: context propagation for nestjs (#736)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR

Implements context propagation in the Nest.js SDK.
This relates to the discussions from
https://github.com/open-feature/js-sdk/pull/733#discussion_r1427747322.

Open questions are:
- How to scope the `contextFactory`? It seems that we should be able to
define a common and client specific context factories.
- Should the `AsyncLocalStorage` be used in the `FeatureFlagDecorators`
too as it is in this draft?
- Should we merge the injected `OpenFeatureClient` and the
`OpenFeatureContextService` so that you do not have to inject both into
the consuming services as we do in the `TestService`?

@luizgribeiro this is the draft for what we discussed about, what do you
think?

---------

Signed-off-by: Lukas Reining <lukas.reining@codecentric.de>
Signed-off-by: Luiz Guilherme Ribeiro <ltrindaderibeiro@gmail.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Co-authored-by: Luiz Guilherme Ribeiro <ltrindaderibeiro@gmail.com>
2024-01-08 22:40:19 +00:00
Lukas Reining ef874e0365
feat: implement draft for a Nest.js SDK (#718)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

This is a first draft of a Nest.js SDK.
Currently it only handles injecting clients and feature flags.
I also added a context factory for the FeatureFlag decorators to be able
to use request information for the execution context.

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

Fixes #705 

### Notes
<!-- any additional notes for this PR -->

@toddbaert maybe we can do it as we did with the React SDK, merge this
fast and release as experimental to let people experiment and try out?

### Follow-up Tasks
<!-- anything that is related to this PR but not done here should be
noted under this section -->
<!-- if there is a need for a new issue, please link it here -->
We will have to see if we want to stick with the injected feature flags
being wrapped in an observable.
To me this feels the most idiomatic for Nest.js.

### How to test
Tests for the current functionality are included.

---------

Signed-off-by: Lukas Reining <lukas.reining@codecentric.de>
Co-authored-by: Henry Chen <1474479+chenhunghan@users.noreply.github.com>
Co-authored-by: Luiz Guilherme Ribeiro <ltrindaderibeiro@gmail.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
2023-12-13 16:59:48 +00:00