Meet application logic and folder struture

This commit is contained in:
Daniel García Aubert 2018-04-09 16:18:30 +02:00
parent 7e68f5270d
commit 6167562758
59 changed files with 69 additions and 69 deletions

View File

@ -13,11 +13,11 @@ const TemplateMaps = require('../backends/template_maps.js');
const PgQueryRunner = require('../backends/pg_query_runner'); const PgQueryRunner = require('../backends/pg_query_runner');
const StatsBackend = require('../backends/stats'); const StatsBackend = require('../backends/stats');
const AuthApi = require('../api/auth_api'); const AuthApi = require('../backends/api/auth_api');
const UserLimitsApi = require('../api/user_limits_api'); const UserLimitsApi = require('../backends/api/user_limits_api');
const OverviewsMetadataApi = require('../api/overviews_metadata_api'); const OverviewsMetadataApi = require('../backends/api/overviews_metadata_api');
const FilterStatsApi = require('../api/filter_stats_api'); const FilterStatsApi = require('../backends/api/filter_stats_api');
const TablesExtentApi = require('../api/tables_extent_api'); const TablesExtentApi = require('../backends/api/tables_extent_api');
const LayergroupAffectedTablesCache = require('../cache/layergroup_affected_tables'); const LayergroupAffectedTablesCache = require('../cache/layergroup_affected_tables');
const SurrogateKeysCache = require('../cache/surrogate_keys_cache'); const SurrogateKeysCache = require('../cache/surrogate_keys_cache');
@ -51,8 +51,8 @@ const sendResponse = require('./middlewares/send-response');
const syntaxError = require('./middlewares/syntax-error'); const syntaxError = require('./middlewares/syntax-error');
const errorMiddleware = require('./middlewares/error-middleware'); const errorMiddleware = require('./middlewares/error-middleware');
const MapRouter = require('./map-router'); const MapRouter = require('./map/map-router');
const TemplateRouter = require('./template-router'); const TemplateRouter = require('./template/template-router');
module.exports = class ApiRouter { module.exports = class ApiRouter {
constructor ({ serverOptions, environmentOptions }) { constructor ({ serverOptions, environmentOptions }) {

View File

@ -1,12 +1,12 @@
const PSQL = require('cartodb-psql'); const PSQL = require('cartodb-psql');
const cleanUpQueryParams = require('./middlewares/clean-up-query-params'); const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('./middlewares/credentials'); const credentials = require('../middlewares/credentials');
const authorize = require('./middlewares/authorize'); const authorize = require('../middlewares/authorize');
const dbConnSetup = require('./middlewares/db-conn-setup'); const dbConnSetup = require('../middlewares/db-conn-setup');
const rateLimit = require('./middlewares/rate-limit'); const rateLimit = require('../middlewares/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
const cacheControlHeader = require('./middlewares/cache-control-header'); const cacheControlHeader = require('../middlewares/cache-control-header');
const dbParamsFromResLocals = require('../utils/database-params'); const dbParamsFromResLocals = require('../../utils/database-params');
function AnalysesController(pgConnection, authApi, userLimitsApi) { function AnalysesController(pgConnection, authApi, userLimitsApi) {
this.pgConnection = pgConnection; this.pgConnection = pgConnection;

View File

@ -5,19 +5,19 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials'); const credentials = require('../middlewares/credentials');
const dbConnSetup = require('../middlewares/db-conn-setup'); const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); const authorize = require('../middlewares/authorize');
const initProfiler = require('./middlewares/init-profiler'); const initProfiler = require('../middlewares/init-profiler');
const checkJsonContentType = require('./middlewares/check-json-content-type'); const checkJsonContentType = require('../middlewares/check-json-content-type');
const incrementMapViewCount = require('./middlewares/increment-map-view-count'); const incrementMapViewCount = require('../middlewares/increment-map-view-count');
const augmentLayergroupData = require('./middlewares/augment-layergroup-data'); const augmentLayergroupData = require('../middlewares/augment-layergroup-data');
const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');
const lastModifiedHeader = require('../middlewares/last-modified-header'); const lastModifiedHeader = require('../middlewares/last-modified-header');
const lastUpdatedTimeLayergroup = require('./middlewares/last-updated-time-layergroup'); const lastUpdatedTimeLayergroup = require('../middlewares/last-updated-time-layergroup');
const layerStats = require('./middlewares/layer-stats'); const layerStats = require('../middlewares/layer-stats');
const layergroupIdHeader = require('./middlewares/layergroup-id-header'); const layergroupIdHeader = require('../middlewares/layergroup-id-header');
const layergroupMetadata = require('./middlewares/layergroup-metadata'); const layergroupMetadata = require('../middlewares/layergroup-metadata');
const mapError = require('./middlewares/map-error'); const mapError = require('../middlewares/map-error');
const CreateLayergroupMapConfigProvider = require('../../models/mapconfig/provider/create-layergroup-provider'); const CreateLayergroupMapConfigProvider = require('../../models/mapconfig/provider/create-layergroup-provider');
const rateLimit = require('../middlewares/rate-limit'); const rateLimit = require('../middlewares/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;

View File

@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); const authorize = require('../middlewares/authorize');
const rateLimit = require('../middlewares/rate-limit'); const rateLimit = require('../middlewares/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; 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 cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');

View File

@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); const authorize = require('../middlewares/authorize');
const rateLimit = require('../middlewares/rate-limit'); const rateLimit = require('../middlewares/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; 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 cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');

View File

@ -1,13 +1,13 @@
const { Router: router } = require('express'); const { Router: router } = require('express');
const AnalysisLayergroupController = require('./layergroup/analysis'); const AnalysisLayergroupController = require('./analysis-layergroup-controller');
const AttributesLayergroupController = require('./layergroup/attributes'); const AttributesLayergroupController = require('./attributes-layergroup-controller');
const DataviewLayergroupController = require('./layergroup/dataview'); const DataviewLayergroupController = require('./dataview-layergroup-controller');
const PreviewLayergroupController = require('./layergroup/preview'); const PreviewLayergroupController = require('./preview-layergroup-controller');
const TileLayergroupController = require('./layergroup/tile'); const TileLayergroupController = require('./tile-layergroup-controller');
const AnonymousMapController = require('./map/anonymous'); const AnonymousMapController = require('./anonymous-map-controller');
const PreviewTemplateController = require('./template/preview'); const PreviewTemplateController = require('./preview-template-controller');
const AnalysesController = require('./analyses'); const AnalysesCatalogController = require('./analyses-catalog-controller');
module.exports = class MapRouter { module.exports = class MapRouter {
constructor ({ collaborators }) { constructor ({ collaborators }) {
@ -108,7 +108,7 @@ module.exports = class MapRouter {
userLimitsApi userLimitsApi
); );
this.analysesController = new AnalysesController( this.analysesController = new AnalysesCatalogController(
pgConnection, pgConnection,
authApi, authApi,
userLimitsApi userLimitsApi

View File

@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); const authorize = require('../middlewares/authorize');
const rateLimit = require('../middlewares/rate-limit'); const rateLimit = require('../middlewares/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; 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 cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');

View File

@ -2,7 +2,7 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials'); const credentials = require('../middlewares/credentials');
const dbConnSetup = require('../middlewares/db-conn-setup'); const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); 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 cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');

View File

@ -5,7 +5,7 @@ const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); const authorize = require('../middlewares/authorize');
const rateLimit = require('../middlewares/rate-limit'); const rateLimit = require('../middlewares/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; 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 cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');

View File

@ -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 ( module.exports = function createMapStoreMapConfigProvider (
mapStore, mapStore,

View File

@ -2,19 +2,19 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials'); const credentials = require('../middlewares/credentials');
const dbConnSetup = require('../middlewares/db-conn-setup'); const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); const authorize = require('../middlewares/authorize');
const initProfiler = require('./middlewares/init-profiler'); const initProfiler = require('../middlewares/init-profiler');
const checkJsonContentType = require('./middlewares/check-json-content-type'); const checkJsonContentType = require('../middlewares/check-json-content-type');
const incrementMapViewCount = require('./middlewares/increment-map-view-count'); const incrementMapViewCount = require('../middlewares/increment-map-view-count');
const augmentLayergroupData = require('./middlewares/augment-layergroup-data'); const augmentLayergroupData = require('../middlewares/augment-layergroup-data');
const cacheControlHeader = require('../middlewares/cache-control-header'); const cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');
const lastModifiedHeader = require('../middlewares/last-modified-header'); const lastModifiedHeader = require('../middlewares/last-modified-header');
const lastUpdatedTimeLayergroup = require('./middlewares/last-updated-time-layergroup'); const lastUpdatedTimeLayergroup = require('../middlewares/last-updated-time-layergroup');
const layerStats = require('./middlewares/layer-stats'); const layerStats = require('../middlewares/layer-stats');
const layergroupIdHeader = require('./middlewares/layergroup-id-header'); const layergroupIdHeader = require('../middlewares/layergroup-id-header');
const layergroupMetadata = require('./middlewares/layergroup-metadata'); const layergroupMetadata = require('../middlewares/layergroup-metadata');
const mapError = require('./middlewares/map-error'); const mapError = require('../middlewares/map-error');
const NamedMapMapConfigProvider = require('../../models/mapconfig/provider/named-map-provider'); const NamedMapMapConfigProvider = require('../../models/mapconfig/provider/named-map-provider');
const CreateLayergroupMapConfigProvider = require('../../models/mapconfig/provider/create-layergroup-provider'); const CreateLayergroupMapConfigProvider = require('../../models/mapconfig/provider/create-layergroup-provider');
const rateLimit = require('../middlewares/rate-limit'); const rateLimit = require('../middlewares/rate-limit');

View File

@ -1,8 +1,8 @@
const { Router: router } = require('express'); const { Router: router } = require('express');
const NamedMapController = require('./map/named'); const NamedMapController = require('./named-template-controller');
const AdminTemplateController = require('./template/admin'); const AdminTemplateController = require('./admin-template-controller');
const TileTemplateController = require('./template/tile'); const TileTemplateController = require('./tile-template-controller');
module.exports = class TemplateRouter { module.exports = class TemplateRouter {
constructor ({ collaborators }) { constructor ({ collaborators }) {

View File

@ -2,7 +2,7 @@ const cleanUpQueryParams = require('../middlewares/clean-up-query-params');
const credentials = require('../middlewares/credentials'); const credentials = require('../middlewares/credentials');
const dbConnSetup = require('../middlewares/db-conn-setup'); const dbConnSetup = require('../middlewares/db-conn-setup');
const authorize = require('../middlewares/authorize'); 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 cacheControlHeader = require('../middlewares/cache-control-header');
const cacheChannelHeader = require('../middlewares/cache-channel-header'); const cacheChannelHeader = require('../middlewares/cache-channel-header');
const surrogateKeyHeader = require('../middlewares/surrogate-key-header'); const surrogateKeyHeader = require('../middlewares/surrogate-key-header');

View File

@ -1,6 +1,6 @@
var _ = require('underscore'); var _ = require('underscore');
var step = require('step'); var step = require('step');
var AnalysisFilter = require('../models/filter/analysis'); var AnalysisFilter = require('../../models/filter/analysis');
function FilterStatsApi(pgQueryRunner) { function FilterStatsApi(pgQueryRunner) {
this.pgQueryRunner = pgQueryRunner; this.pgQueryRunner = pgQueryRunner;

View File

@ -1,4 +1,4 @@
var SubstitutionTokens = require('../utils/substitution-tokens'); var SubstitutionTokens = require('../../utils/substitution-tokens');
function OverviewsMetadataApi(pgQueryRunner) { function OverviewsMetadataApi(pgQueryRunner) {
this.pgQueryRunner = pgQueryRunner; this.pgQueryRunner = pgQueryRunner;

View File

@ -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, " + var WELCOME_MSG = "This is the CartoDB Maps API, " +
"see the documentation at http://docs.cartodb.com/cartodb-platform/maps-api.html"; "see the documentation at http://docs.cartodb.com/cartodb-platform/maps-api.html";

View File

@ -5,8 +5,8 @@ const { mapnik } = windshaft;
const jsonReplacer = require('./utils/json-replacer'); const jsonReplacer = require('./utils/json-replacer');
const ApiRouter = require('./routers/api-router'); const ApiRouter = require('./api/api-router');
const ServerInfoController = require('./routers/server-info'); const ServerInfoController = require('./server-info-controller');
const StatsClient = require('./stats/client'); const StatsClient = require('./stats/client');

View File

@ -5,8 +5,8 @@ const redis = require('redis');
const RedisPool = require('redis-mpool'); const RedisPool = require('redis-mpool');
const cartodbRedis = require('cartodb-redis'); const cartodbRedis = require('cartodb-redis');
const TestClient = require('../support/test-client'); const TestClient = require('../support/test-client');
const UserLimitsApi = require('../../lib/cartodb/api/user_limits_api'); const UserLimitsApi = require('../../lib/cartodb/backends/api/user_limits_api');
const rateLimitMiddleware = require('../../lib/cartodb/routers/middlewares/rate-limit'); const rateLimitMiddleware = require('../../lib/cartodb/api/middlewares/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitMiddleware; const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitMiddleware;
let userLimitsApi; let userLimitsApi;

View File

@ -5,8 +5,8 @@ var RedisPool = require('redis-mpool');
var cartodbRedis = require('cartodb-redis'); var cartodbRedis = require('cartodb-redis');
var PgConnection = require(__dirname + '/../../lib/cartodb/backends/pg_connection'); var PgConnection = require(__dirname + '/../../lib/cartodb/backends/pg_connection');
var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); 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');
var FilterStatsApi = require('../../lib/cartodb/api/filter_stats_api'); var FilterStatsApi = require('../../lib/cartodb/backends/api/filter_stats_api');
var MapConfigOverviewsAdapter = require('../../lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter'); var MapConfigOverviewsAdapter = require('../../lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter');
var redisPool = new RedisPool(global.environment.redis); var redisPool = new RedisPool(global.environment.redis);

View File

@ -7,7 +7,7 @@ var cartodbRedis = require('cartodb-redis');
var PgConnection = require('../../lib/cartodb/backends/pg_connection'); var PgConnection = require('../../lib/cartodb/backends/pg_connection');
var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); 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() { describe('OverviewsMetadataApi', function() {

View File

@ -1,7 +1,7 @@
require('../../support/test_helper.js'); require('../../support/test_helper.js');
var assert = require('assert'); 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() { describe('error-middleware', function() {

View File

@ -2,7 +2,7 @@ require('../../support/test_helper');
var assert = require('assert'); 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() { describe('error messages clean up', function() {

View File

@ -1,7 +1,7 @@
var assert = require('assert'); var assert = require('assert');
var testHelper = require('../../support/test_helper'); 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() { describe('lzma-middleware', function() {

View File

@ -4,13 +4,13 @@ var _ = require('underscore');
var RedisPool = require('redis-mpool'); var RedisPool = require('redis-mpool');
var cartodbRedis = require('cartodb-redis'); var cartodbRedis = require('cartodb-redis');
var PgConnection = require('../../../lib/cartodb/backends/pg_connection'); 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'); var TemplateMaps = require('../../../lib/cartodb/backends/template_maps');
const cleanUpQueryParamsMiddleware = require('../../../lib/cartodb/routers/middlewares/clean-up-query-params'); const cleanUpQueryParamsMiddleware = require('../../../lib/cartodb/api/middlewares/clean-up-query-params');
const authorizeMiddleware = require('../../../lib/cartodb/routers/middlewares/authorize'); const authorizeMiddleware = require('../../../lib/cartodb/api/middlewares/authorize');
const dbConnSetupMiddleware = require('../../../lib/cartodb/routers/middlewares/db-conn-setup'); const dbConnSetupMiddleware = require('../../../lib/cartodb/api/middlewares/db-conn-setup');
const credentialsMiddleware = require('../../../lib/cartodb/routers/middlewares/credentials'); const credentialsMiddleware = require('../../../lib/cartodb/api/middlewares/credentials');
var windshaft = require('windshaft'); var windshaft = require('windshaft');