Add chainquery dependencies for Spee.ch, does not include migrations #593

Merged
skhameneh merged 15 commits from add-chainquery into master 2018-10-10 02:12:18 +02:00
5 changed files with 60 additions and 67 deletions
Showing only changes of commit ec2aea5972 - Show all commits

1
.gitignore vendored
View file

@ -5,7 +5,6 @@
node_modules
client/build
server/chainquery/build
client_custom/build
client_custom/scss

View file

@ -22,6 +22,7 @@ function * parseAndUpdateIdentifierAndClaim (modifier, claim) {
};
yield call(newAssetRequest, onNewAssetRequest(claimName, claimId, null, null, extension));
}
function * parseAndUpdateClaimOnly (claim) {
// this could be a request for an asset or a channel page
// claim could be an asset claim or a channel claim
@ -50,8 +51,9 @@ export function * handleShowPageUri (action) {
const { identifier, claim } = action.data;
if (identifier) {
return yield call(parseAndUpdateIdentifierAndClaim, identifier, claim);
} else if (claim) {
yield call(parseAndUpdateClaimOnly, claim);
}
yield call(parseAndUpdateClaimOnly, claim);
};
export function * watchHandleShowPageUri () {

View file

@ -1,7 +1,7 @@
const handlePageRender = require('../../render/build/handlePageRender.js');
const handleShowRender = require('../../render/build/handleShowRender.js');
const sendReactApp = (req, res) => {
handlePageRender(req, res);
handleShowRender(req, res);
};
module.exports = sendReactApp;

View file

@ -10,6 +10,12 @@ var _reactRedux = require("react-redux");
var _reactRouterDom = require("react-router-dom");
var _renderFullPage = _interopRequireDefault(require("../renderFullPage"));
var _reduxSaga = _interopRequireDefault(require("redux-saga"));
var _effects = require("redux-saga/effects");
var _reactHelmet = _interopRequireDefault(require("react-helmet"));
var _reducers = _interopRequireDefault(require("@reducers"));
@ -18,33 +24,65 @@ var _GAListener = _interopRequireDefault(require("@components/GAListener"));
var _app = _interopRequireDefault(require("@app"));
var _renderFullPage = _interopRequireDefault(require("../renderFullPage.js"));
var _sagas = _interopRequireDefault(require("@sagas"));
var _actions = _interopRequireDefault(require("@actions"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var returnSagaWithParams = function returnSagaWithParams(saga, params) {
return (
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return (0, _effects.call)(saga, params);
case 2:
case "end":
return _context.stop();
}
}
}, _callee, this);
})
);
};
module.exports = function (req, res) {
var context = {}; // create a new Redux store instance
var context = {}; // create and apply middleware
var store = (0, _redux.createStore)(_reducers.default); // render component to a string
var sagaMiddleware = (0, _reduxSaga.default)();
var middleware = (0, _redux.applyMiddleware)(sagaMiddleware); // create a new Redux store instance
var html = (0, _server.renderToString)(_react.default.createElement(_reactRedux.Provider, {
store: store
}, _react.default.createElement(_reactRouterDom.StaticRouter, {
location: req.url,
context: context
}, _react.default.createElement(_GAListener.default, null, _react.default.createElement(_app.default, null))))); // get head tags from helmet
var store = (0, _redux.createStore)(_reducers.default, middleware); // create an action to handle the given url,
// and create a the saga needed to handle that action
var helmet = _reactHelmet.default.renderStatic(); // check for a redirect
var action = _actions.default.onHandleShowPageUri(req.params);
var saga = returnSagaWithParams(_sagas.default.handleShowPageUri, action); // run the saga middleware with the saga call
sagaMiddleware.run(saga).done.then(function () {
// render component to a string
var html = (0, _server.renderToString)(_react.default.createElement(_reactRedux.Provider, {
store: store
}, _react.default.createElement(_reactRouterDom.StaticRouter, {
location: req.url,
context: context
}, _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
if (context.url) {
// Somewhere a `<Redirect>` was rendered
return res.redirect(301, context.url);
} else {} // we're good, send the response
// get the initial state from our Redux store
if (context.url) {
return res.redirect(301, context.url);
} // get the initial state from our Redux store
var preloadedState = store.getState(); // send the rendered page back to the client
var preloadedState = store.getState(); // send the rendered page back to the client
res.send((0, _renderFullPage.default)(helmet, html, preloadedState));
res.send((0, _renderFullPage.default)(helmet, html, preloadedState));
});
};

View file

@ -1,46 +0,0 @@
import React from 'react';
import { renderToString } from 'react-dom/server';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import { StaticRouter } from 'react-router-dom';
import Helmet from 'react-helmet';
import Reducers from '@reducers';
import GAListener from '@components/GAListener';
import App from '@app';
import renderFullPage from '../renderFullPage.js';
module.exports = (req, res) => {
let context = {};
// create a new Redux store instance
const store = createStore(Reducers);
// render component to a string
const html = renderToString(
<Provider store={store}>
<StaticRouter location={req.url} context={context}>
<GAListener>
<App />
</GAListener>
</StaticRouter>
</Provider>
);
// get head tags from helmet
const helmet = Helmet.renderStatic();
// check for a redirect
if (context.url) {
// Somewhere a `<Redirect>` was rendered
return res.redirect(301, context.url);
} else {
// we're good, send the response
}
// get the initial state from our Redux store
const preloadedState = store.getState();
// send the rendered page back to the client
res.send(renderFullPage(helmet, html, preloadedState));
};