content: import path from 'path'
  import express from 'express'
  import React from 'react'
  import {renderToString} from 'react-dom/server'
  import {Provider} from 'react-redux'
  import App from './app.js'
  import cookies from 'cookies'
  import {middleware as intlNegotiate} from 'rex-intl'
  import createStore from './store.js'
  import Intl from './intlProvider.js'
  
  const esMessages = require('../intl/es.json')
  
  const server = express()
  server.use(cookies.express())
  server.use(intlNegotiate(['en', 'es']))
  
  server.use('/assets', express.static(path.resolve(__dirname)))
  
  server.use((req, res) => {
    const store = createStore(req.cookies)
  
    let messages = null
    if (req.language == 'es') {
      messages = esMessages
    }
    store.dispatch({type: 'INTL', language: req.language, messages})
  
    const html = renderToString(
      <Provider store={store}>
        <Intl>
          <App />
        </Intl>
      </Provider>
    )
  
    const preloadedState = store.getState()
  
    res.send(`
      <!doctype html>
      <html>
        <head>
          <title>Redux Universal Example</title>
        </head>
        <body>
          <div id="root">${html}</div>
          <script>
            // WARNING: See the following for Security isues with this approach:
            // http://redux.js.org/docs/recipes/ServerRendering.html#security-considerations
            window.PRELOADED_STATE = ${JSON.stringify(preloadedState)}
          </script>
          <script src="/assets/browser.js"></script>
        </body>
      </html>
    `)
  })
  
  server.listen(3000, () => {
    console.log('server listening on port 3000')
  })
  