Skip to content

Commit

Permalink
UI_HOST support
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed May 28, 2016
1 parent 0e1451f commit 436f533
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dotenv.load();
var defaults = {
"STEAM_API_KEY": "", //for API reqs, in worker
"STEAM_USER": "", //for getting replay salt/profile data, in retriever
"STEAM_PASS": "", //make sure to wrap in double quotes if it contains special characters
"STEAM_PASS": "", //make sure to wrap in double quotes in .env if it contains special characters
"RECAPTCHA_PUBLIC_KEY": "", //for preventing automated requests, in web
"RECAPTCHA_SECRET_KEY": "",
"STRIPE_SECRET": "", //for donations, in web
Expand Down Expand Up @@ -48,14 +48,14 @@ var defaults = {
"MATCH_RATING_RETENTION_HOURS": 12, //hours in block to retain match rating data for percentile
"ABILITY_UPGRADE_RETENTION_HOURS": 12, //hours to retain match ability upgrade data
"PROVIDER": "", //The cloud provider used by the application (determines how environment data is downloaded)
"UI_HOST": "", //The host of the UI, redirect traffic from / and /return here
"ENABLE_RECAPTCHA": "", //set to enable the recaptcha on the Request page
"ENABLE_ADS": "", //set to turn on ads
"ENABLE_PRO_PARSING": "", // set to parse pro matches from sequential API
"ENABLE_MATCH_CACHE": "", // set to enable caching matches (Redis)
"ENABLE_PLAYER_CACHE": "", // set to enable caching players (Cassandra)
"ENABLE_INSERT_ALL_MATCHES": "", //set to enable inserting all matches
"ENABLE_RANDOM_MMR_UPDATE": "", //set to randomly update MMRs in ranked matches
"ENABLE_SPA_MODE": "", //set to enable single page application mode for web (all routes serve the SPA page by default)
"ENABLE_POSTGRES_MATCH_STORE_WRITE": "1", //set to enable writing match data to postgres (default on)
"ENABLE_CASSANDRA_MATCH_STORE_READ": "", //set to enable reading match data from cassandra
"ENABLE_CASSANDRA_MATCH_STORE_WRITE": "", //set to enable writing match data to cassandra
Expand Down
35 changes: 18 additions & 17 deletions svc/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ app.use(function telemetry(req, res, cb)
});
cb();
});
//TODO can remove this middleware with SPA
app.use(function getMetadata(req, res, cb)
{
async.parallel(
Expand Down Expand Up @@ -197,7 +198,14 @@ app.route('/return').get(passport.authenticate('steam',
failureRedirect: '/'
}), function(req, res, next)
{
res.redirect('/players/' + req.user.account_id);
if (config.UI_HOST)
{
return res.redirect(config.UI_HOST + '/players/' + req.user.account_id);
}
else
{
res.redirect('/players/' + req.user.account_id);
}
});
app.route('/logout').get(function(req, res)
{
Expand All @@ -206,24 +214,16 @@ app.route('/logout').get(function(req, res)
res.redirect('/');
});
app.use('/api', api(db, redis, cassandra));
app.use(function(req, res, cb)
{
if (config.ENABLE_SPA_MODE)
{
res.sendFile('index.html',
{
root: path.join(__dirname, '../public/build')
});
}
else
{
return cb();
}
});
//END service/admin routes
//START standard routes. Don't need these in SPA
//START standard routes.
//TODO remove these with SPA
app.route('/').get(function(req, res, next)
{
if (config.UI_HOST)
{
return res.redirect(config.UI_HOST);
}
//TODO remove this with SPA
if (req.user)
{
res.redirect('/players/' + req.user.account_id);
Expand Down Expand Up @@ -397,9 +397,10 @@ app.get('/april/:year?', function(req, res, cb)
});
});
app.use('/april/2016/hyperopia', hyperopia(db));
app.use('/', donate(db, redis));
app.use('/', mmstats(redis));
//END standard routes
//TODO keep donate routes around for legacy until @albertcui can reimplement in SPA?
app.use('/', donate(db, redis));
app.use(function(req, res, next)
{
var err = new Error("Not Found");
Expand Down

0 comments on commit 436f533

Please sign in to comment.