diff --git a/config/slackConfig.js b/config/slackConfig.js index 109671f2..0f7ed106 100644 --- a/config/slackConfig.js +++ b/config/slackConfig.js @@ -1,25 +1,26 @@ -const config = require('./speechConfig.js'); +const { logging } = require('./speechConfig.js'); +const { slackWebHook, slackErrorChannel, slackInfoChannel } = logging; const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook; module.exports = (winston) => { - if (config.logging.slackWebHook) { + if (slackWebHook) { // add a transport for errors to slack - if (config.logging.slackErrorChannel) { + if (slackErrorChannel) { winston.add(winstonSlackWebHook, { name : 'slack-errors-transport', level : 'warn', - webhookUrl: config.logging.slackWebHook, - channel : config.logging.slackErrorChannel, + webhookUrl: slackWebHook, + channel : slackErrorChannel, username : 'spee.ch', iconEmoji : ':face_with_head_bandage:', }); }; - if (config.logging.slackInfoChannel) { + if (slackInfoChannel) { winston.add(winstonSlackWebHook, { name : 'slack-info-transport', level : 'info', - webhookUrl: config.logging.slackWebHook, - channel : config.logging.slackInfoChannel, + webhookUrl: slackWebHook, + channel : slackInfoChannel, username : 'spee.ch', iconEmoji : ':nerd_face:', }); diff --git a/models/claim.js b/models/claim.js index 126d2c7a..2bc066d1 100644 --- a/models/claim.js +++ b/models/claim.js @@ -1,7 +1,7 @@ const logger = require('winston'); const { returnShortId } = require('../helpers/sequelizeHelpers.js'); -const { publishing, site } = require('../config/speechConfig.js'); -const { defaultTitle, defaultThumbnail, defaultDescription } = publishing; +const { claim, site } = require('../config/speechConfig.js'); +const { defaultTitle, defaultThumbnail, defaultDescription } = claim; const { host } = site; function determineFileExtensionFromContentType (contentType) { diff --git a/models/index.js b/models/index.js index b959586c..96a4bea5 100644 --- a/models/index.js +++ b/models/index.js @@ -4,9 +4,7 @@ const Sequelize = require('sequelize'); const basename = path.basename(module.filename); const logger = require('winston'); const config = require('../config/speechConfig.js'); -const database = config.sql.database; -const username = config.sql.username; -const password = config.sql.password; +const { database, username, password } = config.sql; const db = {}; // set sequelize options diff --git a/task-scripts/update-password.js b/task-scripts/update-password.js index c2cca20c..6a5176d4 100644 --- a/task-scripts/update-password.js +++ b/task-scripts/update-password.js @@ -3,7 +3,7 @@ const logger = require('winston'); const db = require('../models/index'); // require our models for syncing // configure logging const config = require('../config/speechConfig.js'); -const logLevel = config.logging.logLevel; +const { logLevel } = config.logging; require('../config/loggerConfig.js')(logger, logLevel); const userName = process.argv[2];