Merge pull request #432 from lbryio/update-configs-match-www.spee.ch
Update configs to match www.spee.ch
This commit is contained in:
commit
e3c3d557dc
9 changed files with 39 additions and 30 deletions
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
17
config/viewsConfig.js
Normal file
17
config/viewsConfig.js
Normal 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();
|
25
index.js
25
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();
|
||||
|
@ -33,21 +29,18 @@ function Server () {
|
|||
app.enable('trust proxy');
|
||||
|
||||
/* add middleware */
|
||||
|
||||
// set HTTP headers to protect against well-known web vulnerabilties
|
||||
app.use(helmet());
|
||||
|
||||
// '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');
|
||||
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`);
|
||||
};
|
||||
const publicPath = Path.resolve(process.cwd(), 'public');
|
||||
app.use(express.static(publicPath));
|
||||
logger.info(`serving static files from default static path at ${publicPath}.`);
|
||||
|
||||
// 'body parser' for parsing application/json
|
||||
app.use(bodyParser.json());
|
||||
|
||||
// 'body parser' for parsing application/x-www-form-urlencoded
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ const createBasicPublishParams = (filePath, name, title, description, license, n
|
|||
if (thumbnail) {
|
||||
publishParams['metadata']['thumbnail'] = thumbnail;
|
||||
}
|
||||
logger.debug('publish params:', publishParams);
|
||||
return publishParams;
|
||||
};
|
||||
|
||||
|
|
|
@ -27,11 +27,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|||
*/
|
||||
var siteConfig = require('../../../config/siteConfig.js');
|
||||
|
||||
var viewsConfig = require('../../../config/viewsConfig.js');
|
||||
|
||||
module.exports = function (req, res) {
|
||||
var context = {}; // customize the reducer by passing in intial state configs
|
||||
|
||||
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 store = (0, _redux.createStore)(MyReducers); // render component to a string
|
||||
|
|
|
@ -31,6 +31,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|||
*/
|
||||
var siteConfig = require('../../../config/siteConfig.js');
|
||||
|
||||
var viewsConfig = require('../../../config/viewsConfig.js');
|
||||
|
||||
var returnSagaWithParams = function returnSagaWithParams(saga, params) {
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
|
@ -56,7 +58,7 @@ module.exports = function (req, res) {
|
|||
var context = {}; // configure the reducers by passing initial state configs
|
||||
|
||||
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 sagaMiddleware = (0, _reduxSaga.default)();
|
||||
|
|
|
@ -15,13 +15,14 @@ import renderFullPage from '../renderFullPage.js';
|
|||
import Helmet from 'react-helmet';
|
||||
|
||||
const siteConfig = require('../../../config/siteConfig.js');
|
||||
const viewsConfig = require('../../../config/viewsConfig.js');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
let context = {};
|
||||
|
||||
// customize the reducer by passing in intial state configs
|
||||
const MyReducers = Reducers(siteConfig);
|
||||
const MyApp = App(siteConfig);
|
||||
const MyApp = App(viewsConfig);
|
||||
const MyGAListener = GAListener(siteConfig);
|
||||
|
||||
// create a new Redux store instance
|
||||
|
|
|
@ -17,6 +17,7 @@ import { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components';
|
|||
import Helmet from 'react-helmet';
|
||||
|
||||
const siteConfig = require('../../../config/siteConfig.js');
|
||||
const viewsConfig = require('../../../config/viewsConfig.js');
|
||||
|
||||
const returnSagaWithParams = (saga, params) => {
|
||||
return function * () {
|
||||
|
@ -29,7 +30,7 @@ module.exports = (req, res) => {
|
|||
|
||||
// configure the reducers by passing initial state configs
|
||||
const MyReducers = Reducers(siteConfig);
|
||||
const MyApp = App(siteConfig);
|
||||
const MyApp = App(viewsConfig);
|
||||
const MyGAListener = GAListener(siteConfig);
|
||||
|
||||
// create and apply middleware
|
||||
|
|
Loading…
Reference in a new issue