0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-24 23:55:46 -05:00

refactor: use object assign

This commit is contained in:
Karl Wiggisser 2017-10-18 12:41:28 +02:00 committed by karl wiggisser
parent c84d567d76
commit 074086d31a

View file

@ -124,9 +124,9 @@ function afterConfigLoad() {
};
logger.logger.fatal([
'You need to specify either '
' "https.key", "https.cert" and "https.ca" or '
' "https.pfx" and optionally "https.passphrase" '
'You need to specify either ',
' "https.key", "https.cert" and "https.ca" or ',
' "https.pfx" and optionally "https.passphrase" ',
'to run https server',
'',
// commands are borrowed from node.js docs
@ -152,15 +152,17 @@ function afterConfigLoad() {
};
if (config.https.pfx) {
httpsoptions.pfx = fs.readFileSync(config.https.pfx);
httpsoptions.passphrase = config.https.passphrase || "";
Object.assign(httpsoptions, {
pfx: fs.readFileSync(config.https.pfx),
passphrase: config.https.passphrase || ""
});
} else {
httpsoptions.key = fs.readFileSync(config.https.key);
httpsoptions.cert = fs.readFileSync(config.https.cert);
httpsoptions.ca = fs.readFileSync(config.https.ca);
Object.assign(httpsoptions, {
key: fs.readFileSync(config.https.key),
cert: fs.readFileSync(config.https.cert),
ca: fs.readFileSync(config.https.ca)
});
}
webServer = https.createServer(httpsoptions, app);
} catch (err) { // catch errors related to certificate loading
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}');