var React = require('react')
var ReactDOMServer = require('react-dom/server')
var StaticRouter = require('react-router-dom').StaticRouter
var ServerStyleSheet = require('styled-components').ServerStyleSheet
var fs = require('fs')
var _ = require('lodash')
var baseTemplate = fs.readFileSync('./index.html') // TODO change to async function maybe
var template = _.template(baseTemplate)
var sheet = new ServerStyleSheet()
var something = sheet.collectStyles(App)
var css = sheet.getStyleTags()
var App = require('../src/js/App').default

const isomorphic = (req, res, next) => {
  var context = {}
  var body = ReactDOMServer.renderToString(
    React.createElement(StaticRouter, { location: req.url, context },
      React.createElement(App)
    )
  )

  if (context.url) {
    // TODO if there is a redirect
  }

  res.write(template({body: body}))
  res.end()
}

function isomorphic2() {
  return function(req, res, next) {
    if (req.url !== '/') {
      console.log('hit not root')
      next()
    } else {
      var context = {}
      var body = ReactDOMServer.renderToString(
        React.createElement(StaticRouter, { location: req.url, context },
          React.createElement(App)
        )
      )

      console.log('bitch?');

      if (context.url) {
        // TODO if there is a redirect
      }

      res.write(template({body: body}))
      res.end()
    }
  }
}

module.exports = isomorphic

@@ -862,527 +862,8 @@
 %0A%7D%0A%0A
-function isomorphic2() %7B%0A  return function(req, res, next) %7B%0A    if (req.url !== '/') %7B%0A      console.log('hit not root')%0A      next()%0A    %7D else %7B%0A      var context = %7B%7D%0A      var body = ReactDOMServer.renderToString(%0A        React.createElement(StaticRouter, %7B location: req.url, context %7D,%0A          React.createElement(App)%0A        )%0A      )%0A%0A      console.log('bitch?');%0A%0A      if (context.url) %7B%0A        // TODO if there is a redirect%0A      %7D%0A%0A      res.write(template(%7Bbody: body%7D))%0A      res.end()%0A    %7D%0A  %7D%0A%7D%0A%0A
 modu

remove old iso function