-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nest.js SDK #705
Comments
That sounds good!
This way we can keep it simple for those who only want a default provider but also support different scenarios.
I'd also say that a Method/Controller/Handler decorator can be useful. Enabling or disabling an enpoint from a decorator might be useful |
It would also be great if it were possible to configure the injected client to contain request-scoped context properties. That would allow you to easily set context like By the way, the OpenFeature playground app uses Nest. We should keep that in mind as we build out this SDK. |
Ya totally, changed the requirements. |
Yes this could make sense. |
This sounds good! |
I will start to bring some of the existing code into a draft PR and then we can continue to work on this. |
I think that returning 404 in this case would mean that it's disabled. I see that we're coming up with multiple ideas and it will probably make it harder to implement all at once. |
Do you have any idea on how to implement this? |
Yes but I am not sure about the ergonomics. export interface OpenFeatureStringFlagProps {
clientName?: string;
flagKey: string;
defaultValue: string;
context?: EvaluationContext;
}
export const OpenFeatureStringFlag= createParamDecorator(
({ clientName, flagKey, defaultValue, context }: OpenFeatureFeatureProps) => {
const client = clientName ? OpenFeature.getClient(clientName) : OpenFeature.getClient();
return client.getStringDetails(flagKey, defaultValue, context);
},
); import { Controller, Get } from '@nestjs/common';
import { EvaluationDetails } from '@openfeature/server-sdk';
import { OpenFeatureFeature } from './feature.decorator';
@Controller()
export class ExampleController {
@Get('/tenant')
public async handleRequest(
@OpenFeatureStringFlag({ clientName: 'myCLient', flagKey: 'tenantName', defaultValue: 'BigCorp' })
feature: Promise<EvaluationDetails<string>>,
) {
const details = await feature;
return details.value;
}
} |
Yes, it would only be important, that this behaves exactly like the endpoint not existing, I would say. |
I've started sketching a module here but I'm not 100% confident about this. I'll probably study libs such as nest/mongoose before coming up with anything barely usable. I haven't done much Dynamic modules stuff from ground. My main concern about this is how to test it properly. |
As promised, I started to integrate this too. Here is the first draft of the most basic functions: #718 @luizgribeiro I also wanted to add you as reviewer, but you are not in the org. Would you like to joint the org? Then we could add you. |
<!-- 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 <[email protected]> Co-authored-by: Henry Chen <[email protected]> Co-authored-by: Luiz Guilherme Ribeiro <[email protected]> Co-authored-by: Todd Baert <[email protected]>
We are discussing context propagation here: #736 |
<!-- 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 <[email protected]> Co-authored-by: Henry Chen <[email protected]> Co-authored-by: Luiz Guilherme Ribeiro <[email protected]> Co-authored-by: Todd Baert <[email protected]>
<!-- 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 <[email protected]> Signed-off-by: Luiz Guilherme Ribeiro <[email protected]> Signed-off-by: Luiz Guilherme Ribeiro <[email protected]> Co-authored-by: Luiz Guilherme Ribeiro <[email protected]>
Hey @lukas-reining, can this issue be closed? |
Good question, maybe we can take the chance to see if we can get to a 1.0 release. |
Sure, that sounds reasonable. |
Will propose it in the community meeting and then we can do it maybe. @beeme1mr @toddbaert |
We should build a Nest.js Module, as Nest.js is a really popular backend framework for JavaScript.
The following is the current idea of what feature could be interesting:
Non-functional requirements:
The text was updated successfully, but these errors were encountered: