Use strict mode in modules under lib folder (except lib/cartodb/models/resource-locator.js)

This commit is contained in:
Daniel García Aubert 2018-10-23 17:45:42 +02:00
parent 4775c73aee
commit e7e3d612a1
121 changed files with 250 additions and 11 deletions

View File

@ -1,3 +1,5 @@
'use strict';
const { Router: router } = require('express');
const RedisPool = require('redis-mpool');

View File

@ -1,3 +1,5 @@
'use strict';
const PSQL = require('cartodb-psql');
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials');

View File

@ -1,3 +1,5 @@
'use strict';
const layergroupToken = require('../middlewares/layergroup-token');
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials');

View File

@ -1,3 +1,5 @@
'use strict';
const windshaft = require('windshaft');
const MapConfig = windshaft.model.MapConfig;
const Datasource = windshaft.model.Datasource;
@ -152,17 +154,17 @@ function prepareAdapterMapConfig (mapConfigAdapter) {
}
};
mapConfigAdapter.getMapConfig(user,
requestMapConfig,
params,
context,
mapConfigAdapter.getMapConfig(user,
requestMapConfig,
params,
context,
(err, requestMapConfig, stats = { overviewsAddedToMapconfig : false }) => {
req.profiler.done('anonymous.getMapConfig');
stats.mapType = 'anonymous';
req.profiler.add(stats);
if (err) {
return next(err);
}

View File

@ -1,3 +1,5 @@
'use strict';
const layergroupToken = require('../middlewares/layergroup-token');
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials');

View File

@ -1,3 +1,5 @@
'use strict';
const layergroupToken = require('../middlewares/layergroup-token');
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials');

View File

@ -1,3 +1,5 @@
'use strict';
const { Router: router } = require('express');
const AnalysisLayergroupController = require('./analysis-layergroup-controller');

View File

@ -1,3 +1,5 @@
'use strict';
const layergroupToken = require('../middlewares/layergroup-token');
const coordinates = require('../middlewares/coordinates');
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');

View File

@ -1,3 +1,5 @@
'use strict';
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials');
const dbConnSetup = require('../middlewares/db-conn-setup');

View File

@ -1,3 +1,5 @@
'use strict';
const layergroupToken = require('../middlewares/layergroup-token');
const coordinates = require('../middlewares/coordinates');
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');

View File

@ -1,3 +1,5 @@
'use strict';
const _ = require('underscore');
module.exports = function augmentLayergroupData () {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function authorize (authBackend) {
return function authorizeMiddleware (req, res, next) {
authBackend.authorize(req, res, (err, authorized) => {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function setCacheChannelHeader () {
return function setCacheChannelHeaderMiddleware (req, res, next) {
if (req.method !== 'GET') {

View File

@ -1,3 +1,5 @@
'use strict';
const ONE_YEAR_IN_SECONDS = 60 * 60 * 24 * 365;
module.exports = function setCacheControlHeader ({ ttl = ONE_YEAR_IN_SECONDS, revalidate = false } = {}) {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function checkJsonContentType () {
return function checkJsonContentTypeMiddleware(req, res, next) {
if (req.method === 'POST' && !req.is('application/json')) {

View File

@ -1,3 +1,5 @@
'use strict';
const VALID_IMAGE_FORMATS = ['png', 'jpg'];
module.exports = function checkStaticImageFormat () {

View File

@ -1,3 +1,5 @@
'use strict';
const _ = require('underscore');
// Whitelist query parameters and attach format

View File

@ -1,3 +1,5 @@
'use strict';
const positiveIntegerNumberRegExp = /^\d+$/;
const integerNumberRegExp = /^-?\d+$/;
const invalidZoomMessage = function (zoom) {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function cors () {
return function corsMiddleware (req, res, next) {
const headers = [

View File

@ -1,3 +1,5 @@
'use strict';
const basicAuth = require('basic-auth');
module.exports = function credentials () {

View File

@ -1,3 +1,5 @@
'use strict';
const _ = require('underscore');
module.exports = function dbConnSetup (pgConnection) {

View File

@ -1,3 +1,5 @@
'use strict';
const _ = require('underscore');
const debug = require('debug')('windshaft:cartodb:error-middleware');

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function incrementMapViewCount (metadataBackend) {
return function incrementMapViewCountMiddleware(req, res, next) {
const { mapConfig, user } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function initProfiler (isTemplateInstantiation) {
const operation = isTemplateInstantiation ? 'instance_template' : 'createmap';

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function initializeStatusCode () {
return function initializeStatusCodeMiddleware (req, res, next) {
if (req.method !== 'OPTIONS') {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function setLastModifiedHeader () {
return function setLastModifiedHeaderMiddleware(req, res, next) {
if (req.method !== 'GET') {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function setLastUpdatedTimeToLayergroup () {
return function setLastUpdatedTimeToLayergroupMiddleware (req, res, next) {
const { mapConfigProvider, analysesResults } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function setLayerStats (pgConnection, statsBackend) {
return function setLayerStatsMiddleware(req, res, next) {
const { user, mapConfig } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function setLayergroupIdHeader (templateMaps, useTemplateHash) {
return function setLayergroupIdHeaderMiddleware (req, res, next) {
const { user, template } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function setMetadataToLayergroup (layergroupMetadata, includeQuery) {
return function setMetadataToLayergroupMiddleware (req, res, next) {
const { user, mapConfig, analysesResults = [], context, api_key: userApiKey } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
const LayergroupToken = require('../../models/layergroup-token');
const authErrorMessageTemplate = function (signer, user) {
return `Cannot use map signature of user "${signer}" on db of user "${user}"`;

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function logger (options) {
if (!global.log4js || !options.log_format) {
return function dummyLoggerMiddleware (req, res, next) {

View File

@ -1,3 +1,5 @@
'use strict';
const LZMA = require('lzma').LZMA;
module.exports = function lzma () {

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function mapError (options) {
const { addContext = false, label = 'MAPS CONTROLLER' } = options;

View File

@ -1,3 +1,5 @@
'use strict';
const MapStoreMapConfigProvider = require('../../models/mapconfig/provider/map-store-provider');
module.exports = function createMapStoreMapConfigProvider (

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function getNamedMapProvider ({ namedMapProviderCache, label, forcedFormat = null }) {
return function getNamedMapProviderMiddleware (req, res, next) {
const { user, token, cache_buster, api_key } = res.locals;

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function noop () {
return function noopMiddleware (req, res, next) {
next();

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function sendResponse () {
return function sendResponseMiddleware (req, res) {
req.profiler.done('res');

View File

@ -1,3 +1,5 @@
'use strict';
const os = require('os');
module.exports = function servedByHostHeader () {

View File

@ -1,3 +1,5 @@
'use strict';
const Profiler = require('../../stats/profiler_proxy');
const debug = require('debug')('windshaft:cartodb:stats');
const onHeaders = require('on-headers');

View File

@ -1,3 +1,5 @@
'use strict';
const NamedMapsCacheEntry = require('../../cache/model/named_maps_entry');
const NamedMapMapConfigProvider = require('../../models/mapconfig/provider/named-map-provider');

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function syntaxError () {
return function syntaxErrorMiddleware (err, req, res, next) {
if (err.name === 'SyntaxError') {

View File

@ -1,3 +1,5 @@
'use strict';
const CdbRequest = require('../../models/cdb_request');
module.exports = function user () {

View File

@ -1,3 +1,5 @@
'use strict';
const fs = require('fs');
const timeoutErrorVectorTile = fs.readFileSync(__dirname + '/../../../../assets/render-timeout-fallback.mvt');

View File

@ -1,3 +1,5 @@
'use strict';
const { templateName } = require('../../backends/template_maps');
const credentials = require('../middlewares/credentials');
const rateLimit = require('../middlewares/rate-limit');

View File

@ -1,3 +1,5 @@
'use strict';
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials');
const dbConnSetup = require('../middlewares/db-conn-setup');

View File

@ -1,3 +1,5 @@
'use strict';
const { Router: router } = require('express');
const NamedMapController = require('./named-template-controller');

View File

@ -1,3 +1,5 @@
'use strict';
const coordinates = require('../middlewares/coordinates');
const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials');

View File

@ -1,3 +1,5 @@
'use strict';
var PSQL = require('cartodb-psql');
function AnalysisStatusBackend() {

View File

@ -1,3 +1,5 @@
'use strict';
/**
*
* @param {PgConnection} pgConnection

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var PSQL = require('cartodb-psql');
var BBoxFilter = require('../models/filter/bbox');

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var AnalysisFilter = require('../models/filter/analysis');

View File

@ -1,3 +1,5 @@
'use strict';
function EmptyLayerStats(types) {
this._types = types || {};
}

View File

@ -1,3 +1,5 @@
'use strict';
var LayerStats = require('./layer-stats');
var EmptyLayerStats = require('./empty-layer-stats');
var MapnikLayerStats = require('./mapnik-layer-stats');

View File

@ -1,3 +1,5 @@
'use strict';
var queue = require('queue-async');
function LayerStats(layerStatsIterator) {

View File

@ -1,3 +1,5 @@
'use strict';
const queryUtils = require('../../utils/query-utils');
const AggregationMapConfig = require('../../models/aggregation/aggregation-mapconfig');
const aggregationQuery = require('../../models/aggregation/aggregation-query');

View File

@ -1,3 +1,5 @@
'use strict';
function TorqueLayerStats() {
this._types = {
torque: true

View File

@ -1,3 +1,5 @@
'use strict';
const queryUtils = require('../utils/query-utils');
function OverviewsMetadataBackend(pgQueryRunner) {

View File

@ -1,3 +1,5 @@
'use strict';
var PSQL = require('cartodb-psql');
var _ = require('underscore');
const debug = require('debug')('cachechan');

View File

@ -1,3 +1,5 @@
'use strict';
var PSQL = require('cartodb-psql');
function PgQueryRunner(pgConnection) {

View File

@ -1,3 +1,5 @@
'use strict';
var layerStats = require('./layer-stats/factory');
function StatsBackend() {

View File

@ -1,3 +1,5 @@
'use strict';
function TablesExtentBackend(pgQueryRunner) {
this.pgQueryRunner = pgQueryRunner;
}

View File

@ -1,3 +1,5 @@
'use strict';
var crypto = require('crypto');
var debug = require('debug')('windshaft:templates');
var _ = require('underscore');

View File

@ -1,3 +1,5 @@
'use strict';
/**
*
* @param metadataBackend

View File

@ -1,3 +1,5 @@
'use strict';
var FastlyPurge = require('fastly-purge');
function FastlyCacheBackend(apiKey, serviceId) {

View File

@ -1,3 +1,5 @@
'use strict';
var request = require('request');
function VarnishHttpCacheBackend(host, port) {

View File

@ -1,3 +1,5 @@
'use strict';
var LruCache = require('lru-cache');
function LayergroupAffectedTables() {

View File

@ -1,3 +1,5 @@
'use strict';
var crypto = require('crypto');
function NamedMaps(owner, name) {

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var dot = require('dot');
var NamedMapMapConfigProvider = require('../models/mapconfig/provider/named-map-provider');

View File

@ -1,3 +1,5 @@
'use strict';
var queue = require('queue-async');
/**

View File

@ -1,3 +1,5 @@
'use strict';
const MapConfig = require('windshaft').model.MapConfig;
const aggregationQuery = require('./aggregation-query');
const aggregationValidator = require('./aggregation-validator');

View File

@ -1,3 +1,5 @@
'use strict';
const timeDimension = require('./time-dimension');
const DEFAULT_PLACEMENT = 'point-sample';

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = function aggregationValidator (mapconfig) {
return function validateProperty (key, validator) {
for (let index = 0; index < mapconfig.getLayers().length; index++) {

View File

@ -1,3 +1,5 @@
'use strict';
// timezones can be defined either by an numeric offset in seconds or by
// a valid (case-insensitive) tz/PG name;
// they include abbreviations defined by PG (which have precedence and

View File

@ -1,3 +1,5 @@
'use strict';
function CdbRequest() {
this.RE_USER_FROM_HOST = new RegExp(global.environment.user_from_host ||
'^([^\\.]+)\\.' // would extract "strk" from "strk.cartodb.com"

View File

@ -1,3 +1,5 @@
'use strict';
const BaseDataview = require('./base');
const debug = require('debug')('windshaft:dataview:aggregation');

View File

@ -1,3 +1,5 @@
'use strict';
const FLOAT_OIDS = {
700: true,
701: true,

View File

@ -1,3 +1,5 @@
'use strict';
const dataviews = require('./');
module.exports = class DataviewFactory {

View File

@ -1,3 +1,5 @@
'use strict';
const BaseDataview = require('./base');
const debug = require('debug')('windshaft:dataview:formula');
const utils = require('../../utils/query-utils');

View File

@ -1,3 +1,5 @@
'use strict';
const debug = require('debug')('windshaft:dataview:histogram');
const NumericHistogram = require('./histograms/numeric-histogram');
const DateHistogram = require('./histograms/date-histogram');

View File

@ -1,3 +1,5 @@
'use strict';
const BaseDataview = require('../base');
const TYPE = 'histogram';

View File

@ -1,3 +1,5 @@
'use strict';
const BaseHistogram = require('./base-histogram');
const debug = require('debug')('windshaft:dataview:date-histogram');
const utils = require('../../../utils/query-utils');

View File

@ -1,3 +1,5 @@
'use strict';
const BaseHistogram = require('./base-histogram');
const debug = require('debug')('windshaft:dataview:numeric-histogram');
const utils = require('../../../utils/query-utils');

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = {
Aggregation: require('./aggregation'),
Formula: require('./formula'),

View File

@ -1,3 +1,5 @@
'use strict';
var BaseOverviewsDataview = require('./base');
var BaseDataview = require('../aggregation');
var debug = require('debug')('windshaft:widget:aggregation:overview');

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var BaseDataview = require('../base');

View File

@ -1,3 +1,5 @@
'use strict';
var parentFactory = require('../factory');
var dataviews = require('./');

View File

@ -1,3 +1,5 @@
'use strict';
var BaseOverviewsDataview = require('./base');
var BaseDataview = require('../formula');
var debug = require('debug')('windshaft:widget:formula:overview');

View File

@ -1,3 +1,5 @@
'use strict';
var _ = require('underscore');
var BaseOverviewsDataview = require('./base');
var BaseDataview = require('../histogram');
@ -278,5 +280,3 @@ Histogram.prototype._shouldOverride = function (override) {
Histogram.prototype._shouldOverrideBins = function (override) {
return override && _.has(override, 'bins');
};

View File

@ -1,3 +1,5 @@
'use strict';
module.exports = {
Aggregation: require('./aggregation'),
Formula: require('./formula'),

View File

@ -1,3 +1,5 @@
'use strict';
var filters = {
category: require('./analysis/category'),
range: require('./analysis/range')

View File

@ -1,3 +1,5 @@
'use strict';
var debug = require('debug')('windshaft:filter:bbox');
var dot = require('dot');
dot.templateSettings.strip = false;

View File

@ -1,3 +1,5 @@
'use strict';
/**
* @param {String} token might match the following pattern: {user}@{tpl_id}@{token}:{cache_buster}
*/

View File

@ -1,3 +1,5 @@
'use strict';
const AggregationMapConfig = require('../../aggregation/aggregation-mapconfig');
const queryUtils = require('../../../utils/query-utils');

View File

@ -1,3 +1,5 @@
'use strict';
var queue = require('queue-async');
var debug = require('debug')('windshaft:analysis');

View File

@ -1,3 +1,5 @@
'use strict';
function DataviewsWidgetsMapConfigAdapter() {
}

View File

@ -1,3 +1,5 @@
'use strict';
function MapConfigBufferSizeAdapter() {
this.formats = ['png', 'png32', 'mvt', 'grid.json'];
}

View File

@ -1,3 +1,5 @@
'use strict';
var queue = require('queue-async');
var _ = require('underscore');
var Datasource = require('windshaft').model.Datasource;

View File

@ -1,3 +1,5 @@
'use strict';
var queue = require('queue-async');
var _ = require('underscore');

View File

@ -1,3 +1,5 @@
'use strict';
function SqlWrapMapConfigAdapter() {
}

Some files were not shown because too many files have changed in this diff Show More