starbasedb icon indicating copy to clipboard operation
starbasedb copied to clipboard

feat: make feature flags a bit more granular

Open jeroenptrs opened this issue 10 months ago • 1 comments

Purpose

Seeing the feature flag configuration was nice but it appeared to be a bit incomplete (for example, websockets has a feature flag but it's not configured or in use), so getFeature is now a reusable function to a certain degree and more parts/plugins are added to the list of flags.

This change also allows you to turn on / off plugins without having to remove code, mostly from the perspective of not wanting to cause too many changes that could cause merge conflicts.

I left the default values in the configuration as I didn't want to act too opinionated.

Additionally, I thought about switching to a comma separated list or an array of values, but ultimately felt like that was way more cumbersome to validate. As a tradeoff, this does inflate the amount of variables present in env vars a bit.

Tasks

  • [x] use getFeature everywhere feature flags are used (and extract it to utils)
  • [x] update tests
  • [x] if a feature flag impacts a plugin, also prevent instantiating said plugin
  • [x] add studio / interface / cron / cdc to feature flags as well

Verify

  • using Studio as an example, set ALLOW_STUDIO in wrangler to 0
  • launch starbasedb and go to your.url/studio
  • studio should no longer launch

jeroenptrs avatar Feb 23 '25 19:02 jeroenptrs

Alright I made some changes and filtering the plugins array for undefined values seems like a better design as opposed to wrapping everything in if statements :)

jeroenptrs avatar Feb 25 '25 08:02 jeroenptrs