Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit

Permalink
Add support for updating own config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
DaneEveritt committed Dec 15, 2014
1 parent b962478 commit 945a7e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules/*
npm-debug.log

config.json

config.json.bkup
18 changes: 18 additions & 0 deletions interfaces/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ restserver.get('/gameservers/', function info(req, res, next){
res.send(response);
});

restserver.get('/gameservers/config', function info(req, res, next){
if (!restauth(req, -1, "g:config")){res = unauthorized(res); return next();}
res.send(config);
});

restserver.put('/gameservers/config', function info(req, res, next){
if (!restauth(req, -1, "g:config")){res = unauthorized(res); return next();}
if(req.params['cfg']) {

try {
saveconfig(JSON.parse(req.params['cfg']));
} catch(ex){
log.error("Error encountered when trying to update config.json", ex);
}

}
});

restserver.post('/gameservers/', function info(req, res, next){
if (!restauth(req, -1, "g:new")){res = unauthorized(res); return next();}
id = config.servers.push(JSON.parse(req.params['settings']));
Expand Down

0 comments on commit 945a7e5

Please sign in to comment.