diff --git a/src/global_config.js b/src/global_config.js index c7c9266a..b1b8f90e 100644 --- a/src/global_config.js +++ b/src/global_config.js @@ -5,6 +5,19 @@ var Parse = require('parse/node').Parse, var router = new PromiseRouter(); +function getGlobalConfig(req) { + return req.config.database.rawCollection('_GlobalConfig') + .then(coll => coll.findOne({'_id': 1})) + .then(globalConfig => ({response: { params: globalConfig.params }})) + .catch(() => ({ + status: 404, + response: { + code: Parse.Error.INVALID_KEY_NAME, + error: 'config does not exist', + } + })); +} + function updateGlobalConfig(req) { if (!req.auth.isMaster) { return Promise.resolve({ @@ -27,19 +40,6 @@ function updateGlobalConfig(req) { })); } -function getGlobalConfig(req) { - return req.config.database.rawCollection('_GlobalConfig') - .then(coll => coll.findOne({'_id': 1})) - .then(globalConfig => ({response: { params: globalConfig.params }})) - .catch(() => ({ - status: 404, - response: { - code: Parse.Error.INVALID_KEY_NAME, - error: 'config does not exist', - } - })); -} - router.route('GET', '/config', getGlobalConfig); router.route('PUT', '/config', updateGlobalConfig);