Now generateing api key via eng_gen script

This commit is contained in:
2021-03-02 16:57:46 +01:00
parent 01f5001355
commit 17f5876d73
3 changed files with 34 additions and 10 deletions

View File

@@ -8,14 +8,21 @@ nodemailer.createTestAccount((err, account) => {
console.error('Failed to create a testing account. ' + err.message);
return process.exit(1);
}
let apikey = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
for (var i = 0; i < 64; i++) {
apikey += characters.charAt(Math.floor(Math.random() * charactersLength));
}
const env = `
NODE_ENV=dev
MAIL_SERVER=${account.smtp.host}
MAIL_PORT=${account.smtp.port}
MAIL_USER=${account.user}
MAIL_PASSWORD=${account.pass}
MAIL_FROM=${account.user}`
MAIL_FROM=${account.user}
API_KEY=${apikey}
`
try {
fs.writeFileSync("./.env", env, { encoding: "utf-8" });