Skip to content
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

PER-9717 [back-end] Endpoint to retrieve environment configuration #127

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

iulianvsp
Copy link
Contributor

@iulianvsp iulianvsp commented Oct 1, 2024

PER-9717 [back-end] Endpoint to retrieve environment configuration

@iulianvsp iulianvsp force-pushed the PER-9717 branch 2 times, most recently from efdfe92 to bca3cbb Compare October 1, 2024 15:43
Copy link
Member

@liam-lloyd liam-lloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're generally on the right path here as far as how we write endpoints and what this one should do. I've added a couple comments in places where I think a better course exists.

You asked also whether there are any additional fields this endpoint should return; I've now added an OpenAPI specification describing the desired endpoint in detail (though that specification need not be taken as dogma; if you see a better way by all means present your case for it). If you prefer not to read the YAML directly, you can create a much nicer HTML version of the specification by running redocly build-docs packages/api/docs/present/api.yaml (we have just recently adopted this API specification format and aren't yet hosting a docs site).

Some other documentation that might give you useful further context:
The longer term plan for feature flags
Our best practices for API design

packages/api/src/account/queries/get_feature_flags.sql Outdated Show resolved Hide resolved
packages/api/src/feature/models.ts Outdated Show resolved Hide resolved
packages/api/src/feature/service.ts Outdated Show resolved Hide resolved
packages/api/src/feature/controller.ts Outdated Show resolved Hide resolved
@iulianvsp
Copy link
Contributor Author

You're generally on the right path here as far as how we write endpoints and what this one should do. I've added a couple comments in places where I think a better course exists.

You asked also whether there are any additional fields this endpoint should return; I've now added an OpenAPI specification describing the desired endpoint in detail (though that specification need not be taken as dogma; if you see a better way by all means present your case for it). If you prefer not to read the YAML directly, you can create a much nicer HTML version of the specification by running redocly build-docs packages/api/docs/present/api.yaml (we have just recently adopted this API specification format and aren't yet hosting a docs site).

Some other documentation that might give you useful further context: The longer term plan for feature flags Our best practices for API design

I updated the PR with the suggested changes, please have a look. I also saw in the best practices API design page that for lists of object we want to have pagination. Does this apply to the feature_flags as well?

Also should I create the other CRUD methods to this entity? Thanks

packages/api/src/feature_flag/controller.ts Outdated Show resolved Hide resolved
packages/api/src/feature_flag/controller.ts Outdated Show resolved Hide resolved
packages/api/src/feature_flag/controller.ts Outdated Show resolved Hide resolved
packages/api/src/feature_flag/controller.ts Outdated Show resolved Hide resolved
packages/api/src/routes/index.ts Outdated Show resolved Hide resolved
packages/api/src/feature_flag/service.ts Outdated Show resolved Hide resolved
packages/api/src/feature_flag/models.ts Outdated Show resolved Hide resolved
@liam-lloyd
Copy link
Member

I also saw in the best practices API design page that for lists of object we want to have pagination. Does this apply to the feature_flags as well?

I think feature flags are most naturally an exception to this rule. From the user-facing client's perspective, it would be a hassle to have to make several calls through multiple pages of feature flags in order to determine which features should be active. From the admin panel's perspective, pagination might be more reasonable, but I think realistically we should never have so many feature flags at once that they would be unmanageable without pagination (unless we neglect to delete old ones, but then the lack of pagination may become a useful inducement to not neglect that).

Also should I create the other CRUD methods to this entity?

I think that would be a great thing for you to do once this endpoint is done; the create and update methods are higher priority than delete. The tickets for those endpoints are here:
https://permanent.atlassian.net/browse/PER-9718
https://permanent.atlassian.net/browse/PER-9866

@iulianvsp iulianvsp force-pushed the PER-9717 branch 4 times, most recently from 3523a60 to f2e0d9f Compare October 3, 2024 15:46
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.67%. Comparing base (9e56697) to head (f2e0d9f).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
- Coverage   88.12%   86.67%   -1.46%     
==========================================
  Files          75       78       +3     
  Lines        1347     1403      +56     
  Branches      207      213       +6     
==========================================
+ Hits         1187     1216      +29     
- Misses        146      171      +25     
- Partials       14       16       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iulianvsp iulianvsp force-pushed the PER-9717 branch 5 times, most recently from f1d9ffe to 7668dd8 Compare October 8, 2024 15:07
@iulianvsp iulianvsp marked this pull request as ready for review October 8, 2024 15:08
@iulianvsp iulianvsp force-pushed the PER-9717 branch 3 times, most recently from 455714b to e652b29 Compare October 16, 2024 11:42
Copy link
Member

@liam-lloyd liam-lloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more comment, then I think this will be ready to merge!

packages/api/src/feature_flag/controller.test.ts Outdated Show resolved Hide resolved
@iulianvsp iulianvsp force-pushed the PER-9717 branch 2 times, most recently from ed5dacd to df44d7f Compare October 22, 2024 17:42
next: NextFunction
): Promise<void> => {
const authenticationToken = getAuthTokenFromRequest(req);
const email = await getOptionalValueFromAuthToken(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one more thing while testing locally - this function will throw an exception (because of the way the Fusionauth client works) if it receives an authenticationToken that's an empty string. Since we don't want that case to fail, we should check for an empty authenticationToken and then only call this if it's not empty.

New endpoint feature-flags that will return a list of globally enabled flag names if the user is not authenticated or a regular user and all feature flags if the user is an administrator

Functional testing was added for both scenarios
@iulianvsp iulianvsp merged commit 3b5f612 into main Oct 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants