Created
July 7, 2014 07:15
-
-
Save yoshuawuyts/95c0c94ad3fb02160b11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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