Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved sensitive information to .env #144

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

DedaDev
Copy link

@DedaDev DedaDev commented Oct 6, 2019

I see a lot of improvements for this bot,
some packages are required in multiple places instead of 1, unnecessary try-catch blocks.
Sensitive information in JSON instead of dotenv module.

@chalda
Copy link
Owner

chalda commented Oct 6, 2019

you dropped youtube-node down to 1.2 from 1.3? but overall this looks good. heading out to comiccon rn but will take a look tomorrow

@Einarin
Copy link
Collaborator

Einarin commented Jan 3, 2020

Support for getting credentials from environment variables is definitely nice, but can we make this backwards compatible so it isn't a breaking change for people with the bot already set up?

@Androz2091
Copy link

I think a small script which delete the auth.json file and create a .env file with the current credentials will be cleaner than a complicated system of logic within the code, no? Something like that:

const oldCredentials = require('auth.json');
let credsList = Object.keys(oldCredentials);
let dotEnvContent = '';
credsList.forEach(cred => {
    dotEnvContent += cred.toUpperCase()+'= '+oldCredentials[cred];
});
require('fs').writeFileSync('.env', dotEnvContent);
console.log('auth.json file has been moved to .env file!');

@chalda
Copy link
Owner

chalda commented Nov 8, 2020

huh just remmebered about this. i ended up implementing a much hackier solution to get stuff to work in heroku 😭 ill try to rebase this and get it to work with my changes. I think ill keep my changes for now that work both with json and env tho :P

@AakashRawat04
Copy link

AakashRawat04 commented Sep 1, 2022

I think a small script which delete the auth.json file and create a .env file with the current credentials will be cleaner than a complicated system of logic within the code, no? Something like that:

const oldCredentials = require('auth.json');
let credsList = Object.keys(oldCredentials);
let dotEnvContent = '';
credsList.forEach(cred => {
    dotEnvContent += cred.toUpperCase()+'= '+oldCredentials[cred];
});
require('fs').writeFileSync('.env', dotEnvContent);
console.log('auth.json file has been moved to .env file!');

This code looks cleaner as it doesn't require you to write all the credentials all by yourself in a .env file.
Also, this way we might get saved from misspelled key-value pairs which might throw out unusual errors.

But the problem is while working with config.json files we can assign numeric values to a key, but in the case of the .env file, everything is converted to a string.
and due to that reason, the discord.js guide also addresses this problem by using the config.json file instead of the .env file.
you can find the specific reason here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants