Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Created July 7, 2014 07:15
Show Gist options
  • Save yoshuawuyts/95c0c94ad3fb02160b11 to your computer and use it in GitHub Desktop.
Save yoshuawuyts/95c0c94ad3fb02160b11 to your computer and use it in GitHub Desktop.
/* global window*/
/**
* Module dependencies
*/
var react = require('react');
var index = require('./index');
/**
* Variables
*/
var ENV = process.env.NODE_ENV;
var PORT = process.env.port || 1337;
var HOST = process.env.NODE_ENV == 'production' ? 'versity.co'
: 'versity.dev:' + PORT;
/**
* Render component on the client.
*
* This is the entry point for the build task (gulp), once all dependencies are
* loaded on the client `renderComponent()` gets triggered and makes all
* elements dynamic.
*/
module.exports = react.renderComponent(
index({
path: window.location.pathname,
host: HOST,
env: ENV
}),
window.document
);
/**
* Module dependencies
*/
var router = require('koa-router');
var react = require('react');
var koa = require('koa');
var index = require('../../client/modules/index/index');
/**
* Variables
*/
var ENV = process.env.NODE_ENV;
var PORT = process.env.port || 1337;
var host = process.env.NODE_ENV == 'production'
? 'versity.co'
: 'versity.dev:' + PORT;
/**
* Initialize 'app'.
*/
var app = koa();
app.use(router(app));
/**
* Export 'app'.
*/
module.exports = app;
/**
* because fuck the favicon, that's why.
*/
app.get('/favicon.ico', function* (next){})
/**
* Render
*/
app.get('*', function* (next) {
this.body = react.renderComponentToString(index({
path: this.path,
host: host,
env: ENV
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment