expose new client at /new-app, can be enabled in prod setting a flag

This commit is contained in:
Matteo Pagliazzi
2016-09-21 13:43:39 +02:00
parent 2f626c7875
commit f751ccacc5
8 changed files with 29 additions and 12 deletions

View File

@@ -1,11 +1,14 @@
import locals from '../../middlewares/locals';
import _ from 'lodash';
import md from 'habitica-markdown';
import nconf from 'nconf';
let api = {};
const IS_PROD = nconf.get('IS_PROD');
const TOTAL_USER_COUNT = '1,500,000';
const LOADING_SCREEN_TIPS = 32;
const IS_NEW_CLIENT_ENABLED = nconf.get('NEW_CLIENT_ENABLED') === 'true';
api.getFrontPage = {
method: 'GET',
@@ -82,5 +85,19 @@ api.redirectExtensionsPage = {
},
};
// All requests to /new_app (expect /new_app/static) should serve the new client in development
if (IS_PROD && IS_NEW_CLIENT_ENABLED) {
api.getNewClient = {
method: 'GET',
url: /^\/new-app($|\/(?!(static\/.?|static$)))/,
async handler (req, res) {
if (!(req.session && req.session.userId)) {
return res.redirect('/static/front');
}
return res.sendFile('./dist-client/index.html', {root: `${__dirname}/../../../../`});
},
};
}
module.exports = api;