Add ability to filter beta challenges from production
This PR adds the ability to test out challenges in beta without fear that they will leak to production servers. In development all challenges will display. In production all challenges marked 'isBeta' will be filtered out except in the case the environmental variable `BETA` is set ture, in which case all challenges will display.
This commit is contained in:
@@ -16,6 +16,8 @@ import {
|
||||
ifNoUserSend
|
||||
} from '../utils/middleware';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
const isBeta = !!process.env.BETA;
|
||||
const debug = debugFactory('freecc:challenges');
|
||||
const challengesRegex = /^(bonfire|waypoint|zipline|basejump)/i;
|
||||
const firstChallenge = 'waypoint-say-hello-to-html-elements';
|
||||
@@ -105,6 +107,9 @@ module.exports = function(app) {
|
||||
null,
|
||||
Scheduler.default
|
||||
))
|
||||
// filter out all challenges that have isBeta flag set
|
||||
// except in development or beta site
|
||||
.filter(challenge => isDev || isBeta || !challenge.isBeta)
|
||||
.shareReplay();
|
||||
|
||||
// create a stream of challenge blocks
|
||||
@@ -543,8 +548,10 @@ module.exports = function(app) {
|
||||
}
|
||||
return sum;
|
||||
}, 0);
|
||||
const isBeta = _.every(blockArray, 'isBeta');
|
||||
|
||||
return {
|
||||
isBeta,
|
||||
name: blockArray[0].block,
|
||||
dashedName: dasherize(blockArray[0].block),
|
||||
challenges: blockArray,
|
||||
|
Reference in New Issue
Block a user