From 18eaf81579f8078a60468ff02548b1315d64139e Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 2 May 2018 10:30:33 -0700 Subject: [PATCH] added separate views config file --- config/siteConfig.js | 10 +--------- config/slackConfig.js | 2 +- config/viewsConfig.js | 17 +++++++++++++++++ index.js | 8 ++------ 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 config/viewsConfig.js diff --git a/config/siteConfig.js b/config/siteConfig.js index af5e02f4..38a5bc67 100644 --- a/config/siteConfig.js +++ b/config/siteConfig.js @@ -10,9 +10,6 @@ function SiteConfig () { this.auth = { sessionKey: 'default', }; - this.customComponents = {}; - this.customContainers = {}; - this.customPages = {}; this.details = { description: 'Welcome to my decentralized image and video sharing site.', host : 'http://localhost:3000', @@ -29,22 +26,17 @@ function SiteConfig () { thumbnailChannelId : 'default', uploadDirectory : '/home/lbry/Uploads', }; - this.routes = {}; this.update = (config) => { if (!config) { return console.log('No site config received.'); } - const { analytics, assetDefaults, auth, customComponents, customContainers, customPages, details, publishing, routes } = config; + const { analytics, assetDefaults, auth, details, publishing } = config; console.log('Configuring site details...'); this.analytics = analytics; this.assetDefaults = assetDefaults; this.auth = auth; this.details = details; this.publishing = publishing; - this.customComponents = customComponents; - this.customContainers = customContainers; - this.customPages = customPages; - this.routes = routes; }; } diff --git a/config/slackConfig.js b/config/slackConfig.js index b9c8ab25..56008a27 100644 --- a/config/slackConfig.js +++ b/config/slackConfig.js @@ -28,7 +28,7 @@ function SlackConfig () { iconEmoji : ':face_with_head_bandage:', }); }; - if (slackInfoChannel) { + if (this.slackInfoChannel) { winston.add(winstonSlackWebHook, { name : 'slack-info-transport', level : 'info', diff --git a/config/viewsConfig.js b/config/viewsConfig.js new file mode 100644 index 00000000..11310efa --- /dev/null +++ b/config/viewsConfig.js @@ -0,0 +1,17 @@ +function ViewsConfig () { + this.components = {}; + this.containers = {}; + this.pages = {}; + this.update = (config) => { + if (!config) { + return console.log('No components config received.'); + } + const { components, containers, pages } = config; + console.log('Configuring custom components ...'); + this.components = components; + this.containers = containers; + this.pages = pages; + }; +} + +module.exports = new ViewsConfig(); diff --git a/index.js b/index.js index 0e2a6efc..60af5519 100644 --- a/index.js +++ b/index.js @@ -13,18 +13,14 @@ const loggerConfig = require('./config/loggerConfig.js'); const mysqlConfig = require('./config/mysqlConfig.js'); const siteConfig = require('./config/siteConfig.js'); const slackConfig = require('./config/slackConfig.js'); +const viewsConfig = require('./config/viewsConfig.js'); function Server () { this.configureLogger = loggerConfig.update; this.configureMysql = mysqlConfig.update; this.configureSite = siteConfig.update; this.configureSlack = slackConfig.update; - this.configureModels = () => { - logger.debug('here is where you could add/overwrite the default models') - }; - this.configureRoutes = () => { - logger.debug('here is where you could add/overwrite the default routes') - }; + this.configureViews = viewsConfig.update; this.createApp = () => { // create an Express application const app = express();