Fix configs loading #470
15 changed files with 426 additions and 428 deletions
|
@ -19,15 +19,12 @@ var _channelCreate = _interopRequireDefault(require("./channelCreate"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var customizedReducers = function customizedReducers(siteConfig) {
|
var _default = (0, _redux.combineReducers)({
|
||||||
return (0, _redux.combineReducers)({
|
|
||||||
channel: _channel.default,
|
channel: _channel.default,
|
||||||
channelCreate: _channelCreate.default,
|
channelCreate: _channelCreate.default,
|
||||||
publish: (0, _publish.default)(siteConfig),
|
publish: _publish.default,
|
||||||
show: _show.default,
|
show: _show.default,
|
||||||
site: (0, _site.default)(siteConfig)
|
site: _site.default
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
var _default = customizedReducers;
|
|
||||||
exports.default = _default;
|
exports.default = _default;
|
|
@ -9,23 +9,26 @@ var actions = _interopRequireWildcard(require("../constants/publish_action_types
|
||||||
|
|
||||||
var _publish_channel_select_states = require("../constants/publish_channel_select_states");
|
var _publish_channel_select_states = require("../constants/publish_channel_select_states");
|
||||||
|
|
||||||
|
var _siteConfig = _interopRequireDefault(require("@config/siteConfig"));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||||
|
|
||||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||||
|
|
||||||
var customizedPublishReducer = function customizedPublishReducer(siteConfig) {
|
|
||||||
// parse inputs
|
// parse inputs
|
||||||
var disabledConfig = false;
|
var disabledConfig = false;
|
||||||
var disabledMessageConfig = 'none';
|
var disabledMessageConfig = 'none';
|
||||||
var thumbnailChannel = '';
|
var thumbnailChannel = '';
|
||||||
var thumbnailChannelId = '';
|
var thumbnailChannelId = '';
|
||||||
|
|
||||||
if (siteConfig) {
|
if (_siteConfig.default) {
|
||||||
if (siteConfig.publishing) {
|
if (_siteConfig.default.publishing) {
|
||||||
disabledConfig = siteConfig.publishing.disabled;
|
disabledConfig = _siteConfig.default.publishing.disabled;
|
||||||
disabledMessageConfig = siteConfig.publishing.disabledMessage;
|
disabledMessageConfig = _siteConfig.default.publishing.disabledMessage;
|
||||||
thumbnailChannel = siteConfig.publishing.thumbnailChannel;
|
thumbnailChannel = _siteConfig.default.publishing.thumbnailChannel;
|
||||||
thumbnailChannelId = siteConfig.publishing.thumbnailChannelId;
|
thumbnailChannelId = _siteConfig.default.publishing.thumbnailChannelId;
|
||||||
}
|
}
|
||||||
} // create initial state
|
} // create initial state
|
||||||
|
|
||||||
|
@ -57,7 +60,8 @@ var customizedPublishReducer = function customizedPublishReducer(siteConfig) {
|
||||||
thumbnailChannel: thumbnailChannel,
|
thumbnailChannel: thumbnailChannel,
|
||||||
thumbnailChannelId: thumbnailChannelId
|
thumbnailChannelId: thumbnailChannelId
|
||||||
};
|
};
|
||||||
return function () {
|
|
||||||
|
var _default = function _default() {
|
||||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
||||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
|
|
||||||
|
@ -115,7 +119,5 @@ var customizedPublishReducer = function customizedPublishReducer(siteConfig) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
var _default = customizedPublishReducer;
|
|
||||||
exports.default = _default;
|
exports.default = _default;
|
|
@ -5,15 +5,26 @@ Object.defineProperty(exports, "__esModule", {
|
||||||
});
|
});
|
||||||
exports.default = void 0;
|
exports.default = void 0;
|
||||||
|
|
||||||
var customizedSiteReducer = function customizedSiteReducer(siteConfig) {
|
var _siteConfig = _interopRequireDefault(require("@config/siteConfig"));
|
||||||
var initialState = {};
|
|
||||||
|
|
||||||
if (siteConfig) {
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
var googleAnalyticsId = siteConfig.analytics.googleId,
|
|
||||||
_siteConfig$assetDefa = siteConfig.assetDefaults,
|
var initialState = {
|
||||||
|
description: 'default description',
|
||||||
|
googleAnalyticsId: 'default google id',
|
||||||
|
host: 'default host',
|
||||||
|
title: 'default title',
|
||||||
|
twitter: 'default twitter',
|
||||||
|
defaultDescription: 'default description',
|
||||||
|
defaultThumbnail: 'default thumbnail'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_siteConfig.default) {
|
||||||
|
var googleAnalyticsId = _siteConfig.default.analytics.googleId,
|
||||||
|
_siteConfig$assetDefa = _siteConfig.default.assetDefaults,
|
||||||
defaultThumbnail = _siteConfig$assetDefa.thumbnail,
|
defaultThumbnail = _siteConfig$assetDefa.thumbnail,
|
||||||
defaultDescription = _siteConfig$assetDefa.description,
|
defaultDescription = _siteConfig$assetDefa.description,
|
||||||
_siteConfig$details = siteConfig.details,
|
_siteConfig$details = _siteConfig.default.details,
|
||||||
description = _siteConfig$details.description,
|
description = _siteConfig$details.description,
|
||||||
host = _siteConfig$details.host,
|
host = _siteConfig$details.host,
|
||||||
title = _siteConfig$details.title,
|
title = _siteConfig$details.title,
|
||||||
|
@ -27,19 +38,9 @@ var customizedSiteReducer = function customizedSiteReducer(siteConfig) {
|
||||||
defaultDescription: defaultDescription,
|
defaultDescription: defaultDescription,
|
||||||
defaultThumbnail: defaultThumbnail
|
defaultThumbnail: defaultThumbnail
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
initialState = {
|
|
||||||
description: 'default description',
|
|
||||||
googleAnalyticsId: 'default google id',
|
|
||||||
host: 'default host',
|
|
||||||
title: 'default title',
|
|
||||||
twitter: 'default twitter',
|
|
||||||
defaultDescription: 'default description',
|
|
||||||
defaultThumbnail: 'default thumbnail'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return function () {
|
var _default = function _default() {
|
||||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
||||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
|
|
||||||
|
@ -48,7 +49,5 @@ var customizedSiteReducer = function customizedSiteReducer(siteConfig) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
var _default = customizedSiteReducer;
|
|
||||||
exports.default = _default;
|
exports.default = _default;
|
|
@ -1,18 +1,15 @@
|
||||||
import { combineReducers } from 'redux';
|
import { combineReducers } from 'redux';
|
||||||
|
|
||||||
import PublishReducer from './publish';
|
import PublishReducer from './publish';
|
||||||
import ChannelReducer from './channel';
|
import ChannelReducer from './channel';
|
||||||
import ShowReducer from './show';
|
import ShowReducer from './show';
|
||||||
import SiteReducer from './site';
|
import SiteReducer from './site';
|
||||||
import ChannelCreateReducer from './channelCreate';
|
import ChannelCreateReducer from './channelCreate';
|
||||||
|
|
||||||
const customizedReducers = (siteConfig) => {
|
export default combineReducers({
|
||||||
return combineReducers({
|
|
||||||
channel : ChannelReducer,
|
channel : ChannelReducer,
|
||||||
channelCreate: ChannelCreateReducer,
|
channelCreate: ChannelCreateReducer,
|
||||||
publish : PublishReducer(siteConfig),
|
publish : PublishReducer,
|
||||||
show : ShowReducer,
|
show : ShowReducer,
|
||||||
site : SiteReducer(siteConfig),
|
site : SiteReducer,
|
||||||
})
|
});
|
||||||
};
|
|
||||||
|
|
||||||
export default customizedReducers;
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import * as actions from '../constants/publish_action_types';
|
import * as actions from '../constants/publish_action_types';
|
||||||
import { LOGIN } from '../constants/publish_channel_select_states';
|
import { LOGIN } from '../constants/publish_channel_select_states';
|
||||||
|
|
||||||
const customizedPublishReducer = (siteConfig) => {
|
import siteConfig from '@config/siteConfig';
|
||||||
|
|
||||||
// parse inputs
|
// parse inputs
|
||||||
let disabledConfig = false;
|
let disabledConfig = false;
|
||||||
let disabledMessageConfig = 'none';
|
let disabledMessageConfig = 'none';
|
||||||
|
@ -15,6 +16,7 @@ const customizedPublishReducer = (siteConfig) => {
|
||||||
thumbnailChannelId = siteConfig.publishing.thumbnailChannelId;
|
thumbnailChannelId = siteConfig.publishing.thumbnailChannelId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create initial state
|
// create initial state
|
||||||
const initialState = {
|
const initialState = {
|
||||||
disabled : disabledConfig,
|
disabled : disabledConfig,
|
||||||
|
@ -43,7 +45,8 @@ const customizedPublishReducer = (siteConfig) => {
|
||||||
thumbnailChannel,
|
thumbnailChannel,
|
||||||
thumbnailChannelId,
|
thumbnailChannelId,
|
||||||
};
|
};
|
||||||
return (state = initialState, action) => {
|
|
||||||
|
export default (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.FILE_SELECTED:
|
case actions.FILE_SELECTED:
|
||||||
return Object.assign({}, initialState, { // note: clears to initial state
|
return Object.assign({}, initialState, { // note: clears to initial state
|
||||||
|
@ -91,6 +94,3 @@ const customizedPublishReducer = (siteConfig) => {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
export default customizedPublishReducer;
|
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
const customizedSiteReducer = (siteConfig) => {
|
import siteConfig from '@config/siteConfig';
|
||||||
let initialState = {};
|
|
||||||
|
let initialState = {
|
||||||
|
description : 'default description',
|
||||||
|
googleAnalyticsId : 'default google id',
|
||||||
|
host : 'default host',
|
||||||
|
title : 'default title',
|
||||||
|
twitter : 'default twitter',
|
||||||
|
defaultDescription: 'default description',
|
||||||
|
defaultThumbnail : 'default thumbnail',
|
||||||
|
};
|
||||||
|
|
||||||
if (siteConfig) {
|
if (siteConfig) {
|
||||||
const {
|
const {
|
||||||
analytics: {
|
analytics: {
|
||||||
|
@ -26,23 +36,11 @@ const customizedSiteReducer = (siteConfig) => {
|
||||||
defaultDescription,
|
defaultDescription,
|
||||||
defaultThumbnail,
|
defaultThumbnail,
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
initialState = {
|
|
||||||
description : 'default description',
|
|
||||||
googleAnalyticsId : 'default google id',
|
|
||||||
host : 'default host',
|
|
||||||
title : 'default title',
|
|
||||||
twitter : 'default twitter',
|
|
||||||
defaultDescription: 'default description',
|
|
||||||
defaultThumbnail : 'default thumbnail',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return (state = initialState, action) => {
|
|
||||||
|
export default (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
export default customizedSiteReducer;
|
|
||||||
|
|
68
index.js
68
index.js
|
@ -1,3 +1,10 @@
|
||||||
|
// set up aliasing
|
||||||
|
const moduleAlias = require('module-alias');
|
||||||
|
const createModuleAliases = require('./server/utils/createModuleAliases.js');
|
||||||
|
const customAliases = createModuleAliases();
|
||||||
|
console.log('custom aliases', customAliases);
|
||||||
|
moduleAlias.addAliases(customAliases);
|
||||||
|
|
||||||
// load modules
|
// load modules
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
|
@ -8,34 +15,36 @@ const cookieSession = require('cookie-session');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const Path = require('path');
|
const Path = require('path');
|
||||||
const moduleAlias = require('module-alias');
|
|
||||||
|
|
||||||
// load local modules
|
// load local modules
|
||||||
|
const db = require('./server/models');
|
||||||
const requestLogger = require('./server/middleware/requestLogger.js');
|
const requestLogger = require('./server/middleware/requestLogger.js');
|
||||||
const createDatabaseIfNotExists = require('./server/models/utils/createDatabaseIfNotExists.js');
|
const createDatabaseIfNotExists = require('./server/models/utils/createDatabaseIfNotExists.js');
|
||||||
const { getWalletBalance } = require('./server/lbrynet');
|
const { getWalletBalance } = require('./server/lbrynet');
|
||||||
const db = require('./server/models');
|
|
||||||
const configureLogging = require('./server/utils/configureLogging.js');
|
const configureLogging = require('./server/utils/configureLogging.js');
|
||||||
const configureSlack = require('./server/utils/configureSlack.js');
|
const configureSlack = require('./server/utils/configureSlack.js');
|
||||||
const speechPassport = require('./server/speechPassport');
|
const speechPassport = require('./server/speechPassport');
|
||||||
const createModuleAliases = require('./utils/createModuleAliases.js');
|
|
||||||
|
|
||||||
// set up aliasing
|
// test configs
|
||||||
const customAliases = createModuleAliases();
|
|
||||||
logger.debug('custom aliases', customAliases);
|
|
||||||
moduleAlias.addAliases(customAliases);
|
|
||||||
|
|
||||||
// load aliased modules
|
|
||||||
const siteConfig = require('@config/siteConfig');
|
const siteConfig = require('@config/siteConfig');
|
||||||
|
console.log('siteConfig:', siteConfig);
|
||||||
|
const mysqlConfig = require('@config/mysqlConfig');
|
||||||
|
console.log('mysqlConfig:', mysqlConfig);
|
||||||
|
const slackConfig = require('@config/slackConfig');
|
||||||
|
console.log('slackConfig:', slackConfig);
|
||||||
|
const loggerConfig = require('@config/loggerConfig');
|
||||||
|
console.log('loggerConfig:', loggerConfig);
|
||||||
|
|
||||||
const PORT = siteConfig.details.port;
|
const PORT = siteConfig.details.port;
|
||||||
|
|
||||||
const startServer = () => {
|
function Server () {
|
||||||
|
this.initialize = () => {
|
||||||
// configure logging
|
// configure logging
|
||||||
configureLogging();
|
configureLogging();
|
||||||
|
|
||||||
// configure slack logging
|
// configure slack logging
|
||||||
configureSlack();
|
configureSlack();
|
||||||
|
};
|
||||||
|
this.createApp = () => {
|
||||||
/* create app */
|
/* create app */
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
@ -83,20 +92,32 @@ const startServer = () => {
|
||||||
require('./server/routes/assets')(app);
|
require('./server/routes/assets')(app);
|
||||||
require('./server/routes/fallback')(app);
|
require('./server/routes/fallback')(app);
|
||||||
|
|
||||||
|
this.app = app;
|
||||||
|
};
|
||||||
|
this.createServer = () => {
|
||||||
/* create server */
|
/* create server */
|
||||||
const server = http.Server(app);
|
this.server = http.Server(this.app);
|
||||||
|
};
|
||||||
/* start the server */
|
this.syncDatabase = () => {
|
||||||
createDatabaseIfNotExists()
|
return createDatabaseIfNotExists()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return getWalletBalance();
|
|
||||||
})
|
|
||||||
.then(balance => {
|
|
||||||
logger.info('starting LBC balance:', balance);
|
|
||||||
db.sequelize.sync();
|
db.sequelize.sync();
|
||||||
server.listen(PORT, () => {
|
})
|
||||||
|
};
|
||||||
|
this.start = () => {
|
||||||
|
this.initialize();
|
||||||
|
this.createApp();
|
||||||
|
this.createServer();
|
||||||
|
/* start the server */
|
||||||
|
Promise.all([
|
||||||
|
this.syncDatabase(),
|
||||||
|
getWalletBalance(),
|
||||||
|
])
|
||||||
|
.then(([syncResult, walletBalance]) => {
|
||||||
|
logger.info('starting LBC balance:', walletBalance);
|
||||||
|
return this.server.listen(PORT, () => {
|
||||||
logger.info(`Server is listening on PORT ${PORT}`);
|
logger.info(`Server is listening on PORT ${PORT}`);
|
||||||
});
|
})
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.code === 'ECONNREFUSED') {
|
if (error.code === 'ECONNREFUSED') {
|
||||||
|
@ -107,5 +128,6 @@ const startServer = () => {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = startServer;
|
module.exports = Server;
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const Sequelize = require('sequelize');
|
||||||
|
const logger = require('winston');
|
||||||
|
|
||||||
const Certificate = require('./certificate.js');
|
const Certificate = require('./certificate.js');
|
||||||
const Channel = require('./channel.js');
|
const Channel = require('./channel.js');
|
||||||
const Claim = require('./claim.js');
|
const Claim = require('./claim.js');
|
||||||
|
@ -6,10 +9,10 @@ const Request = require('./request.js');
|
||||||
const User = require('./user.js');
|
const User = require('./user.js');
|
||||||
const Blocked = require('./blocked.js');
|
const Blocked = require('./blocked.js');
|
||||||
|
|
||||||
const Sequelize = require('sequelize');
|
|
||||||
const logger = require('winston');
|
|
||||||
|
|
||||||
const {database, username, password} = require('@config/mysqlConfig');
|
const {database, username, password} = require('@config/mysqlConfig');
|
||||||
|
if (!database || !username || !password) {
|
||||||
|
logger.warn('missing database, user, or password from mysqlConfig');
|
||||||
|
}
|
||||||
|
|
||||||
// set sequelize options
|
// set sequelize options
|
||||||
const sequelize = new Sequelize(database, username, password, {
|
const sequelize = new Sequelize(database, username, password, {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const Sequelize = require('sequelize');
|
const Sequelize = require('sequelize');
|
||||||
|
const {database, username, password} = require('@config/mysqlConfig');
|
||||||
|
|
||||||
const createDatabaseIfNotExists = () => {
|
const createDatabaseIfNotExists = () => {
|
||||||
const {database, username, password} = require('@config/mysqlConfig');
|
|
||||||
const sequelize = new Sequelize('', username, password, {
|
const sequelize = new Sequelize('', username, password, {
|
||||||
dialect : 'mysql',
|
dialect : 'mysql',
|
||||||
logging : false,
|
logging : false,
|
||||||
|
|
|
@ -22,23 +22,17 @@ var _reactHelmet = _interopRequireDefault(require("react-helmet"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var siteConfig = require('@config/siteConfig');
|
|
||||||
|
|
||||||
module.exports = function (req, res) {
|
module.exports = function (req, res) {
|
||||||
var context = {}; // customize the reducer by passing in intial state configs
|
var context = {}; // create a new Redux store instance
|
||||||
|
|
||||||
var MyReducers = (0, _reducers.default)(siteConfig);
|
var store = (0, _redux.createStore)(_reducers.default); // render component to a string
|
||||||
var MyApp = _app.default;
|
|
||||||
var MyGAListener = (0, _GAListener.default)(siteConfig); // create a new Redux store instance
|
|
||||||
|
|
||||||
var store = (0, _redux.createStore)(MyReducers); // render component to a string
|
|
||||||
|
|
||||||
var html = (0, _server.renderToString)(_react.default.createElement(_reactRedux.Provider, {
|
var html = (0, _server.renderToString)(_react.default.createElement(_reactRedux.Provider, {
|
||||||
store: store
|
store: store
|
||||||
}, _react.default.createElement(_reactRouterDom.StaticRouter, {
|
}, _react.default.createElement(_reactRouterDom.StaticRouter, {
|
||||||
location: req.url,
|
location: req.url,
|
||||||
context: context
|
context: context
|
||||||
}, _react.default.createElement(MyGAListener, null, _react.default.createElement(MyApp, null))))); // get head tags from helmet
|
}, _react.default.createElement(_GAListener.default, null, _react.default.createElement(_app.default, null))))); // get head tags from helmet
|
||||||
|
|
||||||
var helmet = _reactHelmet.default.renderStatic(); // check for a redirect
|
var helmet = _reactHelmet.default.renderStatic(); // check for a redirect
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ var _reactHelmet = _interopRequireDefault(require("react-helmet"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var siteConfig = require('@config/siteConfig');
|
|
||||||
|
|
||||||
var returnSagaWithParams = function returnSagaWithParams(saga, params) {
|
var returnSagaWithParams = function returnSagaWithParams(saga, params) {
|
||||||
return (
|
return (
|
||||||
/*#__PURE__*/
|
/*#__PURE__*/
|
||||||
|
@ -54,16 +52,12 @@ var returnSagaWithParams = function returnSagaWithParams(saga, params) {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function (req, res) {
|
module.exports = function (req, res) {
|
||||||
var context = {}; // configure the reducers by passing initial state configs
|
var context = {}; // create and apply middleware
|
||||||
|
|
||||||
var MyReducers = (0, _reducers.default)(siteConfig);
|
|
||||||
var MyApp = _app.default;
|
|
||||||
var MyGAListener = (0, _GAListener.default)(siteConfig); // create and apply middleware
|
|
||||||
|
|
||||||
var sagaMiddleware = (0, _reduxSaga.default)();
|
var sagaMiddleware = (0, _reduxSaga.default)();
|
||||||
var middleware = (0, _redux.applyMiddleware)(sagaMiddleware); // create a new Redux store instance
|
var middleware = (0, _redux.applyMiddleware)(sagaMiddleware); // create a new Redux store instance
|
||||||
|
|
||||||
var store = (0, _redux.createStore)(MyReducers, middleware); // create saga
|
var store = (0, _redux.createStore)(_reducers.default, middleware); // create saga
|
||||||
|
|
||||||
var action = _actions.default.onHandleShowPageUri(req.params);
|
var action = _actions.default.onHandleShowPageUri(req.params);
|
||||||
|
|
||||||
|
@ -76,7 +70,7 @@ module.exports = function (req, res) {
|
||||||
}, _react.default.createElement(_reactRouterDom.StaticRouter, {
|
}, _react.default.createElement(_reactRouterDom.StaticRouter, {
|
||||||
location: req.url,
|
location: req.url,
|
||||||
context: context
|
context: context
|
||||||
}, _react.default.createElement(MyGAListener, null, _react.default.createElement(MyApp, null))))); // get head tags from helmet
|
}, _react.default.createElement(_GAListener.default, null, _react.default.createElement(_app.default, null))))); // get head tags from helmet
|
||||||
|
|
||||||
var helmet = _reactHelmet.default.renderStatic(); // check for a redirect
|
var helmet = _reactHelmet.default.renderStatic(); // check for a redirect
|
||||||
|
|
||||||
|
|
|
@ -9,26 +9,19 @@ import App from '@app';
|
||||||
import renderFullPage from '../renderFullPage.js';
|
import renderFullPage from '../renderFullPage.js';
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
const siteConfig = require('@config/siteConfig');
|
|
||||||
|
|
||||||
module.exports = (req, res) => {
|
module.exports = (req, res) => {
|
||||||
let context = {};
|
let context = {};
|
||||||
|
|
||||||
// customize the reducer by passing in intial state configs
|
|
||||||
const MyReducers = Reducers(siteConfig);
|
|
||||||
const MyApp = App;
|
|
||||||
const MyGAListener = GAListener(siteConfig);
|
|
||||||
|
|
||||||
// create a new Redux store instance
|
// create a new Redux store instance
|
||||||
const store = createStore(MyReducers);
|
const store = createStore(Reducers);
|
||||||
|
|
||||||
// render component to a string
|
// render component to a string
|
||||||
const html = renderToString(
|
const html = renderToString(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<StaticRouter location={req.url} context={context}>
|
<StaticRouter location={req.url} context={context}>
|
||||||
<MyGAListener>
|
<GAListener>
|
||||||
<MyApp />
|
<App />
|
||||||
</MyGAListener>
|
</GAListener>
|
||||||
</StaticRouter>
|
</StaticRouter>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,8 +13,6 @@ import Sagas from '@sagas';
|
||||||
import Actions from '@actions';
|
import Actions from '@actions';
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
const siteConfig = require('@config/siteConfig');
|
|
||||||
|
|
||||||
const returnSagaWithParams = (saga, params) => {
|
const returnSagaWithParams = (saga, params) => {
|
||||||
return function * () {
|
return function * () {
|
||||||
yield call(saga, params);
|
yield call(saga, params);
|
||||||
|
@ -24,17 +22,12 @@ const returnSagaWithParams = (saga, params) => {
|
||||||
module.exports = (req, res) => {
|
module.exports = (req, res) => {
|
||||||
let context = {};
|
let context = {};
|
||||||
|
|
||||||
// configure the reducers by passing initial state configs
|
|
||||||
const MyReducers = Reducers(siteConfig);
|
|
||||||
const MyApp = App;
|
|
||||||
const MyGAListener = GAListener(siteConfig);
|
|
||||||
|
|
||||||
// create and apply middleware
|
// create and apply middleware
|
||||||
const sagaMiddleware = createSagaMiddleware();
|
const sagaMiddleware = createSagaMiddleware();
|
||||||
const middleware = applyMiddleware(sagaMiddleware);
|
const middleware = applyMiddleware(sagaMiddleware);
|
||||||
|
|
||||||
// create a new Redux store instance
|
// create a new Redux store instance
|
||||||
const store = createStore(MyReducers, middleware);
|
const store = createStore(Reducers, middleware);
|
||||||
|
|
||||||
// create saga
|
// create saga
|
||||||
const action = Actions.onHandleShowPageUri(req.params);
|
const action = Actions.onHandleShowPageUri(req.params);
|
||||||
|
@ -49,9 +42,9 @@ module.exports = (req, res) => {
|
||||||
const html = renderToString(
|
const html = renderToString(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<StaticRouter location={req.url} context={context}>
|
<StaticRouter location={req.url} context={context}>
|
||||||
<MyGAListener>
|
<GAListener>
|
||||||
<MyApp />
|
<App />
|
||||||
</MyGAListener>
|
</GAListener>
|
||||||
</StaticRouter>
|
</StaticRouter>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
|
|
||||||
const { logLevel } = require('@config/loggerConfig');
|
const config = require('@config/loggerConfig');
|
||||||
|
const { logLevel } = config;
|
||||||
|
|
||||||
function configureLogging () {
|
function configureLogging () {
|
||||||
if (!logLevel) {
|
|
||||||
return logger.warn('No logLevel config received.');
|
|
||||||
}
|
|
||||||
logger.info('configuring winston logger...');
|
logger.info('configuring winston logger...');
|
||||||
|
if (!config) {
|
||||||
|
return logger.warn('No logger config found');
|
||||||
|
}
|
||||||
|
if (!logLevel) {
|
||||||
|
logger.warn('No logLevel found in config.');
|
||||||
|
}
|
||||||
// configure the winston logger
|
// configure the winston logger
|
||||||
logger.configure({
|
logger.configure({
|
||||||
transports: [
|
transports: [
|
||||||
new (logger.transports.Console)({
|
new (logger.transports.Console)({
|
||||||
level : this.logLevel,
|
level : logLevel || 'debug',
|
||||||
timestamp : false,
|
timestamp : false,
|
||||||
colorize : true,
|
colorize : true,
|
||||||
prettyPrint : true,
|
prettyPrint : true,
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
|
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
|
|
||||||
const config = require('@config/loggerConfig');
|
const config = require('@config/slackConfig');
|
||||||
|
const {slackWebHook, slackErrorChannel, slackInfoChannel} = config;
|
||||||
|
|
||||||
function configureSlack () {
|
function configureSlack () {
|
||||||
|
logger.info('configuring slack logger...');
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return logger.warn('No slack config found');
|
return logger.warn('No slack config found');
|
||||||
}
|
}
|
||||||
const {slackWebHook, slackErrorChannel, slackInfoChannel} = config;
|
|
||||||
// update variables
|
|
||||||
logger.info('configuring slack logger...');
|
|
||||||
|
|
||||||
// update slack webhook settings
|
// update slack webhook settings
|
||||||
if (!slackWebHook) {
|
if (!slackWebHook) {
|
||||||
return logger.warn('Slack logging is not enabled because no slackWebHook config var provided.');
|
return logger.info('Slack logging is not enabled because no slackWebHook config var provided.');
|
||||||
}
|
}
|
||||||
// add a transport for errors to slack
|
// add a transport for errors to slack
|
||||||
if (slackErrorChannel) {
|
if (slackErrorChannel) {
|
||||||
|
@ -25,6 +23,8 @@ function configureSlack () {
|
||||||
username : 'spee.ch',
|
username : 'spee.ch',
|
||||||
iconEmoji : ':face_with_head_bandage:',
|
iconEmoji : ':face_with_head_bandage:',
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
logger.warn('No slack error channel logging set up');
|
||||||
}
|
}
|
||||||
// add a transport for info in slack
|
// add a transport for info in slack
|
||||||
if (slackInfoChannel) {
|
if (slackInfoChannel) {
|
||||||
|
@ -36,6 +36,8 @@ function configureSlack () {
|
||||||
username : 'spee.ch',
|
username : 'spee.ch',
|
||||||
iconEmoji : ':nerd_face:',
|
iconEmoji : ':nerd_face:',
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
logger.warn('No slack info channel logging set up');
|
||||||
}
|
}
|
||||||
// send test messages
|
// send test messages
|
||||||
logger.info('Slack logging is online.');
|
logger.info('Slack logging is online.');
|
||||||
|
|
Loading…
Reference in a new issue