Skip to content

Commit

Permalink
Merge pull request #120 from Kondeo/seperatedV
Browse files Browse the repository at this point in the history
Allow for separate version control
  • Loading branch information
julianpoy committed Jun 9, 2016
2 parents 52e6ae5 + f0f5ad8 commit 430cb78
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
20 changes: 18 additions & 2 deletions backend/config/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,32 @@
},
"CLIENT": {
"IOS": {
"SUBSCRIBE_PAGE": false,
"SUBSCRIBE_PAGE": true,
"SUBSCRIBE_ONLINE_TEXT": false
},
"ANDROID": {
"SUBSCRIBE_PAGE": false,
"SUBSCRIBE_PAGE": true,
"SUBSCRIBE_ONLINE_TEXT": false
},
"WEB": {
"SUBSCRIBE_PAGE": true,
"SUBSCRIBE_ONLINE_TEXT": false
}
},
"CLIENTVER": {
"0.1.9": {
"IOS": {
"SUBSCRIBE_PAGE": false,
"SUBSCRIBE_ONLINE_TEXT": false
},
"ANDROID": {
"SUBSCRIBE_PAGE": true,
"SUBSCRIBE_ONLINE_TEXT": false
},
"WEB": {
"SUBSCRIBE_PAGE": true,
"SUBSCRIBE_ONLINE_TEXT": false
}
}
}
}
23 changes: 20 additions & 3 deletions backend/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,29 @@ router.get('/prices', function(req, res, next) {
});

router.get('/client', function(req, res, next) {
var status = 200;
//CLIENT OUT OF DATE - Semver client version is less than last compat
if(semver.lt(req.query.version, CONST.VERSION.LAST_COMPATIBLE)){ res.status(426).json(CONST.CLIENT) }
if(semver.lt(req.query.version, CONST.VERSION.LAST_COMPATIBLE)){
status = 426;
}
//CLIENT BEING DEPRICATED SOON - Semver client version is less than or equal to DEPRICATED
else if(semver.lte(req.query.version, CONST.VERSION.DEPRICATED)){ res.status(449).json(CONST.CLIENT) }
else if(semver.lte(req.query.version, CONST.VERSION.DEPRICATED)){
status = 449;
}
//CLIENT VERSION OK
else { res.status(200).json(CONST.CLIENT) }
else {
status = 200;
}
sendClient(req.query.version, status, res);
});

function sendClient(version, status, res){
var custClient = CONST.CLIENTVER[version];
if(custClient){
res.status(status).json(custClient);
} else {
res.status(status).json(CONST.CLIENT);
}
}

module.exports = router;

0 comments on commit 430cb78

Please sign in to comment.