Merge pull request #432 from lbryio/update-configs-match-www.spee.ch

Update configs to match www.spee.ch
This commit is contained in:
Bill Bittner 2018-05-04 05:58:34 -07:00 committed by GitHub
commit e3c3d557dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 30 deletions

View file

@ -10,9 +10,6 @@ function SiteConfig () {
this.auth = { this.auth = {
sessionKey: 'default', sessionKey: 'default',
}; };
this.customComponents = {};
this.customContainers = {};
this.customPages = {};
this.details = { this.details = {
description: 'Welcome to my decentralized image and video sharing site.', description: 'Welcome to my decentralized image and video sharing site.',
host : 'http://localhost:3000', host : 'http://localhost:3000',
@ -29,22 +26,17 @@ function SiteConfig () {
thumbnailChannelId : 'default', thumbnailChannelId : 'default',
uploadDirectory : '/home/lbry/Uploads', uploadDirectory : '/home/lbry/Uploads',
}; };
this.routes = {};
this.update = (config) => { this.update = (config) => {
if (!config) { if (!config) {
return console.log('No site config received.'); 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...'); console.log('Configuring site details...');
this.analytics = analytics; this.analytics = analytics;
this.assetDefaults = assetDefaults; this.assetDefaults = assetDefaults;
this.auth = auth; this.auth = auth;
this.details = details; this.details = details;
this.publishing = publishing; this.publishing = publishing;
this.customComponents = customComponents;
this.customContainers = customContainers;
this.customPages = customPages;
this.routes = routes;
}; };
} }

View file

@ -28,7 +28,7 @@ function SlackConfig () {
iconEmoji : ':face_with_head_bandage:', iconEmoji : ':face_with_head_bandage:',
}); });
}; };
if (slackInfoChannel) { if (this.slackInfoChannel) {
winston.add(winstonSlackWebHook, { winston.add(winstonSlackWebHook, {
name : 'slack-info-transport', name : 'slack-info-transport',
level : 'info', level : 'info',

17
config/viewsConfig.js Normal file
View file

@ -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();

View file

@ -13,18 +13,14 @@ const loggerConfig = require('./config/loggerConfig.js');
const mysqlConfig = require('./config/mysqlConfig.js'); const mysqlConfig = require('./config/mysqlConfig.js');
const siteConfig = require('./config/siteConfig.js'); const siteConfig = require('./config/siteConfig.js');
const slackConfig = require('./config/slackConfig.js'); const slackConfig = require('./config/slackConfig.js');
const viewsConfig = require('./config/viewsConfig.js');
function Server () { function Server () {
this.configureLogger = loggerConfig.update; this.configureLogger = loggerConfig.update;
this.configureMysql = mysqlConfig.update; this.configureMysql = mysqlConfig.update;
this.configureSite = siteConfig.update; this.configureSite = siteConfig.update;
this.configureSlack = slackConfig.update; this.configureSlack = slackConfig.update;
this.configureModels = () => { this.configureViews = viewsConfig.update;
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.createApp = () => { this.createApp = () => {
// create an Express application // create an Express application
const app = express(); const app = express();
@ -33,21 +29,18 @@ function Server () {
app.enable('trust proxy'); app.enable('trust proxy');
/* add middleware */ /* add middleware */
// set HTTP headers to protect against well-known web vulnerabilties // set HTTP headers to protect against well-known web vulnerabilties
app.use(helmet()); app.use(helmet());
// 'express.static' to serve static files from public directory // 'express.static' to serve static files from public directory
if (siteConfig.routes.publicFolder) {
// take in a different public folder, so it can serve it's own bundle if needed
const publicFolder = Path.resolve(process.cwd(), siteConfig.routes.publicFolder);
app.use(express.static(publicFolder));
logger.info('serving static files from custom path:', publicFolder);
} else {
const publicPath = Path.resolve(process.cwd(), 'public'); const publicPath = Path.resolve(process.cwd(), 'public');
app.use(express.static(publicPath)); app.use(express.static(publicPath));
logger.warn(`serving static files from default static path at ${publicPath}. Please specify a path in your config/siteConfig.js file`); logger.info(`serving static files from default static path at ${publicPath}.`);
};
// 'body parser' for parsing application/json // 'body parser' for parsing application/json
app.use(bodyParser.json()); app.use(bodyParser.json());
// 'body parser' for parsing application/x-www-form-urlencoded // 'body parser' for parsing application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.urlencoded({ extended: true }));

View file

@ -34,6 +34,7 @@ const createBasicPublishParams = (filePath, name, title, description, license, n
if (thumbnail) { if (thumbnail) {
publishParams['metadata']['thumbnail'] = thumbnail; publishParams['metadata']['thumbnail'] = thumbnail;
} }
logger.debug('publish params:', publishParams);
return publishParams; return publishParams;
}; };

View file

@ -27,11 +27,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
*/ */
var siteConfig = require('../../../config/siteConfig.js'); var siteConfig = require('../../../config/siteConfig.js');
var viewsConfig = require('../../../config/viewsConfig.js');
module.exports = function (req, res) { module.exports = function (req, res) {
var context = {}; // customize the reducer by passing in intial state configs var context = {}; // customize the reducer by passing in intial state configs
var MyReducers = (0, _spee.Reducers)(siteConfig); var MyReducers = (0, _spee.Reducers)(siteConfig);
var MyApp = (0, _spee.App)(siteConfig); var MyApp = (0, _spee.App)(viewsConfig);
var MyGAListener = (0, _spee.GAListener)(siteConfig); // create a new Redux store instance var MyGAListener = (0, _spee.GAListener)(siteConfig); // create a new Redux store instance
var store = (0, _redux.createStore)(MyReducers); // render component to a string var store = (0, _redux.createStore)(MyReducers); // render component to a string

View file

@ -31,6 +31,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
*/ */
var siteConfig = require('../../../config/siteConfig.js'); var siteConfig = require('../../../config/siteConfig.js');
var viewsConfig = require('../../../config/viewsConfig.js');
var returnSagaWithParams = function returnSagaWithParams(saga, params) { var returnSagaWithParams = function returnSagaWithParams(saga, params) {
return ( return (
/*#__PURE__*/ /*#__PURE__*/
@ -56,7 +58,7 @@ module.exports = function (req, res) {
var context = {}; // configure the reducers by passing initial state configs var context = {}; // configure the reducers by passing initial state configs
var MyReducers = (0, _spee.Reducers)(siteConfig); var MyReducers = (0, _spee.Reducers)(siteConfig);
var MyApp = (0, _spee.App)(siteConfig); var MyApp = (0, _spee.App)(viewsConfig);
var MyGAListener = (0, _spee.GAListener)(siteConfig); // create and apply middleware var MyGAListener = (0, _spee.GAListener)(siteConfig); // create and apply middleware
var sagaMiddleware = (0, _reduxSaga.default)(); var sagaMiddleware = (0, _reduxSaga.default)();

View file

@ -15,13 +15,14 @@ import renderFullPage from '../renderFullPage.js';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
const siteConfig = require('../../../config/siteConfig.js'); const siteConfig = require('../../../config/siteConfig.js');
const viewsConfig = require('../../../config/viewsConfig.js');
module.exports = (req, res) => { module.exports = (req, res) => {
let context = {}; let context = {};
// customize the reducer by passing in intial state configs // customize the reducer by passing in intial state configs
const MyReducers = Reducers(siteConfig); const MyReducers = Reducers(siteConfig);
const MyApp = App(siteConfig); const MyApp = App(viewsConfig);
const MyGAListener = GAListener(siteConfig); const MyGAListener = GAListener(siteConfig);
// create a new Redux store instance // create a new Redux store instance

View file

@ -17,6 +17,7 @@ import { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
const siteConfig = require('../../../config/siteConfig.js'); const siteConfig = require('../../../config/siteConfig.js');
const viewsConfig = require('../../../config/viewsConfig.js');
const returnSagaWithParams = (saga, params) => { const returnSagaWithParams = (saga, params) => {
return function * () { return function * () {
@ -29,7 +30,7 @@ module.exports = (req, res) => {
// configure the reducers by passing initial state configs // configure the reducers by passing initial state configs
const MyReducers = Reducers(siteConfig); const MyReducers = Reducers(siteConfig);
const MyApp = App(siteConfig); const MyApp = App(viewsConfig);
const MyGAListener = GAListener(siteConfig); const MyGAListener = GAListener(siteConfig);
// create and apply middleware // create and apply middleware