<commit_before>/* @flow */
import path from 'path';

import express from 'express';
import React from 'react';
import ReactDOM from 'react-dom/server';
import { createServerDispatcher } from 'isomorphic-dispatcher';

import { storeA, storeB, storeC } from './stores';
import App from './app';

/*------------------------------------------------------------------------------------------------*/
//	--- Create server ---
/*------------------------------------------------------------------------------------------------*/
let app = express();
app.use('/', (req, res, next) => {
	if(req.url !== '/') {
		next();
		return;
	}

	const dispatcher = createServerDispatcher({ storeA, storeB, storeC }, () => req);
	const appMarkup = ReactDOM.renderToString(
		<App dispatcher={dispatcher} />
	);
	const pageMarkup = ReactDOM.renderToStaticMarkup(
		<html>
			<head>
				<title>Example - react-isomorphic-dispatcher</title>
			</head>
			<body>
				<div id="react-element" dangerouslySetInnerHTML={{__html: appMarkup}} />
				<script src="/app.js" />
			</body>
		</html>
	);
	res.send(pageMarkup);
});
app.use('/app.js', express.static(path.join(__dirname, '../app.js')));
app.use('/dispatch', (req, res, next) => {
	//TODO, add isomporphic-dispatcher communication
	const dispatcher = createServerDispatcher({ storeA, storeB, storeC }, () => req);

	next(new Error('NYI'));
});
app.use((err, req, res, next) => {
	console.error(err.stack);
	res.status(500).send(err.message);
});

/*------------------------------------------------------------------------------------------------*/
//	--- Start server ---
/*------------------------------------------------------------------------------------------------*/
app.listen(80);
console.log('listening on port', 80);<commit_msg>Minor Update to Example<commit_after>/* @flow */
import path from 'path';

import express from 'express';
import React from 'react';
import ReactDOM from 'react-dom/server';
import { createServerDispatcher } from 'isomorphic-dispatcher';

import { storeA, storeB, storeC } from './stores';
import App from './app';

/*------------------------------------------------------------------------------------------------*/
//	--- Create dispatcher ---
/*------------------------------------------------------------------------------------------------*/
const dispatcher = createServerDispatcher({ storeA, storeB, storeC });

/*------------------------------------------------------------------------------------------------*/
//	--- Create server ---
/*------------------------------------------------------------------------------------------------*/
let app = express();
app.use('/', (req, res, next) => {
	if(req.url !== '/') {
		next();
		return;
	}


	const appMarkup = ReactDOM.renderToString(
		<App dispatcher={dispatcher.cloneWithOnServerArg(req)} />
	);

	const pageMarkup = ReactDOM.renderToStaticMarkup(
		<html>
			<head>
				<title>Example - react-isomorphic-dispatcher</title>
			</head>
			<body>
				<div id="react-element" dangerouslySetInnerHTML={{__html: appMarkup}} />
				<script src="/app.js" />
			</body>
		</html>
	);
	res.send(pageMarkup);
});
app.use('/app.js', express.static(path.join(__dirname, '../app.js')));
app.use('/dispatch', (req, res, next) => {
	//TODO, add isomporphic-dispatcher communication
	const currDispatcher = dispatcher.cloneWithOnServerArg(req);

	next(new Error('NYI'));
});
app.use((err, req, res, next) => {
	console.error(err.stack);
	res.status(500).send(err.message);
});

/*------------------------------------------------------------------------------------------------*/
//	--- Start server ---
/*------------------------------------------------------------------------------------------------*/
app.listen(80);
console.log('listening on port', 80);
{'fraction_non_alphanumeric': 0.4075351552135845, 'fraction_numerical': 0.0037145131334571503, 'mean_word_length': 1.4560260586319218, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3179370', 'n_tokens_mistral': 1037, 'n_tokens_neox': 973, 'n_words': 213}