updated format and lint scripts and applied them
This commit is contained in:
37
genSecret.js
37
genSecret.js
@@ -1,24 +1,23 @@
|
||||
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';
|
||||
/* eslint-disable no-console */
|
||||
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';
|
||||
if (NODE_ENV && NODE_ENV.toLowerCase() === 'production') {
|
||||
confFile = 'production.json'
|
||||
}
|
||||
let config = require('./config/' + confFile);
|
||||
let configPath = path.join(__dirname, 'config', confFile);
|
||||
let config = require('./config/' + confFile)
|
||||
let configPath = path.join(__dirname, 'config', confFile)
|
||||
|
||||
if(!config.authentication) {
|
||||
config.authentication = { secret };
|
||||
if (!config.authentication) {
|
||||
config.authentication = { secret }
|
||||
} else {
|
||||
config.authentication.secret = secret;
|
||||
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);
|
||||
}
|
||||
);
|
||||
fs.writeFile(configPath, JSON.stringify(config, null, 2) + '\n', err => {
|
||||
if (err) return console.error(err)
|
||||
console.log('\nAuthentication secret successfully updated in', confFile)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user