Open koenpunt opened 10 years ago
I see a few options:
process.env
TWITTER_KEYS_CONSUMER
vs TWITTER_CONSUMER_KEY
TWITTER_CONSUMERKEY
vs TWITTER_CONSUMER_KEY
__
and then name the var TWITTER__CONSUMER_KEY
vs TWITTER_CONSUMER_KEY
For me personally, 3 has worked well enough. But I think if Environmental needs to address this, I feel most for 4.
What do you think?
The problem is that in this case the library (Tuiter) expects the keys of the configuration to be like
{
consumer_key: 'xxxxx',
consumer_secret: 'xxxxx',
access_token_key: 'xxxxx',
access_token_secret: 'xxxxx'
}
so this rules out option 3.
Customizable delimiter will convenient anyway.
Another option could be to limit nesting with a numeric value.
When set to 1
, TWITTER_ACCESS_TOKEN_SECRET
results in:
twitter: {
access_token_secret: 'xxx'
}
When set to 2
it results in:
twitter: {
access: {
token_secret: 'xxx'
}
}
Etc.
I like the idea of making the delimiter and nesting level configurable! Would you also be interested in hacking on that?
I like the idea of parsing the variables into objects, although parsing environment variables like
TWITTER_ACCESS_TOKEN_SECRET
result is something like:Where I previously could use a JSON object like this:
I now have to supply every property separately:
And I know with environment variables would it be the same:
But I think it would be nice to fetch some variables by prefix, but not completely teared apart.
Something in the likes of: