Professor-Redwood-Team / Professor-Redwood

Pokemon Go Discord Bot
MIT License
34 stars 21 forks source link

Move secrets to environment variables #68

Closed kc135576 closed 4 years ago

kc135576 commented 6 years ago

I think it would be a great idea to have the functionality to move secrets into environment variables instead of relying only on the secrets.json. For example, deploying on heroku requires a git repo and we wouldn't want to commit the secrets.

Maybe in bot.js we can do something along the lines of

const config = (process.env.DEBUG == "true") ? require('./config/secrets.json') :
 {
   "discord": {
     "token": process.env.DISCORD_TOKEN,
     "BOTID": process.env.DISCORD_BOTID
   },
   "mysql": {
     "host": process.env.MYSQL_HOST,
     "user": process.env.MYSQL_USER,
     "password": process.env.MYSQL_PASSWORD,
     "database": process.env.MYSQL_DB
   },
   "webhook": {
     "log": {
       "id": process.env.WEBHOOK_ID,
       "token": process.env.WEBHOOK_TOKEN
     }
   }
 };
kc135576 commented 4 years ago

Doing this will allow for CI testing

kc135576 commented 4 years ago

added in #129