From 595dac57a04b60636aeae6b90c0e234fd1d8d6ee Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 20 Jan 2015 18:14:10 +0100 Subject: [PATCH] Moves setDBParams into controller --- lib/cartodb/cartodb_windshaft.js | 15 --------------- lib/cartodb/controllers/template_maps.js | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 03029c46..300bd3e1 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -205,21 +205,6 @@ var CartodbWindshaft = function(serverOptions) { ); templateMapsController.register(ws); - ws.setDBParams = function(cdbuser, params, callback) { - Step( - function setAuth() { - serverOptions.setDBAuth(cdbuser, params, this); - }, - function setConn(err) { - if ( err ) throw err; - serverOptions.setDBConn(cdbuser, params, this); - }, - function finish(err) { - callback(err); - } - ); - }; - var healthCheck = new HealthCheck(cartoData, Windshaft.tilelive); ws.get('/health', function(req, res) { diff --git a/lib/cartodb/controllers/template_maps.js b/lib/cartodb/controllers/template_maps.js index 391a6c78..485cb5f0 100644 --- a/lib/cartodb/controllers/template_maps.js +++ b/lib/cartodb/controllers/template_maps.js @@ -413,7 +413,7 @@ TemplateMapsController.prototype.instantiateTemplate = function(req, res, templa res: res, profiler: req.profiler }; - self.app.setDBParams(cdbuser, fakereq.params, this); + self.setDBParams(cdbuser, fakereq.params, this); }, function setApiKey(err){ if ( req.profiler ) req.profiler.done('setDBParams'); @@ -477,3 +477,19 @@ TemplateMapsController.prototype.finish_instantiation = function(err, response, this.app.sendResponse(res, [response, 200]); } }; + +TemplateMapsController.prototype.setDBParams = function(cdbuser, params, callback) { + var self = this; + Step( + function setAuth() { + self.serverOptions.setDBAuth(cdbuser, params, this); + }, + function setConn(err) { + if ( err ) throw err; + self.serverOptions.setDBConn(cdbuser, params, this); + }, + function finish(err) { + callback(err); + } + ); +};