-5
emailpassword: getenv('EMAIL_PASSWORD',''),

So what exactly does this code do? And what is the 'getenv' function. A quick google search told me that it is something to do with environment variables. Could someone explain what they are?

error404
  • 1
  • 1
  • 1
  • Most likely https://github.com/ctavan/node-getenv. That returns the value of the environment variable `EMAIL_PASSWORD`. – thefourtheye Jun 18 '18 at 02:14
  • Environment variables are like system-wide global variables. In windows you set them in "System Properties -> Environment Variables". But you can also set them from command line and it's pretty common to set something temporary when you run some application: `set EMAIL_PASSWORD=abc123 node index.js` Syntax are different on different OS though, so you have to do a little bit of research. In node, the most common one is NODE_ENV="development" or "production". You see it everywhere. And then you can get it inside your app like `console.log( process.env.NODE_ENV )` – ippi Jun 18 '18 at 02:16
  • That node-getenv lib does [exactly that](https://github.com/ctavan/node-getenv/blob/82cb9fd68006090994daa14c2e6c2f9cd14b0ecc/lib/getenv.js#L8) and adds some fallbacks and type handling - looks like complete overkill to me, but what do I know. – ippi Jun 18 '18 at 02:26

2 Answers2

0

By right, it's getting the environment variables which are used for configuring your application, in your case it can be seen as getting your 'EMAIL_PASSWORD'.

0

getenv('EMAIL_PASSWORD') will return the value of variable 'EMAIL_PASSWORD'. Considering 2nd parameter it's meant for fallback functions.

dkm007
  • 145
  • 2
  • 6