hyson007 / grid_bot

0 stars 1 forks source link

use dotenv #1

Open joshh71390 opened 1 year ago

joshh71390 commented 1 year ago

should use dotenv. even if your using cors or whatever else... it 1.. alows you to change one source of truth which is outside your app -> and just about every runtime has integrated access to dotenv.

if your unsure how to do this .... npm install dotenv ->

create a file named .env file in the root folder. > add a file called .ignore and add the line .env inside the .env file you created above... create the two variables that you wish to hide from outside eyes...

use the format below UPPER_CASE=anyStringsCanGOHERE1223444

PRIVATE_KEY=textstringhere PUBLIC_KEY=textstringherenoquotes

inside your app on the very top of your file add require('dotenv').config() replace your keys which are now inside your dotenv folder hidden with const privateKey = process.env.PRIVATE_KEY const publicKey = process.env.PUBLIC_KEY

doSomething(privateKey, PublicKey, payload)

// package.json package-lock.json app.js .env .ignore //

joshh71390 commented 1 year ago

you can also put any other type of enviornmental variables that can change... database uris / or the configuration settings. and when you update that file , all referances will update as well... say you have it hosted on heroku... you can change your config from heroku dashboard instead of pushing new changes etc.