Fix logical error with keys and mysql config

This commit is contained in:
Jamie Curnow 2023-03-21 17:59:27 +10:00
parent f8e6c8d018
commit 4fdc80be01
No known key found for this signature in database
GPG Key ID: FFBB624C43388E9E

View File

@ -21,6 +21,7 @@ const configure = () => {
if (configData && configData.database) {
logger.info(`Using configuration from file: ${filename}`);
instance = configData;
instance.keys = getKeys();
return;
}
}
@ -39,7 +40,8 @@ const configure = () => {
user: envMysqlUser,
password: process.env.DB_MYSQL_PASSWORD,
name: envMysqlName,
}
},
keys: getKeys(),
};
return;
}
@ -56,9 +58,12 @@ const configure = () => {
},
useNullAsDefault: true
}
}
},
keys: getKeys(),
};
};
const getKeys = () => {
// Get keys from file
if (!fs.existsSync(keysFile)) {
generateKeys();
@ -66,13 +71,11 @@ const configure = () => {
logger.info('Keys file exists OK');
}
try {
instance.keys = require(keysFile);
return require(keysFile);
} catch (err) {
logger.error('Could not read JWT key pair from config file: ' + keysFile, err);
process.exit(1);
}
logger.debug('Configuration: ' + JSON.stringify(instance, null, 2));
};
const generateKeys = () => {