add user stores/actions

construct fetchr on every request
This commit is contained in:
Berkeley Martinez
2015-07-24 17:52:07 -07:00
parent 77a0a82118
commit a1a4ac883d
10 changed files with 131 additions and 34 deletions

View File

@@ -1,11 +1,12 @@
import React from 'react';
import Router from 'react-router';
import Fetchr from 'fetchr';
import Location from 'react-router/lib/Location';
import debugFactory from 'debug';
import { app$ } from '../../common/app';
import { RenderToString } from 'thundercats-react';
const debug = debugFactory('freecc:servereact');
const debug = debugFactory('freecc:react-server');
// add routes here as they slowly get reactified
// remove their individual controllers
@@ -25,6 +26,7 @@ export default function reactSubRouter(app) {
app.use(router);
function serveReactApp(req, res, next) {
const services = new Fetchr({ req });
const location = new Location(req.path, req.query);
// returns a router wrapped app
@@ -42,7 +44,7 @@ export default function reactSubRouter(app) {
// prefetches data and sets up it up for current state
debug('rendering to string');
return RenderToString(
AppCat(),
AppCat(null, services),
React.createElement(Router, initialState)
);
})