From d4d5272bf262b3804f05109e92df87759c41ecf4 Mon Sep 17 00:00:00 2001 From: Javier Arce Date: Thu, 12 Sep 2013 15:36:50 +0200 Subject: [PATCH] Sets the sqlapi domain. Fixes #82 --- lib/cartodb/server_options.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 14a06cc7..518fab15 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -9,7 +9,9 @@ var _ = require('underscore') ; // This is for backward compatibility with 1.3.3 -if ( ! global.environment.sqlapi.domain ) global.environment.sqlapi.host; +if ( ! global.environment.sqlapi.domain ) { + global.environment.sqlapi.domain = global.environment.sqlapi.host; +} module.exports = function(){ @@ -84,7 +86,7 @@ module.exports = function(){ callback(new Error(msg)); console.log('unexpected response status (' + res.statusCode + ') for sql query: ' + sql + ': ' + msg); return; - } + } callback(null, body.rows); }); }; @@ -162,7 +164,7 @@ module.exports = function(){ if ( me.channelCache.hasOwnProperty(cacheKey) ) { callback(null, me.channelCache[cacheKey]); return; - } + } else if ( req.params.token ) { // cached cache channel for token-based access should be constructed // at cache creation time @@ -233,7 +235,7 @@ module.exports = function(){ me.generateCacheChannel(req, function(err, channel){ if ( ! err ) { res.header('X-Cache-Channel', channel); - cb(null, channel); + cb(null, channel); } else { console.log('ERROR generating cache channel: ' + ( err.message ? err.message : err )); // TODO: evaluate if we should bubble up the error instead @@ -322,7 +324,7 @@ module.exports = function(){ delete req.query.lzma _.extend(req.query, JSON.parse(result)) me.req2params(req, callback); - } catch (err) { + } catch (err) { callback(new Error('Error parsing lzma as JSON: ' + err)); } },