简体   繁体   中英

GAE - Having environment variables play nice with node.js apps

It seems like the environment variables in app.yaml are rendered in Python-like strings, where booleans like true become True and empty variables becomes None . Anyone have ideas on how to make it play nice with javascript without doing explicit conversion for all my variables?

const MY_ENV_VAR = (process.env.MY_ENV_VAR === 'None') ? null : process.env.MY_ENV_VAR;

Yes, I can write some function to do it. Wondering if anyone has a clever solution.

The only additional available configurations related to Javascript are for Node.js and they are quite simple. As per the official documentation of the app.yaml file , the option Javascript related is to set the runtime and that's it, unfortunately. There is not direct way to configure better usage for the environment variables.

Considering that and that, I agree with you, having better handling of environemt variables in Javascript would be better for a lot of cases. Due to that, I would recommend you to raise a Feature Request in Google's Public Issue Tracker , so they can take a look at it and verify the possibility of implementing it in the future.

Let me know if the information helped you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM