FACG6 / CMSPosts

Link :
https://yourwordsapp.herokuapp.com/
0 stars 0 forks source link

Useless require #15

Open NouraldinS opened 5 years ago

NouraldinS commented 5 years ago

https://github.com/FACG6/CMSPosts/blob/6df00bcc761329d8e4c90eca4f5a99ebb70d379d/src/app.js#L1

First line in your app.js you required dotenv, because mostly, you thought it is needed whenever you call process.env. Which isn't true.

process.env is a global system variable that has your environment variables. (type env to your terminal and press enter) This variable exists even without dotenv installed or any other library, process to Node is something like window to Javascript in the browser.

And if you typed env in your terminal, pressed enter, and seen what's there, then console logged the process.env object, you'll find they're the same.

This leaves us with the last detail, what does dotenv does? It adds a property to your process.env object. The property added in your .env file.

engshorouq commented 5 years ago

i use it to can deal with the variable in file .env like process.env.DATABASE_URL_LOCAL DATABASE_URL_LOCAL not exist in process.env i need to call it from the .env file , and put it in app file to require it once and can access to all other files in my application

NouraldinS commented 5 years ago

@engshorouq True, but it, in it's current place, is useless, because you've already called it in your db_connection, so, either remove it from your app, or from your db_connection.