What’s the recommended approach for implementing the feature flag concept, where functionality, debug level, etc. can be controlled and changed dynamically at runtime?
Debug level is handled by the npm debug package both client-side and server-side. Server side debug is controlled by the DEBUG environment variable.
Environment variables are the typical way to configure the server-side behavior. These can also be used client-side by adding an app behavior to retrieve specific environment variables. Never expose them all because the environment variables will include sensitive data like database passwords and API keys.
The only downside of environment variables is that they are set before the app starts. In theory you can change them at runtime by directly update them like this:
process.env.feature1 = 'on'
But that would only affect the node that the API call is made to so this is almost never used.
Other approaches could include a business object with different features. We added an Event Setting business object to one app which gave a place to store name/value pairs (one row for each) that were retrieved in a service on page load. These could then be referenced by various parts of the application.