/*
 Rookeries - Server-side renderer

 @copyright (c) Copyright 2013-2017 Dorian Pula
 @license AGPL v3
 @author Dorian Pula [dorian.pula@amber-penguin-software.ca]
 */

import 'babel-polyfill';
import {h} from 'preact';
import {render} from 'preact-render-to-string';
/** @jsx h */

import process from 'process';

import {StaticRouter} from 'react-router-dom';

import {App} from './containers/App';

export function renderReactComponentsToString() {
  const url = process.argv[2];

  const context = {};
  return {
    // TODO: Consider bring back a provider for a singular mobx app store.
    bodyContent: render(h(
      <StaticRouter location={ url } context={ context }>
        <App />
      </StaticRouter>
    ))
  };

}

let bodyResponse = renderReactComponentsToString();
console.log(bodyResponse.bodyContent);
