lucaschen / microservices-demo

425 stars 142 forks source link

check cache should be before accessing the process.env #21

Open decisa opened 4 years ago

decisa commented 4 years ago

Thank you for such an amazing tutorial! I have a feeling that your accessEnv helper needs a little tweak. Since the main intention of this helper is to reduce the amount of accesses to process.env, you should check whether key is in process.env after confirming that the key is not already cached.

That seems like a proper logic.

check if key is cached if not cached, check whether key is in process.env if not found, check default value if no default value, throw an error