Rename template maps controller to named maps to be more clear

This commit is contained in:
Raul Ochoa
2015-04-27 15:01:49 +02:00
parent 8c3f9c7ba0
commit 5ee19cc2ed
2 changed files with 16 additions and 17 deletions

View File

@@ -140,8 +140,8 @@ var CartodbWindshaft = function(serverOptions) {
* Routing
******************************************************************************************************************/
var TemplateMapsController = require('./controllers/template_maps'),
templateMapsController = new TemplateMapsController(
var NamedMapsController = require('./controllers/named_maps'),
namedMapsController = new NamedMapsController(
ws,
serverOptions,
templateMaps,
@@ -149,7 +149,7 @@ var CartodbWindshaft = function(serverOptions) {
template_baseurl,
surrogateKeysCache
);
templateMapsController.register(ws);
namedMapsController.register(ws);
var TablesExtentApi = require('./api/tables_extent_api');
var tablesExtentApi = new TablesExtentApi(serverOptions.pgQueryRunner);

View File

@@ -5,8 +5,7 @@ var templateName = require('../template_maps').templateName;
var CdbRequest = require('../models/cdb_request');
var NamedMapsCacheEntry = require('../cache/model/named_maps_entry');
function TemplateMapsController(app, serverOptions, templateMaps, metadataBackend, templateBaseUrl, surrogateKeysCache)
{
function NamedMapsController(app, serverOptions, templateMaps, metadataBackend, templateBaseUrl, surrogateKeysCache) {
this.app = app;
this.serverOptions = serverOptions;
this.templateMaps = templateMaps;
@@ -15,11 +14,11 @@ function TemplateMapsController(app, serverOptions, templateMaps, metadataBacken
this.surrogateKeysCache = surrogateKeysCache;
}
module.exports = TemplateMapsController;
module.exports = NamedMapsController;
var cdbRequest = new CdbRequest();
TemplateMapsController.prototype.register = function(app) {
NamedMapsController.prototype.register = function(app) {
app.get(this.templateBaseUrl + '/:template_id/jsonp', this.jsonp.bind(this));
app.post(this.templateBaseUrl, this.create.bind(this));
app.put(this.templateBaseUrl + '/:template_id', this.update.bind(this));
@@ -31,7 +30,7 @@ TemplateMapsController.prototype.register = function(app) {
};
// Add a template
TemplateMapsController.prototype.create = function(req, res) {
NamedMapsController.prototype.create = function(req, res) {
var self = this;
this.app.doCORS(res);
@@ -58,7 +57,7 @@ TemplateMapsController.prototype.create = function(req, res) {
};
// Update a template
TemplateMapsController.prototype.update = function(req, res) {
NamedMapsController.prototype.update = function(req, res) {
var self = this;
this.app.doCORS(res);
@@ -89,7 +88,7 @@ TemplateMapsController.prototype.update = function(req, res) {
};
// Get a specific template
TemplateMapsController.prototype.retrieve = function(req, res) {
NamedMapsController.prototype.retrieve = function(req, res) {
var self = this;
if (req.profiler) {
@@ -128,7 +127,7 @@ TemplateMapsController.prototype.retrieve = function(req, res) {
};
// Delete a specific template
TemplateMapsController.prototype.destroy = function(req, res) {
NamedMapsController.prototype.destroy = function(req, res) {
var self = this;
if (req.profiler) {
@@ -158,7 +157,7 @@ TemplateMapsController.prototype.destroy = function(req, res) {
};
// Get a list of owned templates
TemplateMapsController.prototype.list = function(req, res) {
NamedMapsController.prototype.list = function(req, res) {
var self = this;
if ( req.profiler ) {
req.profiler.start('windshaft-cartodb.get_template_list');
@@ -185,7 +184,7 @@ TemplateMapsController.prototype.list = function(req, res) {
);
};
TemplateMapsController.prototype.instantiate = function(req, res) {
NamedMapsController.prototype.instantiate = function(req, res) {
var self = this;
if (req.profiler) {
@@ -202,7 +201,7 @@ TemplateMapsController.prototype.instantiate = function(req, res) {
);
};
TemplateMapsController.prototype.options = function(req, res, next) {
NamedMapsController.prototype.options = function(req, res, next) {
this.app.doCORS(res, "Content-Type");
return next();
};
@@ -211,7 +210,7 @@ TemplateMapsController.prototype.options = function(req, res, next) {
* jsonp endpoint, allows to instantiate a template with a json call.
* callback query argument is mandatory
*/
TemplateMapsController.prototype.jsonp = function(req, res) {
NamedMapsController.prototype.jsonp = function(req, res) {
var self = this;
if (req.profiler) {
@@ -239,7 +238,7 @@ TemplateMapsController.prototype.jsonp = function(req, res) {
// Instantiate a template
TemplateMapsController.prototype.instantiateTemplate = function(req, res, template_params, callback) {
NamedMapsController.prototype.instantiateTemplate = function(req, res, template_params, callback) {
var self = this;
this.app.doCORS(res);
@@ -329,7 +328,7 @@ TemplateMapsController.prototype.instantiateTemplate = function(req, res, templa
);
};
TemplateMapsController.prototype.finish_instantiation = function(err, response, res) {
NamedMapsController.prototype.finish_instantiation = function(err, response, res) {
if (err) {
var statusCode = 400;
response = { error: ''+err };