commit
7ddb403f6e
7 changed files with 43 additions and 8 deletions
|
@ -3,6 +3,7 @@ const fs = require('fs');
|
|||
const Path = require('path');
|
||||
const axios = require('axios');
|
||||
const ip = require('ip');
|
||||
const pwGenerator = require('generate-password');
|
||||
|
||||
const mysqlQuestions = require(Path.resolve(__dirname, 'questions/mysqlQuestions.js'));
|
||||
const siteQuestions = require(Path.resolve(__dirname, 'questions/siteQuestions.js'));
|
||||
|
@ -12,11 +13,14 @@ let thumbnailChannelDefault = '@thumbnails';
|
|||
let thumbnailChannel = '';
|
||||
let thumbnailChannelId = '';
|
||||
|
||||
const createConfigFile = (fileName, configObject) => { // siteConfig.json , siteConfig
|
||||
const fileLocation = Path.resolve(__dirname, `../site/config/${fileName}`);
|
||||
const createConfigFile = (fileName, configObject, topSecret) => { // siteConfig.json , siteConfig
|
||||
const fileLocation = topSecret
|
||||
? Path.resolve(__dirname, `../site/private/${fileName}`)
|
||||
: Path.resolve(__dirname, `../site/config/${fileName}`);
|
||||
|
||||
const fileContents = JSON.stringify(configObject, null, 2);
|
||||
fs.writeFileSync(fileLocation, fileContents, 'utf-8');
|
||||
console.log(`Successfully created ./site/config/${fileName}\n`);
|
||||
console.log(`Successfully created ${fileLocation}\n`);
|
||||
};
|
||||
|
||||
// import existing configs or import the defaults
|
||||
|
@ -74,6 +78,27 @@ try {
|
|||
chainqueryConfig = require('./defaults/chainqueryConfig.json');
|
||||
}
|
||||
|
||||
// authConfig
|
||||
let randSessionKey = pwGenerator.generate({
|
||||
length : 20,
|
||||
numbers: true,
|
||||
});
|
||||
|
||||
let randMasterPass = pwGenerator.generate({
|
||||
length : 20,
|
||||
numbers: true,
|
||||
});
|
||||
|
||||
let authConfig;
|
||||
try {
|
||||
authConfig = require('../site/private/authConfig.json');
|
||||
} catch (error) {
|
||||
authConfig = {
|
||||
sessionKey : randSessionKey,
|
||||
masterPassword: randMasterPass,
|
||||
};
|
||||
}
|
||||
|
||||
// ask user questions and create config files
|
||||
inquirer
|
||||
.prompt(mysqlQuestions(mysqlDatabase, mysqlUsername, mysqlPassword))
|
||||
|
@ -204,11 +229,14 @@ inquirer
|
|||
createConfigFile('loggerConfig.json', loggerConfig);
|
||||
createConfigFile('slackConfig.json', slackConfig);
|
||||
createConfigFile('chainqueryConfig.json', chainqueryConfig);
|
||||
createConfigFile('authConfig.json', authConfig, true);
|
||||
})
|
||||
.then(() => {
|
||||
console.log('\nYou\'re all done!');
|
||||
console.log('Next step: run "npm run start" to build and start your server!');
|
||||
console.log('If you want to change any settings, you can edit the files in the "/config" folder.');
|
||||
console.log('\nIt\'s a good idea to BACK UP YOUR MASTER PASSWORD \nin "/site/private/authConfig.json" so that you don\'t lose \ncontrol of your channel.');
|
||||
|
||||
console.log('\nNext step: run "npm run start" to build and start your server!');
|
||||
console.log('If you want to change any settings, you can edit the files in the "/site" folder.');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -5703,6 +5703,11 @@
|
|||
"is-property": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"generate-password": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/generate-password/-/generate-password-1.4.1.tgz",
|
||||
"integrity": "sha512-MwMSkOIKkgYBG3JrquF0m/Rky+pl5jZFNmoroE9bQU5VawFDKdJfxMx1qBthPusx8GQyNWSW0m+Jaw0mZnqApg=="
|
||||
},
|
||||
"generic-pool": {
|
||||
"version": "3.4.2",
|
||||
"resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.4.2.tgz",
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
"express": "^4.16.4",
|
||||
"express-handlebars": "^3.0.0",
|
||||
"express-http-context": "^1.2.0",
|
||||
"generate-password": "^1.4.1",
|
||||
"get-video-dimensions": "^1.0.0",
|
||||
"helmet": "^3.15.0",
|
||||
"image-size": "^0.6.3",
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||
const logger = require('winston');
|
||||
const db = require('../../../../models');
|
||||
const { auth: { masterPassword } } = require('@config/siteConfig.json');
|
||||
|
||||
const { masterPassword } = require('@private/authConfig.json');
|
||||
/*
|
||||
|
||||
route to update a password
|
||||
|
|
|
@ -26,13 +26,14 @@ const {
|
|||
|
||||
const {
|
||||
details: { port: PORT },
|
||||
auth: { sessionKey },
|
||||
startup: {
|
||||
performChecks,
|
||||
performUpdates,
|
||||
},
|
||||
} = require('@config/siteConfig');
|
||||
|
||||
const { sessionKey } = require('@private/authConfig.json');
|
||||
|
||||
function Server () {
|
||||
this.initialize = () => {
|
||||
// configure logging
|
||||
|
|
0
site/private/.gitkeep
Normal file
0
site/private/.gitkeep
Normal file
|
@ -42,6 +42,7 @@ module.exports = () => {
|
|||
|
||||
// aliases for configs
|
||||
moduleAliases['@config'] = resolve('site/config');
|
||||
moduleAliases['@private'] = resolve('site/private');
|
||||
|
||||
// create specific aliases for locally defined components in the following folders
|
||||
moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases);
|
||||
|
|
Loading…
Reference in a new issue