From 19777699c9b77392736f80b2b0d2331139cbdf61 Mon Sep 17 00:00:00 2001 From: Peter Theill Date: Thu, 11 Feb 2016 01:07:49 +0100 Subject: [PATCH] Rearrange methods to follow route setup --- src/global_config.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) 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);