From ac0c28b8f979756655aa2afe127d8f1cfc9b3149 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 12 Mar 2018 19:26:03 -0700 Subject: [PATCH] updated site config files --- .sequelizerc | 4 ++-- config/mysqlConfig.js | 14 +++++++---- config/siteConfig.js | 48 +++++++++++++++++++++----------------- config/slackConfig.js | 14 +++++++---- helpers/googleAnalytics.js | 4 ++-- react/utils/pageTitle.js | 6 ++--- server.js | 7 ++---- 7 files changed, 56 insertions(+), 41 deletions(-) diff --git a/.sequelizerc b/.sequelizerc index f2daa0b6..757fef10 100644 --- a/.sequelizerc +++ b/.sequelizerc @@ -1,5 +1,5 @@ const path = require('path'); module.exports = { - 'config': path.resolve('config', 'sequelizeCliConfig.js'), -} \ No newline at end of file + 'config': path.resolve('devConfig', 'sequelizeCliConfig.js'), +} diff --git a/config/mysqlConfig.js b/config/mysqlConfig.js index 9591f510..bd8bdc35 100644 --- a/config/mysqlConfig.js +++ b/config/mysqlConfig.js @@ -1,11 +1,17 @@ +const logger = require('winston'); + function MysqlConfig () { this.database = 'default'; this.username = 'default'; this.password = 'default'; - this.configure = ({database, username, password}) => { - if (database) this.database = database; - if (username) this.username = username; - if (password) this.password = password; + this.configure = (config) => { + if (!config) { + return logger.warn('No MySQL config received.'); + } + const {database, username, password} = config; + this.database = database; + this.username = username; + this.password = password; }; }; diff --git a/config/siteConfig.js b/config/siteConfig.js index eeeed34f..401ac0d3 100644 --- a/config/siteConfig.js +++ b/config/siteConfig.js @@ -1,34 +1,40 @@ +const logger = require('winston'); + function SiteConfig () { this.analytics = { googleId: 'default', }; + this.assetDefaults = { + title : 'Spee.ch', + thumbnail : 'https://spee.ch/assets/img/video_thumb_default.png', + description: 'Open-source, decentralized image and video sharing.', + }; + this.auth = { + sessionKey: 'default', + }; + this.details = { + title : 'Spee.h Dev1', + host : 'https://dev1.spee.ch', + description: 'Open-source, decentralized image and video sharing.', + }; this.publishing = { + additionalClaimAddresses: [], // optional + disabled : false, primaryClaimAddress : 'default', - additionalClaimAddresses: [], thumbnailChannel : 'default', thumbnailChannelId : 'default', uploadDirectory : '/home/lbry/Uploads', }; - this.details = { - title : 'Spee { - if (analytics) this.analytics = analytics; - if (publishing) this.publishing = publishing; - if (details) this.details = details; - if (assetDefaults) this.assetDefaults = assetDefaults; - if (session) this.session = session; + this.configure = (config) => { + if (!config) { + return logger.warn('No site config received.'); + } + const {analytics, publishing, details, assetDefaults, auth} = config; + this.analytics = analytics; + this.publishing = publishing; + this.details = details; + this.assetDefaults = assetDefaults; + this.auth = auth; }; }; diff --git a/config/slackConfig.js b/config/slackConfig.js index 4e973f0f..b12c09bb 100644 --- a/config/slackConfig.js +++ b/config/slackConfig.js @@ -1,11 +1,17 @@ +const logger = require('winston'); + function SlackConfig () { this.slackWebHook = 'default'; this.slackErrorChannel = 'default'; this.slackInfoChannel = 'default'; - this.configure = ({slackWebHook, slackErrorChannel, slackInfoChannel}) => { - if (slackWebHook) this.slackWebHook = slackWebHook; - if (slackErrorChannel) this.slackErrorChannel = slackErrorChannel; - if (slackInfoChannel) this.slackInfoChannel = slackInfoChannel; + this.configure = (config) => { + if (!config) { + return logger.warn('No slack config received.'); + } + const {slackWebHook, slackErrorChannel, slackInfoChannel} = config; + this.slackWebHook = slackWebHook; + this.slackErrorChannel = slackErrorChannel; + this.slackInfoChannel = slackInfoChannel; }; }; diff --git a/helpers/googleAnalytics.js b/helpers/googleAnalytics.js index 3a5ee5de..ed7b876c 100644 --- a/helpers/googleAnalytics.js +++ b/helpers/googleAnalytics.js @@ -1,6 +1,6 @@ const logger = require('winston'); const ua = require('universal-analytics'); -const { analytics : { googleId }, details: { name: siteName } } = require('../config/siteConfig.js'); +const { analytics : { googleId }, details: { title } } = require('../config/siteConfig.js'); function createServeEventParams (headers, ip, originalUrl) { return { @@ -49,7 +49,7 @@ module.exports = { }, sendGATimingEvent (category, variable, label, startTime, endTime) { const params = createPublishTimingEventParams(category, variable, label, startTime, endTime); - sendGoogleAnalyticsTiming(siteName, params); + sendGoogleAnalyticsTiming(title, params); }, chooseGaLbrynetPublishLabel ({ channel_name: channelName, channel_id: channelId }) { return (channelName || channelId ? 'PUBLISH_IN_CHANNEL_CLAIM' : 'PUBLISH_ANONYMOUS_CLAIM'); diff --git a/react/utils/pageTitle.js b/react/utils/pageTitle.js index d8949949..4a510b36 100644 --- a/react/utils/pageTitle.js +++ b/react/utils/pageTitle.js @@ -1,8 +1,8 @@ -const { details: { title: siteTitle } } = require('../../config/siteConfig.js'); +const { details: { title } } = require('../../config/siteConfig.js'); export const createPageTitle = (pageTitle) => { if (!pageTitle) { - return `${siteTitle}`; + return `${title}`; } - return `${siteTitle} - ${pageTitle}`; + return `${title} - ${pageTitle}`; }; diff --git a/server.js b/server.js index b9d3c9a0..9fe8cde1 100644 --- a/server.js +++ b/server.js @@ -13,12 +13,9 @@ const logger = require('winston'); function SpeechServer ({ mysqlConfig, siteConfig, slackConfig }) { this.PORT = 3000; - this.speak = (something) => { - console.log(something); - }; this.start = () => { - this.configureConfigFiles(); this.configureLogging(); + this.configureConfigFiles(); this.configureApp(); this.configureServer(); this.startServer(); @@ -61,7 +58,7 @@ function SpeechServer ({ mysqlConfig, siteConfig, slackConfig }) { // initialize passport app.use(cookieSession({ name : 'session', - keys : [siteConfig.session.sessionKey], + keys : [siteConfig.auth.sessionKey], maxAge: 24 * 60 * 60 * 1000, // i.e. 24 hours })); app.use(passport.initialize());