From 6167562758bcbb171f1a5020e46635285c4dbc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 9 Apr 2018 16:18:30 +0200 Subject: [PATCH] Meet application logic and folder struture --- lib/cartodb/{routers => api}/api-router.js | 14 +++++++------- .../map/analyses-catalog-controller.js} | 14 +++++++------- .../map/analysis-layergroup-controller.js} | 0 .../map/anonymous-map-controller.js} | 18 +++++++++--------- .../map/attributes-layergroup-controller.js} | 2 +- .../map/dataview-layergroup-controller.js} | 2 +- lib/cartodb/{routers => api/map}/map-router.js | 18 +++++++++--------- .../map/preview-layergroup-controller.js} | 2 +- .../map/preview-template-controller.js} | 2 +- .../map/tile-layergroup-controller.js} | 2 +- .../middlewares/augment-layergroup-data.js | 0 .../{routers => api}/middlewares/authorize.js | 0 .../middlewares/cache-channel-header.js | 0 .../middlewares/cache-control-header.js | 0 .../middlewares/check-json-content-type.js | 0 .../middlewares/clean-up-query-params.js | 0 .../{routers => api}/middlewares/cors.js | 0 .../middlewares/credentials.js | 0 .../middlewares/db-conn-setup.js | 0 .../middlewares/error-middleware.js | 0 .../middlewares/increment-map-view-count.js | 0 .../map => api}/middlewares/init-profiler.js | 0 .../middlewares/last-modified-header.js | 0 .../last-updated-time-layergroup.js | 0 .../map => api}/middlewares/layer-stats.js | 0 .../middlewares/layergroup-id-header.js | 0 .../middlewares/layergroup-metadata.js | 0 .../middlewares/layergroup-token.js | 0 .../{routers => api}/middlewares/logger.js | 0 .../{routers => api}/middlewares/lzma.js | 0 .../map => api}/middlewares/map-error.js | 0 .../map-store-map-config-provider.js | 2 +- .../middlewares/named-map-provider.js | 0 .../{routers => api}/middlewares/rate-limit.js | 0 .../middlewares/send-response.js | 0 .../middlewares/served-by-host-header.js | 0 .../{routers => api}/middlewares/stats.js | 0 .../middlewares/surrogate-key-header.js | 0 .../middlewares/syntax-error.js | 0 .../{routers => api}/middlewares/user.js | 0 .../middlewares/vector-error.js | 0 .../template/admin-template-controller.js} | 0 .../template/named-template-controller.js} | 18 +++++++++--------- .../template}/template-router.js | 6 +++--- .../template/tile-template-controller.js} | 2 +- lib/cartodb/{ => backends}/api/auth_api.js | 0 .../{ => backends}/api/filter_stats_api.js | 2 +- .../api/overviews_metadata_api.js | 2 +- .../{ => backends}/api/tables_extent_api.js | 0 .../{ => backends}/api/user_limits_api.js | 0 ...erver-info.js => server-info-controller.js} | 2 +- lib/cartodb/server.js | 4 ++-- test/acceptance/rate-limit.test.js | 4 ++-- .../integration/mapconfig_overviews_adapter.js | 4 ++-- test/integration/overviews-metadata-api.js | 2 +- test/unit/cartodb/error-middleware.test.js | 2 +- test/unit/cartodb/error_messages.test.js | 2 +- test/unit/cartodb/lzmaMiddleware.test.js | 2 +- test/unit/cartodb/prepare-context.test.js | 10 +++++----- 59 files changed, 69 insertions(+), 69 deletions(-) rename lib/cartodb/{routers => api}/api-router.js (96%) rename lib/cartodb/{routers/analyses.js => api/map/analyses-catalog-controller.js} (89%) rename lib/cartodb/{routers/layergroup/analysis.js => api/map/analysis-layergroup-controller.js} (100%) rename lib/cartodb/{routers/map/anonymous.js => api/map/anonymous-map-controller.js} (91%) rename lib/cartodb/{routers/layergroup/attributes.js => api/map/attributes-layergroup-controller.js} (96%) rename lib/cartodb/{routers/layergroup/dataview.js => api/map/dataview-layergroup-controller.js} (98%) rename lib/cartodb/{routers => api/map}/map-router.js (84%) rename lib/cartodb/{routers/layergroup/preview.js => api/map/preview-layergroup-controller.js} (98%) rename lib/cartodb/{routers/template/preview.js => api/map/preview-template-controller.js} (99%) rename lib/cartodb/{routers/layergroup/tile.js => api/map/tile-layergroup-controller.js} (98%) rename lib/cartodb/{routers/map => api}/middlewares/augment-layergroup-data.js (100%) rename lib/cartodb/{routers => api}/middlewares/authorize.js (100%) rename lib/cartodb/{routers => api}/middlewares/cache-channel-header.js (100%) rename lib/cartodb/{routers => api}/middlewares/cache-control-header.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/check-json-content-type.js (100%) rename lib/cartodb/{routers => api}/middlewares/clean-up-query-params.js (100%) rename lib/cartodb/{routers => api}/middlewares/cors.js (100%) rename lib/cartodb/{routers => api}/middlewares/credentials.js (100%) rename lib/cartodb/{routers => api}/middlewares/db-conn-setup.js (100%) rename lib/cartodb/{routers => api}/middlewares/error-middleware.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/increment-map-view-count.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/init-profiler.js (100%) rename lib/cartodb/{routers => api}/middlewares/last-modified-header.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/last-updated-time-layergroup.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/layer-stats.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/layergroup-id-header.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/layergroup-metadata.js (100%) rename lib/cartodb/{routers => api}/middlewares/layergroup-token.js (100%) rename lib/cartodb/{routers => api}/middlewares/logger.js (100%) rename lib/cartodb/{routers => api}/middlewares/lzma.js (100%) rename lib/cartodb/{routers/map => api}/middlewares/map-error.js (100%) rename lib/cartodb/{routers/layergroup => api}/middlewares/map-store-map-config-provider.js (91%) rename lib/cartodb/{routers/template => api}/middlewares/named-map-provider.js (100%) rename lib/cartodb/{routers => api}/middlewares/rate-limit.js (100%) rename lib/cartodb/{routers => api}/middlewares/send-response.js (100%) rename lib/cartodb/{routers => api}/middlewares/served-by-host-header.js (100%) rename lib/cartodb/{routers => api}/middlewares/stats.js (100%) rename lib/cartodb/{routers => api}/middlewares/surrogate-key-header.js (100%) rename lib/cartodb/{routers => api}/middlewares/syntax-error.js (100%) rename lib/cartodb/{routers => api}/middlewares/user.js (100%) rename lib/cartodb/{routers => api}/middlewares/vector-error.js (100%) rename lib/cartodb/{routers/template/admin.js => api/template/admin-template-controller.js} (100%) rename lib/cartodb/{routers/map/named.js => api/template/named-template-controller.js} (91%) rename lib/cartodb/{routers => api/template}/template-router.js (89%) rename lib/cartodb/{routers/template/tile.js => api/template/tile-template-controller.js} (97%) rename lib/cartodb/{ => backends}/api/auth_api.js (100%) rename lib/cartodb/{ => backends}/api/filter_stats_api.js (96%) rename lib/cartodb/{ => backends}/api/overviews_metadata_api.js (95%) rename lib/cartodb/{ => backends}/api/tables_extent_api.js (100%) rename lib/cartodb/{ => backends}/api/user_limits_api.js (100%) rename lib/cartodb/{routers/server-info.js => server-info-controller.js} (96%) diff --git a/lib/cartodb/routers/api-router.js b/lib/cartodb/api/api-router.js similarity index 96% rename from lib/cartodb/routers/api-router.js rename to lib/cartodb/api/api-router.js index ca46d6ae..4608d477 100644 --- a/lib/cartodb/routers/api-router.js +++ b/lib/cartodb/api/api-router.js @@ -13,11 +13,11 @@ const TemplateMaps = require('../backends/template_maps.js'); const PgQueryRunner = require('../backends/pg_query_runner'); const StatsBackend = require('../backends/stats'); -const AuthApi = require('../api/auth_api'); -const UserLimitsApi = require('../api/user_limits_api'); -const OverviewsMetadataApi = require('../api/overviews_metadata_api'); -const FilterStatsApi = require('../api/filter_stats_api'); -const TablesExtentApi = require('../api/tables_extent_api'); +const AuthApi = require('../backends/api/auth_api'); +const UserLimitsApi = require('../backends/api/user_limits_api'); +const OverviewsMetadataApi = require('../backends/api/overviews_metadata_api'); +const FilterStatsApi = require('../backends/api/filter_stats_api'); +const TablesExtentApi = require('../backends/api/tables_extent_api'); const LayergroupAffectedTablesCache = require('../cache/layergroup_affected_tables'); const SurrogateKeysCache = require('../cache/surrogate_keys_cache'); @@ -51,8 +51,8 @@ const sendResponse = require('./middlewares/send-response'); const syntaxError = require('./middlewares/syntax-error'); const errorMiddleware = require('./middlewares/error-middleware'); -const MapRouter = require('./map-router'); -const TemplateRouter = require('./template-router'); +const MapRouter = require('./map/map-router'); +const TemplateRouter = require('./template/template-router'); module.exports = class ApiRouter { constructor ({ serverOptions, environmentOptions }) { diff --git a/lib/cartodb/routers/analyses.js b/lib/cartodb/api/map/analyses-catalog-controller.js similarity index 89% rename from lib/cartodb/routers/analyses.js rename to lib/cartodb/api/map/analyses-catalog-controller.js index 145d6a0d..300345c2 100644 --- a/lib/cartodb/routers/analyses.js +++ b/lib/cartodb/api/map/analyses-catalog-controller.js @@ -1,12 +1,12 @@ const PSQL = require('cartodb-psql'); -const cleanUpQueryParams = require('./middlewares/clean-up-query-params'); -const credentials = require('./middlewares/credentials'); -const authorize = require('./middlewares/authorize'); -const dbConnSetup = require('./middlewares/db-conn-setup'); -const rateLimit = require('./middlewares/rate-limit'); +const cleanUpQueryParams = require('../middlewares/clean-up-query-params'); +const credentials = require('../middlewares/credentials'); +const authorize = require('../middlewares/authorize'); +const dbConnSetup = require('../middlewares/db-conn-setup'); +const rateLimit = require('../middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; -const cacheControlHeader = require('./middlewares/cache-control-header'); -const dbParamsFromResLocals = require('../utils/database-params'); +const cacheControlHeader = require('../middlewares/cache-control-header'); +const dbParamsFromResLocals = require('../../utils/database-params'); function AnalysesController(pgConnection, authApi, userLimitsApi) { this.pgConnection = pgConnection; diff --git a/lib/cartodb/routers/layergroup/analysis.js b/lib/cartodb/api/map/analysis-layergroup-controller.js similarity index 100% rename from lib/cartodb/routers/layergroup/analysis.js rename to lib/cartodb/api/map/analysis-layergroup-controller.js diff --git a/lib/cartodb/routers/map/anonymous.js b/lib/cartodb/api/map/anonymous-map-controller.js similarity index 91% rename from lib/cartodb/routers/map/anonymous.js rename to lib/cartodb/api/map/anonymous-map-controller.js index 3e2a3582..4c65988b 100644 --- a/lib/cartodb/routers/map/anonymous.js +++ b/lib/cartodb/api/map/anonymous-map-controller.js @@ -5,19 +5,19 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params'); const credentials = require('../middlewares/credentials'); const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); -const initProfiler = require('./middlewares/init-profiler'); -const checkJsonContentType = require('./middlewares/check-json-content-type'); -const incrementMapViewCount = require('./middlewares/increment-map-view-count'); -const augmentLayergroupData = require('./middlewares/augment-layergroup-data'); +const initProfiler = require('../middlewares/init-profiler'); +const checkJsonContentType = require('../middlewares/check-json-content-type'); +const incrementMapViewCount = require('../middlewares/increment-map-view-count'); +const augmentLayergroupData = require('../middlewares/augment-layergroup-data'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const lastModifiedHeader = require('../middlewares/last-modified-header'); -const lastUpdatedTimeLayergroup = require('./middlewares/last-updated-time-layergroup'); -const layerStats = require('./middlewares/layer-stats'); -const layergroupIdHeader = require('./middlewares/layergroup-id-header'); -const layergroupMetadata = require('./middlewares/layergroup-metadata'); -const mapError = require('./middlewares/map-error'); +const lastUpdatedTimeLayergroup = require('../middlewares/last-updated-time-layergroup'); +const layerStats = require('../middlewares/layer-stats'); +const layergroupIdHeader = require('../middlewares/layergroup-id-header'); +const layergroupMetadata = require('../middlewares/layergroup-metadata'); +const mapError = require('../middlewares/map-error'); const CreateLayergroupMapConfigProvider = require('../../models/mapconfig/provider/create-layergroup-provider'); const rateLimit = require('../middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; diff --git a/lib/cartodb/routers/layergroup/attributes.js b/lib/cartodb/api/map/attributes-layergroup-controller.js similarity index 96% rename from lib/cartodb/routers/layergroup/attributes.js rename to lib/cartodb/api/map/attributes-layergroup-controller.js index 3666483a..52ba5f30 100644 --- a/lib/cartodb/routers/layergroup/attributes.js +++ b/lib/cartodb/api/map/attributes-layergroup-controller.js @@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); const rateLimit = require('../middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; -const createMapStoreMapConfigProvider = require('./middlewares/map-store-map-config-provider'); +const createMapStoreMapConfigProvider = require('../middlewares/map-store-map-config-provider'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); diff --git a/lib/cartodb/routers/layergroup/dataview.js b/lib/cartodb/api/map/dataview-layergroup-controller.js similarity index 98% rename from lib/cartodb/routers/layergroup/dataview.js rename to lib/cartodb/api/map/dataview-layergroup-controller.js index 559a51d2..219723bc 100644 --- a/lib/cartodb/routers/layergroup/dataview.js +++ b/lib/cartodb/api/map/dataview-layergroup-controller.js @@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); const rateLimit = require('../middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; -const createMapStoreMapConfigProvider = require('./middlewares/map-store-map-config-provider'); +const createMapStoreMapConfigProvider = require('../middlewares/map-store-map-config-provider'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); diff --git a/lib/cartodb/routers/map-router.js b/lib/cartodb/api/map/map-router.js similarity index 84% rename from lib/cartodb/routers/map-router.js rename to lib/cartodb/api/map/map-router.js index d02cd563..8303040f 100644 --- a/lib/cartodb/routers/map-router.js +++ b/lib/cartodb/api/map/map-router.js @@ -1,13 +1,13 @@ const { Router: router } = require('express'); -const AnalysisLayergroupController = require('./layergroup/analysis'); -const AttributesLayergroupController = require('./layergroup/attributes'); -const DataviewLayergroupController = require('./layergroup/dataview'); -const PreviewLayergroupController = require('./layergroup/preview'); -const TileLayergroupController = require('./layergroup/tile'); -const AnonymousMapController = require('./map/anonymous'); -const PreviewTemplateController = require('./template/preview'); -const AnalysesController = require('./analyses'); +const AnalysisLayergroupController = require('./analysis-layergroup-controller'); +const AttributesLayergroupController = require('./attributes-layergroup-controller'); +const DataviewLayergroupController = require('./dataview-layergroup-controller'); +const PreviewLayergroupController = require('./preview-layergroup-controller'); +const TileLayergroupController = require('./tile-layergroup-controller'); +const AnonymousMapController = require('./anonymous-map-controller'); +const PreviewTemplateController = require('./preview-template-controller'); +const AnalysesCatalogController = require('./analyses-catalog-controller'); module.exports = class MapRouter { constructor ({ collaborators }) { @@ -108,7 +108,7 @@ module.exports = class MapRouter { userLimitsApi ); - this.analysesController = new AnalysesController( + this.analysesController = new AnalysesCatalogController( pgConnection, authApi, userLimitsApi diff --git a/lib/cartodb/routers/layergroup/preview.js b/lib/cartodb/api/map/preview-layergroup-controller.js similarity index 98% rename from lib/cartodb/routers/layergroup/preview.js rename to lib/cartodb/api/map/preview-layergroup-controller.js index d22efffd..1fbf7754 100644 --- a/lib/cartodb/routers/layergroup/preview.js +++ b/lib/cartodb/api/map/preview-layergroup-controller.js @@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); const rateLimit = require('../middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; -const createMapStoreMapConfigProvider = require('./middlewares/map-store-map-config-provider'); +const createMapStoreMapConfigProvider = require('../middlewares/map-store-map-config-provider'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); diff --git a/lib/cartodb/routers/template/preview.js b/lib/cartodb/api/map/preview-template-controller.js similarity index 99% rename from lib/cartodb/routers/template/preview.js rename to lib/cartodb/api/map/preview-template-controller.js index 224579ad..ecce4b7f 100644 --- a/lib/cartodb/routers/template/preview.js +++ b/lib/cartodb/api/map/preview-template-controller.js @@ -2,7 +2,7 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params'); const credentials = require('../middlewares/credentials'); const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); -const namedMapProvider = require('./middlewares/named-map-provider'); +const namedMapProvider = require('../middlewares/named-map-provider'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); diff --git a/lib/cartodb/routers/layergroup/tile.js b/lib/cartodb/api/map/tile-layergroup-controller.js similarity index 98% rename from lib/cartodb/routers/layergroup/tile.js rename to lib/cartodb/api/map/tile-layergroup-controller.js index 0443ca4e..34abcbda 100644 --- a/lib/cartodb/routers/layergroup/tile.js +++ b/lib/cartodb/api/map/tile-layergroup-controller.js @@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); const rateLimit = require('../middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; -const createMapStoreMapConfigProvider = require('./middlewares/map-store-map-config-provider'); +const createMapStoreMapConfigProvider = require('../middlewares/map-store-map-config-provider'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); diff --git a/lib/cartodb/routers/map/middlewares/augment-layergroup-data.js b/lib/cartodb/api/middlewares/augment-layergroup-data.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/augment-layergroup-data.js rename to lib/cartodb/api/middlewares/augment-layergroup-data.js diff --git a/lib/cartodb/routers/middlewares/authorize.js b/lib/cartodb/api/middlewares/authorize.js similarity index 100% rename from lib/cartodb/routers/middlewares/authorize.js rename to lib/cartodb/api/middlewares/authorize.js diff --git a/lib/cartodb/routers/middlewares/cache-channel-header.js b/lib/cartodb/api/middlewares/cache-channel-header.js similarity index 100% rename from lib/cartodb/routers/middlewares/cache-channel-header.js rename to lib/cartodb/api/middlewares/cache-channel-header.js diff --git a/lib/cartodb/routers/middlewares/cache-control-header.js b/lib/cartodb/api/middlewares/cache-control-header.js similarity index 100% rename from lib/cartodb/routers/middlewares/cache-control-header.js rename to lib/cartodb/api/middlewares/cache-control-header.js diff --git a/lib/cartodb/routers/map/middlewares/check-json-content-type.js b/lib/cartodb/api/middlewares/check-json-content-type.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/check-json-content-type.js rename to lib/cartodb/api/middlewares/check-json-content-type.js diff --git a/lib/cartodb/routers/middlewares/clean-up-query-params.js b/lib/cartodb/api/middlewares/clean-up-query-params.js similarity index 100% rename from lib/cartodb/routers/middlewares/clean-up-query-params.js rename to lib/cartodb/api/middlewares/clean-up-query-params.js diff --git a/lib/cartodb/routers/middlewares/cors.js b/lib/cartodb/api/middlewares/cors.js similarity index 100% rename from lib/cartodb/routers/middlewares/cors.js rename to lib/cartodb/api/middlewares/cors.js diff --git a/lib/cartodb/routers/middlewares/credentials.js b/lib/cartodb/api/middlewares/credentials.js similarity index 100% rename from lib/cartodb/routers/middlewares/credentials.js rename to lib/cartodb/api/middlewares/credentials.js diff --git a/lib/cartodb/routers/middlewares/db-conn-setup.js b/lib/cartodb/api/middlewares/db-conn-setup.js similarity index 100% rename from lib/cartodb/routers/middlewares/db-conn-setup.js rename to lib/cartodb/api/middlewares/db-conn-setup.js diff --git a/lib/cartodb/routers/middlewares/error-middleware.js b/lib/cartodb/api/middlewares/error-middleware.js similarity index 100% rename from lib/cartodb/routers/middlewares/error-middleware.js rename to lib/cartodb/api/middlewares/error-middleware.js diff --git a/lib/cartodb/routers/map/middlewares/increment-map-view-count.js b/lib/cartodb/api/middlewares/increment-map-view-count.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/increment-map-view-count.js rename to lib/cartodb/api/middlewares/increment-map-view-count.js diff --git a/lib/cartodb/routers/map/middlewares/init-profiler.js b/lib/cartodb/api/middlewares/init-profiler.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/init-profiler.js rename to lib/cartodb/api/middlewares/init-profiler.js diff --git a/lib/cartodb/routers/middlewares/last-modified-header.js b/lib/cartodb/api/middlewares/last-modified-header.js similarity index 100% rename from lib/cartodb/routers/middlewares/last-modified-header.js rename to lib/cartodb/api/middlewares/last-modified-header.js diff --git a/lib/cartodb/routers/map/middlewares/last-updated-time-layergroup.js b/lib/cartodb/api/middlewares/last-updated-time-layergroup.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/last-updated-time-layergroup.js rename to lib/cartodb/api/middlewares/last-updated-time-layergroup.js diff --git a/lib/cartodb/routers/map/middlewares/layer-stats.js b/lib/cartodb/api/middlewares/layer-stats.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/layer-stats.js rename to lib/cartodb/api/middlewares/layer-stats.js diff --git a/lib/cartodb/routers/map/middlewares/layergroup-id-header.js b/lib/cartodb/api/middlewares/layergroup-id-header.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/layergroup-id-header.js rename to lib/cartodb/api/middlewares/layergroup-id-header.js diff --git a/lib/cartodb/routers/map/middlewares/layergroup-metadata.js b/lib/cartodb/api/middlewares/layergroup-metadata.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/layergroup-metadata.js rename to lib/cartodb/api/middlewares/layergroup-metadata.js diff --git a/lib/cartodb/routers/middlewares/layergroup-token.js b/lib/cartodb/api/middlewares/layergroup-token.js similarity index 100% rename from lib/cartodb/routers/middlewares/layergroup-token.js rename to lib/cartodb/api/middlewares/layergroup-token.js diff --git a/lib/cartodb/routers/middlewares/logger.js b/lib/cartodb/api/middlewares/logger.js similarity index 100% rename from lib/cartodb/routers/middlewares/logger.js rename to lib/cartodb/api/middlewares/logger.js diff --git a/lib/cartodb/routers/middlewares/lzma.js b/lib/cartodb/api/middlewares/lzma.js similarity index 100% rename from lib/cartodb/routers/middlewares/lzma.js rename to lib/cartodb/api/middlewares/lzma.js diff --git a/lib/cartodb/routers/map/middlewares/map-error.js b/lib/cartodb/api/middlewares/map-error.js similarity index 100% rename from lib/cartodb/routers/map/middlewares/map-error.js rename to lib/cartodb/api/middlewares/map-error.js diff --git a/lib/cartodb/routers/layergroup/middlewares/map-store-map-config-provider.js b/lib/cartodb/api/middlewares/map-store-map-config-provider.js similarity index 91% rename from lib/cartodb/routers/layergroup/middlewares/map-store-map-config-provider.js rename to lib/cartodb/api/middlewares/map-store-map-config-provider.js index 7d64cb01..f84dd3fc 100644 --- a/lib/cartodb/routers/layergroup/middlewares/map-store-map-config-provider.js +++ b/lib/cartodb/api/middlewares/map-store-map-config-provider.js @@ -1,4 +1,4 @@ -const MapStoreMapConfigProvider = require('../../../models/mapconfig/provider/map-store-provider'); +const MapStoreMapConfigProvider = require('../../models/mapconfig/provider/map-store-provider'); module.exports = function createMapStoreMapConfigProvider ( mapStore, diff --git a/lib/cartodb/routers/template/middlewares/named-map-provider.js b/lib/cartodb/api/middlewares/named-map-provider.js similarity index 100% rename from lib/cartodb/routers/template/middlewares/named-map-provider.js rename to lib/cartodb/api/middlewares/named-map-provider.js diff --git a/lib/cartodb/routers/middlewares/rate-limit.js b/lib/cartodb/api/middlewares/rate-limit.js similarity index 100% rename from lib/cartodb/routers/middlewares/rate-limit.js rename to lib/cartodb/api/middlewares/rate-limit.js diff --git a/lib/cartodb/routers/middlewares/send-response.js b/lib/cartodb/api/middlewares/send-response.js similarity index 100% rename from lib/cartodb/routers/middlewares/send-response.js rename to lib/cartodb/api/middlewares/send-response.js diff --git a/lib/cartodb/routers/middlewares/served-by-host-header.js b/lib/cartodb/api/middlewares/served-by-host-header.js similarity index 100% rename from lib/cartodb/routers/middlewares/served-by-host-header.js rename to lib/cartodb/api/middlewares/served-by-host-header.js diff --git a/lib/cartodb/routers/middlewares/stats.js b/lib/cartodb/api/middlewares/stats.js similarity index 100% rename from lib/cartodb/routers/middlewares/stats.js rename to lib/cartodb/api/middlewares/stats.js diff --git a/lib/cartodb/routers/middlewares/surrogate-key-header.js b/lib/cartodb/api/middlewares/surrogate-key-header.js similarity index 100% rename from lib/cartodb/routers/middlewares/surrogate-key-header.js rename to lib/cartodb/api/middlewares/surrogate-key-header.js diff --git a/lib/cartodb/routers/middlewares/syntax-error.js b/lib/cartodb/api/middlewares/syntax-error.js similarity index 100% rename from lib/cartodb/routers/middlewares/syntax-error.js rename to lib/cartodb/api/middlewares/syntax-error.js diff --git a/lib/cartodb/routers/middlewares/user.js b/lib/cartodb/api/middlewares/user.js similarity index 100% rename from lib/cartodb/routers/middlewares/user.js rename to lib/cartodb/api/middlewares/user.js diff --git a/lib/cartodb/routers/middlewares/vector-error.js b/lib/cartodb/api/middlewares/vector-error.js similarity index 100% rename from lib/cartodb/routers/middlewares/vector-error.js rename to lib/cartodb/api/middlewares/vector-error.js diff --git a/lib/cartodb/routers/template/admin.js b/lib/cartodb/api/template/admin-template-controller.js similarity index 100% rename from lib/cartodb/routers/template/admin.js rename to lib/cartodb/api/template/admin-template-controller.js diff --git a/lib/cartodb/routers/map/named.js b/lib/cartodb/api/template/named-template-controller.js similarity index 91% rename from lib/cartodb/routers/map/named.js rename to lib/cartodb/api/template/named-template-controller.js index 47699e83..140523b1 100644 --- a/lib/cartodb/routers/map/named.js +++ b/lib/cartodb/api/template/named-template-controller.js @@ -2,19 +2,19 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params'); const credentials = require('../middlewares/credentials'); const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); -const initProfiler = require('./middlewares/init-profiler'); -const checkJsonContentType = require('./middlewares/check-json-content-type'); -const incrementMapViewCount = require('./middlewares/increment-map-view-count'); -const augmentLayergroupData = require('./middlewares/augment-layergroup-data'); +const initProfiler = require('../middlewares/init-profiler'); +const checkJsonContentType = require('../middlewares/check-json-content-type'); +const incrementMapViewCount = require('../middlewares/increment-map-view-count'); +const augmentLayergroupData = require('../middlewares/augment-layergroup-data'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const lastModifiedHeader = require('../middlewares/last-modified-header'); -const lastUpdatedTimeLayergroup = require('./middlewares/last-updated-time-layergroup'); -const layerStats = require('./middlewares/layer-stats'); -const layergroupIdHeader = require('./middlewares/layergroup-id-header'); -const layergroupMetadata = require('./middlewares/layergroup-metadata'); -const mapError = require('./middlewares/map-error'); +const lastUpdatedTimeLayergroup = require('../middlewares/last-updated-time-layergroup'); +const layerStats = require('../middlewares/layer-stats'); +const layergroupIdHeader = require('../middlewares/layergroup-id-header'); +const layergroupMetadata = require('../middlewares/layergroup-metadata'); +const mapError = require('../middlewares/map-error'); const NamedMapMapConfigProvider = require('../../models/mapconfig/provider/named-map-provider'); const CreateLayergroupMapConfigProvider = require('../../models/mapconfig/provider/create-layergroup-provider'); const rateLimit = require('../middlewares/rate-limit'); diff --git a/lib/cartodb/routers/template-router.js b/lib/cartodb/api/template/template-router.js similarity index 89% rename from lib/cartodb/routers/template-router.js rename to lib/cartodb/api/template/template-router.js index d549dafd..b4a70715 100644 --- a/lib/cartodb/routers/template-router.js +++ b/lib/cartodb/api/template/template-router.js @@ -1,8 +1,8 @@ const { Router: router } = require('express'); -const NamedMapController = require('./map/named'); -const AdminTemplateController = require('./template/admin'); -const TileTemplateController = require('./template/tile'); +const NamedMapController = require('./named-template-controller'); +const AdminTemplateController = require('./admin-template-controller'); +const TileTemplateController = require('./tile-template-controller'); module.exports = class TemplateRouter { constructor ({ collaborators }) { diff --git a/lib/cartodb/routers/template/tile.js b/lib/cartodb/api/template/tile-template-controller.js similarity index 97% rename from lib/cartodb/routers/template/tile.js rename to lib/cartodb/api/template/tile-template-controller.js index 730f7e9d..11c0bc19 100644 --- a/lib/cartodb/routers/template/tile.js +++ b/lib/cartodb/api/template/tile-template-controller.js @@ -2,7 +2,7 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params'); const credentials = require('../middlewares/credentials'); const dbConnSetup = require('../middlewares/db-conn-setup'); const authorize = require('../middlewares/authorize'); -const namedMapProvider = require('./middlewares/named-map-provider'); +const namedMapProvider = require('../middlewares/named-map-provider'); const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); diff --git a/lib/cartodb/api/auth_api.js b/lib/cartodb/backends/api/auth_api.js similarity index 100% rename from lib/cartodb/api/auth_api.js rename to lib/cartodb/backends/api/auth_api.js diff --git a/lib/cartodb/api/filter_stats_api.js b/lib/cartodb/backends/api/filter_stats_api.js similarity index 96% rename from lib/cartodb/api/filter_stats_api.js rename to lib/cartodb/backends/api/filter_stats_api.js index 31e90a25..72fd970f 100644 --- a/lib/cartodb/api/filter_stats_api.js +++ b/lib/cartodb/backends/api/filter_stats_api.js @@ -1,6 +1,6 @@ var _ = require('underscore'); var step = require('step'); -var AnalysisFilter = require('../models/filter/analysis'); +var AnalysisFilter = require('../../models/filter/analysis'); function FilterStatsApi(pgQueryRunner) { this.pgQueryRunner = pgQueryRunner; diff --git a/lib/cartodb/api/overviews_metadata_api.js b/lib/cartodb/backends/api/overviews_metadata_api.js similarity index 95% rename from lib/cartodb/api/overviews_metadata_api.js rename to lib/cartodb/backends/api/overviews_metadata_api.js index 55b4966f..dda51d7e 100644 --- a/lib/cartodb/api/overviews_metadata_api.js +++ b/lib/cartodb/backends/api/overviews_metadata_api.js @@ -1,4 +1,4 @@ -var SubstitutionTokens = require('../utils/substitution-tokens'); +var SubstitutionTokens = require('../../utils/substitution-tokens'); function OverviewsMetadataApi(pgQueryRunner) { this.pgQueryRunner = pgQueryRunner; diff --git a/lib/cartodb/api/tables_extent_api.js b/lib/cartodb/backends/api/tables_extent_api.js similarity index 100% rename from lib/cartodb/api/tables_extent_api.js rename to lib/cartodb/backends/api/tables_extent_api.js diff --git a/lib/cartodb/api/user_limits_api.js b/lib/cartodb/backends/api/user_limits_api.js similarity index 100% rename from lib/cartodb/api/user_limits_api.js rename to lib/cartodb/backends/api/user_limits_api.js diff --git a/lib/cartodb/routers/server-info.js b/lib/cartodb/server-info-controller.js similarity index 96% rename from lib/cartodb/routers/server-info.js rename to lib/cartodb/server-info-controller.js index 12f6432b..17e0649c 100644 --- a/lib/cartodb/routers/server-info.js +++ b/lib/cartodb/server-info-controller.js @@ -1,4 +1,4 @@ -var HealthCheck = require('../monitoring/health_check'); +var HealthCheck = require('./monitoring/health_check'); var WELCOME_MSG = "This is the CartoDB Maps API, " + "see the documentation at http://docs.cartodb.com/cartodb-platform/maps-api.html"; diff --git a/lib/cartodb/server.js b/lib/cartodb/server.js index 40f1195c..ea51f2db 100644 --- a/lib/cartodb/server.js +++ b/lib/cartodb/server.js @@ -5,8 +5,8 @@ const { mapnik } = windshaft; const jsonReplacer = require('./utils/json-replacer'); -const ApiRouter = require('./routers/api-router'); -const ServerInfoController = require('./routers/server-info'); +const ApiRouter = require('./api/api-router'); +const ServerInfoController = require('./server-info-controller'); const StatsClient = require('./stats/client'); diff --git a/test/acceptance/rate-limit.test.js b/test/acceptance/rate-limit.test.js index 568db07b..5b7cdbc0 100644 --- a/test/acceptance/rate-limit.test.js +++ b/test/acceptance/rate-limit.test.js @@ -5,8 +5,8 @@ const redis = require('redis'); const RedisPool = require('redis-mpool'); const cartodbRedis = require('cartodb-redis'); const TestClient = require('../support/test-client'); -const UserLimitsApi = require('../../lib/cartodb/api/user_limits_api'); -const rateLimitMiddleware = require('../../lib/cartodb/routers/middlewares/rate-limit'); +const UserLimitsApi = require('../../lib/cartodb/backends/api/user_limits_api'); +const rateLimitMiddleware = require('../../lib/cartodb/api/middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitMiddleware; let userLimitsApi; diff --git a/test/integration/mapconfig_overviews_adapter.js b/test/integration/mapconfig_overviews_adapter.js index 87a87935..79196e3b 100644 --- a/test/integration/mapconfig_overviews_adapter.js +++ b/test/integration/mapconfig_overviews_adapter.js @@ -5,8 +5,8 @@ var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); var PgConnection = require(__dirname + '/../../lib/cartodb/backends/pg_connection'); var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); -var OverviewsMetadataApi = require('../../lib/cartodb/api/overviews_metadata_api'); -var FilterStatsApi = require('../../lib/cartodb/api/filter_stats_api'); +var OverviewsMetadataApi = require('../../lib/cartodb/backends/api/overviews_metadata_api'); +var FilterStatsApi = require('../../lib/cartodb/backends/api/filter_stats_api'); var MapConfigOverviewsAdapter = require('../../lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter'); var redisPool = new RedisPool(global.environment.redis); diff --git a/test/integration/overviews-metadata-api.js b/test/integration/overviews-metadata-api.js index 4d015870..e51c2129 100644 --- a/test/integration/overviews-metadata-api.js +++ b/test/integration/overviews-metadata-api.js @@ -7,7 +7,7 @@ var cartodbRedis = require('cartodb-redis'); var PgConnection = require('../../lib/cartodb/backends/pg_connection'); var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); -var OverviewsMetadataApi = require('../../lib/cartodb/api/overviews_metadata_api'); +var OverviewsMetadataApi = require('../../lib/cartodb/backends/api/overviews_metadata_api'); describe('OverviewsMetadataApi', function() { diff --git a/test/unit/cartodb/error-middleware.test.js b/test/unit/cartodb/error-middleware.test.js index 74cb8fa5..88b1ed6e 100644 --- a/test/unit/cartodb/error-middleware.test.js +++ b/test/unit/cartodb/error-middleware.test.js @@ -1,7 +1,7 @@ require('../../support/test_helper.js'); var assert = require('assert'); -var errorMiddleware = require('../../../lib/cartodb/routers/middlewares/error-middleware'); +var errorMiddleware = require('../../../lib/cartodb/api/middlewares/error-middleware'); describe('error-middleware', function() { diff --git a/test/unit/cartodb/error_messages.test.js b/test/unit/cartodb/error_messages.test.js index dfc489de..ecc6fe3c 100644 --- a/test/unit/cartodb/error_messages.test.js +++ b/test/unit/cartodb/error_messages.test.js @@ -2,7 +2,7 @@ require('../../support/test_helper'); var assert = require('assert'); -var errorMiddleware = require('../../../lib/cartodb/routers/middlewares/error-middleware'); +var errorMiddleware = require('../../../lib/cartodb/api/middlewares/error-middleware'); describe('error messages clean up', function() { diff --git a/test/unit/cartodb/lzmaMiddleware.test.js b/test/unit/cartodb/lzmaMiddleware.test.js index 06219a4d..9701d7ca 100644 --- a/test/unit/cartodb/lzmaMiddleware.test.js +++ b/test/unit/cartodb/lzmaMiddleware.test.js @@ -1,7 +1,7 @@ var assert = require('assert'); var testHelper = require('../../support/test_helper'); -var lzmaMiddleware = require('../../../lib/cartodb/routers/middlewares/lzma'); +var lzmaMiddleware = require('../../../lib/cartodb/api/middlewares/lzma'); describe('lzma-middleware', function() { diff --git a/test/unit/cartodb/prepare-context.test.js b/test/unit/cartodb/prepare-context.test.js index 37265f23..e9f0a320 100644 --- a/test/unit/cartodb/prepare-context.test.js +++ b/test/unit/cartodb/prepare-context.test.js @@ -4,13 +4,13 @@ var _ = require('underscore'); var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); var PgConnection = require('../../../lib/cartodb/backends/pg_connection'); -var AuthApi = require('../../../lib/cartodb/api/auth_api'); +var AuthApi = require('../../../lib/cartodb/backends/api/auth_api'); var TemplateMaps = require('../../../lib/cartodb/backends/template_maps'); -const cleanUpQueryParamsMiddleware = require('../../../lib/cartodb/routers/middlewares/clean-up-query-params'); -const authorizeMiddleware = require('../../../lib/cartodb/routers/middlewares/authorize'); -const dbConnSetupMiddleware = require('../../../lib/cartodb/routers/middlewares/db-conn-setup'); -const credentialsMiddleware = require('../../../lib/cartodb/routers/middlewares/credentials'); +const cleanUpQueryParamsMiddleware = require('../../../lib/cartodb/api/middlewares/clean-up-query-params'); +const authorizeMiddleware = require('../../../lib/cartodb/api/middlewares/authorize'); +const dbConnSetupMiddleware = require('../../../lib/cartodb/api/middlewares/db-conn-setup'); +const credentialsMiddleware = require('../../../lib/cartodb/api/middlewares/credentials'); var windshaft = require('windshaft');