initial commit

This commit is contained in:
JJ Kasper
2018-05-17 14:31:05 -05:00
commit 2c90d2e7dd
79 changed files with 10684 additions and 0 deletions

24
genSecret.js Normal file
View File

@@ -0,0 +1,24 @@
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const secret = crypto.randomBytes(256).toString('hex');
const { NODE_ENV } = process.env;
let confFile = 'default.json';
if(NODE_ENV && NODE_ENV.toLowerCase() === 'production') {
confFile = 'production.json';
}
let config = require('./config/' + confFile);
let configPath = path.join(__dirname, 'config', confFile);
if(!config.authentication) {
config.authentication = { secret };
} else {
config.authentication.secret = secret;
}
fs.writeFile(configPath, JSON.stringify(config, null, 2) + '\n',
err => {
if(err) return console.error(err);
console.log('\nAuthentication secret successfully updated in', confFile);
}
);