Slightly random thought that occurred to me today on a potential improvement to the default Node-RED settings file. Would appreciate any feedback.
opened 04:19PM - 23 May 24 UTC
Our current settings file is structured as a big Object:
```
module.exports … = {
flowFile: 'flows.json',
...
}
```
This is fine if you're used to working with objects - and that you remember to add a comma between any entries you add. This trips some users up and they end up with an invalid settings file. It's also a pain to have to add a comment about ensuring you add a comma whenever the docs talk about adding values.
I happened to be in the gitlab admin docs and noticed how they document their settings file:
```
gitlab_rails['some_setting'] = true
gitlab_rails['some_other_setting'] = {
'label' => 'hi',
'host' => 'example.com
}
```
Putting aside its ruby, not JavaScript - the key point is the settings are individual statements on a top level object.
This removes the issues around getting the formatting right when adding new settings - whether a comma is needed or not.
I propose changing our default settings file to be structured like this:
```
const settings = module.exports = {}
settings['flowFile'] = 'flows.json'
settings['adminAuth'] = {
type: "credentials",
...
}
```
I'm in two minds whether to use dot notation (`settings.flowFile`) or bracket notation (`settings['flowFile']`) - which is more accessible to non-JS users?
Raising this as an issue rather than jumping straight to PR to save the effort reformatting what we've got if this is a terrible idea.
4 Likes
I've c***d up my settings file more times than I care to remember whilst adding in updates, so any improvements to the format would very helpful.
The suggestion/comment by @Steve-Mcl sounds encouraging.
1 Like
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.