feat: make feature flags a bit more granular
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
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 :)