Use const and let instead of var
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
var crypto = require('crypto');
|
||||
var dot = require('dot');
|
||||
var MapConfig = require('windshaft').model.MapConfig;
|
||||
var templateName = require('../../../backends/template_maps').templateName;
|
||||
var QueryTables = require('cartodb-query-tables');
|
||||
const crypto = require('crypto');
|
||||
const dot = require('dot');
|
||||
const MapConfig = require('windshaft').model.MapConfig;
|
||||
const templateName = require('../../../backends/template_maps').templateName;
|
||||
const QueryTables = require('cartodb-query-tables');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -61,7 +61,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function (callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var templateParams = {};
|
||||
let templateParams = {};
|
||||
|
||||
if (this.config) {
|
||||
try {
|
||||
@@ -123,7 +123,7 @@ NamedMapMapConfigProvider.prototype.getContext = function (callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var context = {};
|
||||
const context = {};
|
||||
|
||||
context.analysisConfiguration = {
|
||||
user: this.owner,
|
||||
@@ -168,36 +168,33 @@ NamedMapMapConfigProvider.prototype.getTemplate = function(callback) {
|
||||
}
|
||||
|
||||
if (!tpl) {
|
||||
var notFoundErr = new Error(
|
||||
"Template '" + this.templateName + "' of user '" + this.owner + "' not found"
|
||||
);
|
||||
notFoundErr.http_status = 404;
|
||||
const error = new Error(`Template '${this.templateName}' of user '${this.owner}' not found`);
|
||||
error.http_status = 404;
|
||||
|
||||
this.err = notFoundErr;
|
||||
this.err = error;
|
||||
|
||||
return callback(notFoundErr);
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
var authorized = false;
|
||||
let authorized = false;
|
||||
|
||||
try {
|
||||
authorized = this.templateMaps.isAuthorized(tpl, this.authToken);
|
||||
} catch (err) {
|
||||
// we catch to add http_status
|
||||
var authorizationFailedErr = new Error('Failed to authorize template');
|
||||
authorizationFailedErr.http_status = 403;
|
||||
const error = new Error('Failed to authorize template');
|
||||
error.http_status = 403;
|
||||
|
||||
this.err = authorizationFailedErr;
|
||||
this.err = error;
|
||||
|
||||
return callback(authorizationFailedErr);
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
if (!authorized) {
|
||||
var unauthorizedErr = new Error('Unauthorized template instantiation');
|
||||
unauthorizedErr.http_status = 403;
|
||||
this.err = unauthorizedErr;
|
||||
const error = new Error('Unauthorized template instantiation');
|
||||
error.http_status = 403;
|
||||
this.err = error;
|
||||
|
||||
return callback(unauthorizedErr);
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
this.template = tpl;
|
||||
@@ -226,19 +223,19 @@ NamedMapMapConfigProvider.prototype.reset = function() {
|
||||
};
|
||||
|
||||
NamedMapMapConfigProvider.prototype.filter = function(key) {
|
||||
var regex = new RegExp('^' + this.createKey(true) + '.*');
|
||||
const regex = new RegExp('^' + this.createKey(true) + '.*');
|
||||
return key && key.match(regex);
|
||||
};
|
||||
|
||||
// Configure bases for cache keys suitable for string interpolation
|
||||
var baseKey = '{{=it.dbname}}:{{=it.owner}}:{{=it.templateName}}';
|
||||
var rendererKey = baseKey + ':{{=it.authToken}}:{{=it.configHash}}:{{=it.format}}:{{=it.layer}}:{{=it.scale_factor}}';
|
||||
const baseKey = '{{=it.dbname}}:{{=it.owner}}:{{=it.templateName}}';
|
||||
const rendererKey = baseKey + ':{{=it.authToken}}:{{=it.configHash}}:{{=it.format}}:{{=it.layer}}:{{=it.scale_factor}}';
|
||||
|
||||
var baseKeyTpl = dot.template(baseKey);
|
||||
var rendererKeyTpl = dot.template(rendererKey);
|
||||
const baseKeyTpl = dot.template(baseKey);
|
||||
const rendererKeyTpl = dot.template(rendererKey);
|
||||
|
||||
NamedMapMapConfigProvider.prototype.createKey = function(base) {
|
||||
var tplValues = Object.assign({
|
||||
const tplValues = Object.assign({
|
||||
dbname: '',
|
||||
owner: this.owner,
|
||||
templateName: this.templateName,
|
||||
|
||||
Reference in New Issue
Block a user