firebase-tools
firebase-tools copied to clipboard
Document all process.env variables
I was doing some digging trying to find a way to differentiate function logic depending on whether the cloud function is running in the emulator or not. Apparently, we can tell through process.env.FUNCTIONS_EMULATOR. The problem is, I can't find this anywhere in the documentation. It's not stated in the Firebase Environmental Configuration docs, or the Gcloud environmental variables docs(though the latter doesn't surprise me). It's been a feature for a while tho, but it seems to me that the only way someone could know about it is by stumbling on #1364 or by trusting internet comments talking about a variable that's not even in the docs.
This leads me to wonder whether this is just unique to FUNCTIONS_EMULATOR, or there are a lot more firebase-specific .env variables out there that aren't in the docs.
@andersonaddo point taken! There aren't any other secret ones, FUNCTIONS_EMULATOR is the only emulator-specific environment variable, and you're right that we have not documented it anywhere discoverable.
Still we should document the whole emulator environment.
If there's anyway I can help with that, just lmk!
Thanks @andersonaddo I did indeed stumble across this via #1364
The following at the top of my function works for me
if (process.env.FUNCTIONS_EMULATOR !== "true") {
response.send("Only Available Via Emulator");
}
I wanted a deleteAllUsers function in dev so that I can clean up after testing
But I really don't want that ever in production.
@markarndt any thoughts on this? I'm thinking it's time for a doc somewhere that describes the Functions emulator environment and how / why it differs from production. It has enough interesting corners (like this one) that come up regularly but are mostly undocumented.