diff --git a/NEWS.md b/NEWS.md index 3be0d437..058c65bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,16 @@ # Changelog +## 8.0.0 +Released 2019-mm-dd + +Breaking changes: +- Schema change for "routes" in configuration file, each "router" is now an array instead of an object. See [`dd06de2`](https://github.com/CartoDB/Windshaft-cartodb/pull/1126/commits/dd06de2632661e19d64c9fbc2be0ba1a8059f54c) for more details. + +Announcements: + +- Added mechanism to inject custom middlewares through configuration. +- Stop requiring unused config properties: "base_url", "base_url_mapconfig", and "base_url_templated". + ## 7.2.0 Released 2019-09-30 diff --git a/README.md b/README.md index 79a17cbd..f6f0bdde 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Create the config/environments/.js files (there are .example files to start from). You can optionally use the ./configure script for this, see ```./configure --help``` to see available options. -Look at lib/cartodb/server_options.js for more on config +Look at lib/cartodb/server-options.js for more on config Upgrading --------- diff --git a/app.js b/app.js index 2f9bff99..e8cd445b 100755 --- a/app.js +++ b/app.js @@ -6,7 +6,7 @@ var path = require('path'); var fs = require('fs'); var _ = require('underscore'); var semver = require('semver'); -const setICUEnvVariable = require('./lib/cartodb/utils/icu_data_env_setter'); +const setICUEnvVariable = require('./lib/utils/icu-data-env-setter'); // jshint undef:false var log = console.log.bind(console); @@ -24,12 +24,12 @@ if (!semver.satisfies(nodejsVersion, engines.node)) { setICUEnvVariable(); var argv = require('yargs') - .usage('Usage: $0 [options]') + .usage('Usage: node $0 [options]') .help('h') .example( - '$0 production -c /etc/sql-api/config.js', - 'start server in production environment with /etc/sql-api/config.js as config file' -) + 'node $0 production -c /etc/windshaft-cartodb/config.js', + 'start server in production environment with /etc/windshaft-cartodb/config.js as config file' + ) .alias('h', 'help') .alias('c', 'config') .nargs('c', 1) @@ -105,8 +105,8 @@ global.logger = global.log4js.getLogger(); // Include cartodb_windshaft only _after_ the "global" variable is set // See https://github.com/Vizzuality/Windshaft-cartodb/issues/28 -var cartodbWindshaft = require('./lib/cartodb/server'); -var serverOptions = require('./lib/cartodb/server_options'); +var cartodbWindshaft = require('./lib/server'); +var serverOptions = require('./lib/server-options'); var server = cartodbWindshaft(serverOptions); diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 68737330..91ff546c 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -16,47 +16,41 @@ var config = { // Base URLs for the APIs // // See https://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API + // + // Note: each entry corresponds with an express' router. + // You must define at least one path. However, middlewares are optional. ,routes: { - v1: { + api: [{ paths: [ '/api/v1', '/user/:user/api/v1', ], - // Base url for the Detached Maps API - // "/api/v1/map" is the new API, - map: { - paths: [ - '/map', - ] - }, - // Base url for the Templated Maps API - // "/api/v1/map/named" is the new API, - template: { - paths: [ - '/map/named' - ] - } - }, - // For compatibility with versions up to 1.6.x - v0: { - paths: [ - '/tiles' + // Optional: attach middlewares at the begining of the router + // to perform custom operations. + middlewares: [ + function noop () { + return function noopMiddleware (req, res, next) { + next(); + } + } ], // Base url for the Detached Maps API - // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - map: { + // "/api/v1/map" is the new API, + map: [{ paths: [ - '/layergroup' - ] - }, + '/map', + ], + middlewares: [] // Optional + }], // Base url for the Templated Maps API - // "/tiles/template" is for compatibility with versions up to 1.6.x - template: { + // "/api/v1/map/named" is the new API, + template: [{ paths: [ - '/template' - ] - } - } + '/map/named' + ], + middlewares: [] // Optional + }] + }] } // Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status. diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 5e8ab271..3e75a897 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -16,47 +16,41 @@ var config = { // Base URLs for the APIs // // See https://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API + // + // Note: each entry corresponds with an express' router. + // You must define at least one path. However, middlewares are optional. ,routes: { - v1: { + api: [{ paths: [ '/api/v1', '/user/:user/api/v1', ], - // Base url for the Detached Maps API - // "/api/v1/map" is the new API, - map: { - paths: [ - '/map', - ] - }, - // Base url for the Templated Maps API - // "/api/v1/map/named" is the new API, - template: { - paths: [ - '/map/named' - ] - } - }, - // For compatibility with versions up to 1.6.x - v0: { - paths: [ - '/tiles' + // Optional: attach middlewares at the begining of the router + // to perform custom operations. + middlewares: [ + function noop () { + return function noopMiddleware (req, res, next) { + next(); + } + } ], // Base url for the Detached Maps API - // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - map: { + // "/api/v1/map" is the new API, + map: [{ paths: [ - '/layergroup' - ] - }, + '/map', + ], + middlewares: [] // Optional + }], // Base url for the Templated Maps API - // "/tiles/template" is for compatibility with versions up to 1.6.x - template: { + // "/api/v1/map/named" is the new API, + template: [{ paths: [ - '/template' - ] - } - } + '/map/named' + ], + middlewares: [] // Optional + }] + }] } // Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status. diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 4741fd74..49e08ac7 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -16,47 +16,41 @@ var config = { // Base URLs for the APIs // // See https://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API + // + // Note: each entry corresponds with an express' router. + // You must define at least one path. However, middlewares are optional. ,routes: { - v1: { + api: [{ paths: [ '/api/v1', '/user/:user/api/v1', ], - // Base url for the Detached Maps API - // "/api/v1/map" is the new API, - map: { - paths: [ - '/map', - ] - }, - // Base url for the Templated Maps API - // "/api/v1/map/named" is the new API, - template: { - paths: [ - '/map/named' - ] - } - }, - // For compatibility with versions up to 1.6.x - v0: { - paths: [ - '/tiles' + // Optional: attach middlewares at the begining of the router + // to perform custom operations. + middlewares: [ + function noop () { + return function noopMiddleware (req, res, next) { + next(); + } + } ], // Base url for the Detached Maps API - // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - map: { + // "/api/v1/map" is the new API, + map: [{ paths: [ - '/layergroup' - ] - }, + '/map', + ], + middlewares: [] // Optional + }], // Base url for the Templated Maps API - // "/tiles/template" is for compatibility with versions up to 1.6.x - template: { + // "/api/v1/map/named" is the new API, + template: [{ paths: [ - '/template' - ] - } - } + '/map/named' + ], + middlewares: [] // Optional + }] + }] } // Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status. diff --git a/config/environments/test.js.example b/config/environments/test.js.example index fae21737..04797ae9 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -16,47 +16,41 @@ var config = { // Base URLs for the APIs // // See https://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API + // + // Note: each entry corresponds with an express' router. + // You must define at least one path. However, middlewares are optional. ,routes: { - v1: { + api: [{ paths: [ '/api/v1', '/user/:user/api/v1', ], - // Base url for the Detached Maps API - // "/api/v1/map" is the new API, - map: { - paths: [ - '/map', - ] - }, - // Base url for the Templated Maps API - // "/api/v1/map/named" is the new API, - template: { - paths: [ - '/map/named' - ] - } - }, - // For compatibility with versions up to 1.6.x - v0: { - paths: [ - '/tiles' + // Optional: attach middlewares at the begining of the router + // to perform custom operations. + middlewares: [ + function noop () { + return function noopMiddleware (req, res, next) { + next(); + } + } ], // Base url for the Detached Maps API - // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - map: { + // "/api/v1/map" is the new API, + map: [{ paths: [ - '/layergroup' - ] - }, + '/map', + ], + middlewares: [] // Optional + }], // Base url for the Templated Maps API - // "/tiles/template" is for compatibility with versions up to 1.6.x - template: { + // "/api/v1/map/named" is the new API, + template: [{ paths: [ - '/template' - ] - } - } + '/map/named' + ], + middlewares: [] // Optional + }] + }] } // Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status. diff --git a/lib/cartodb/api/api-router.js b/lib/api/api-router.js similarity index 93% rename from lib/cartodb/api/api-router.js rename to lib/api/api-router.js index fb62aa46..9349a515 100644 --- a/lib/cartodb/api/api-router.js +++ b/lib/api/api-router.js @@ -7,12 +7,12 @@ const cartodbRedis = require('cartodb-redis'); const windshaft = require('windshaft'); -const PgConnection = require('../backends/pg_connection'); +const PgConnection = require('../backends/pg-connection'); const AnalysisBackend = require('../backends/analysis'); const AnalysisStatusBackend = require('../backends/analysis-status'); const DataviewBackend = require('../backends/dataview'); -const TemplateMaps = require('../backends/template_maps.js'); -const PgQueryRunner = require('../backends/pg_query_runner'); +const TemplateMaps = require('../backends/template-maps'); +const PgQueryRunner = require('../backends/pg-query-runner'); const StatsBackend = require('../backends/stats'); const AuthBackend = require('../backends/auth'); @@ -23,12 +23,12 @@ const TablesExtentBackend = require('../backends/tables-extent'); const ClusterBackend = require('../backends/cluster'); -const LayergroupAffectedTablesCache = require('../cache/layergroup_affected_tables'); -const SurrogateKeysCache = require('../cache/surrogate_keys_cache'); -const VarnishHttpCacheBackend = require('../cache/backend/varnish_http'); +const LayergroupAffectedTablesCache = require('../cache/layergroup-affected-tables'); +const SurrogateKeysCache = require('../cache/surrogate-keys-cache'); +const VarnishHttpCacheBackend = require('../cache/backend/varnish-http'); const FastlyCacheBackend = require('../cache/backend/fastly'); -const NamedMapProviderCache = require('../cache/named_map_provider_cache'); -const NamedMapsCacheEntry = require('../cache/model/named_maps_entry'); +const NamedMapProviderCache = require('../cache/named-map-provider-cache'); +const NamedMapsCacheEntry = require('../cache/model/named-maps-entry'); const NamedMapProviderReporter = require('../stats/reporter/named-map-provider'); const SqlWrapMapConfigAdapter = require('../models/mapconfig/adapter/sql-wrap-mapconfig-adapter'); @@ -196,16 +196,17 @@ module.exports = class ApiRouter { this.templateRouter = new TemplateRouter({ collaborators }); } - register (app) { + route (app, routes) { // FIXME: we need a better way to reset cache while running tests if (process.env.NODE_ENV === 'test') { app.layergroupAffectedTablesCache = this.layergroupAffectedTablesCache; } - Object.keys(this.serverOptions.routes).forEach(apiVersion => { - const routes = this.serverOptions.routes[apiVersion]; - + routes.forEach(route => { const apiRouter = router({ mergeParams: true }); + const { paths, middlewares = [] } = route; + + middlewares.forEach(middleware => apiRouter.use(middleware())); apiRouter.use(logger(this.serverOptions)); apiRouter.use(initializeStatusCode()); @@ -219,16 +220,14 @@ module.exports = class ApiRouter { apiRouter.use(cors()); apiRouter.use(user()); - this.templateRouter.register(apiRouter, routes.template.paths); - this.mapRouter.register(apiRouter, routes.map.paths); + this.templateRouter.route(apiRouter, route.template); + this.mapRouter.route(apiRouter, route.map); apiRouter.use(sendResponse()); apiRouter.use(syntaxError()); apiRouter.use(errorMiddleware()); - const apiPaths = routes.paths; - - apiPaths.forEach(path => app.use(path, apiRouter)); + paths.forEach(path => app.use(path, apiRouter)); }); } }; @@ -283,7 +282,7 @@ function createSurrogateKeysCacheBackends(serverOptions) { return cacheBackends; } -const timeoutErrorTilePath = __dirname + '/../../../assets/render-timeout-fallback.png'; +const timeoutErrorTilePath = __dirname + '/../../assets/render-timeout-fallback.png'; const timeoutErrorTile = require('fs').readFileSync(timeoutErrorTilePath, {encoding: null}); function createRendererFactory ({ redisPool, serverOptions, environmentOptions }) { diff --git a/lib/cartodb/api/map/analyses-catalog-controller.js b/lib/api/map/analyses-catalog-controller.js similarity index 99% rename from lib/cartodb/api/map/analyses-catalog-controller.js rename to lib/api/map/analyses-catalog-controller.js index f7f66346..8c75af63 100644 --- a/lib/cartodb/api/map/analyses-catalog-controller.js +++ b/lib/api/map/analyses-catalog-controller.js @@ -17,7 +17,7 @@ module.exports = class AnalysesController { this.userLimitsBackend = userLimitsBackend; } - register (mapRouter) { + route (mapRouter) { mapRouter.get('/analyses/catalog', this.middlewares()); } diff --git a/lib/cartodb/api/map/analysis-layergroup-controller.js b/lib/api/map/analysis-layergroup-controller.js similarity index 98% rename from lib/cartodb/api/map/analysis-layergroup-controller.js rename to lib/api/map/analysis-layergroup-controller.js index 0375d9ed..fe51e607 100644 --- a/lib/cartodb/api/map/analysis-layergroup-controller.js +++ b/lib/api/map/analysis-layergroup-controller.js @@ -17,7 +17,7 @@ module.exports = class AnalysisLayergroupController { this.authBackend = authBackend; } - register (mapRouter) { + route (mapRouter) { mapRouter.get('/:token/analysis/node/:nodeId', this.middlewares()); } diff --git a/lib/cartodb/api/map/anonymous-map-controller.js b/lib/api/map/anonymous-map-controller.js similarity index 99% rename from lib/cartodb/api/map/anonymous-map-controller.js rename to lib/api/map/anonymous-map-controller.js index ef47f5b6..32707b03 100644 --- a/lib/cartodb/api/map/anonymous-map-controller.js +++ b/lib/api/map/anonymous-map-controller.js @@ -64,7 +64,7 @@ module.exports = class AnonymousMapController { this.layergroupMetadata = layergroupMetadata; } - register (mapRouter) { + route (mapRouter) { mapRouter.options('/'); mapRouter.get('/', this.middlewares()); mapRouter.post('/', this.middlewares()); diff --git a/lib/cartodb/api/map/attributes-layergroup-controller.js b/lib/api/map/attributes-layergroup-controller.js similarity index 99% rename from lib/cartodb/api/map/attributes-layergroup-controller.js rename to lib/api/map/attributes-layergroup-controller.js index 9ab394d7..a9a26ada 100644 --- a/lib/cartodb/api/map/attributes-layergroup-controller.js +++ b/lib/api/map/attributes-layergroup-controller.js @@ -32,7 +32,7 @@ module.exports = class AttributesLayergroupController { this.surrogateKeysCache = surrogateKeysCache; } - register (mapRouter) { + route (mapRouter) { mapRouter.get('/:token/:layer/attributes/:fid', this.middlewares()); } diff --git a/lib/cartodb/api/map/clustered-features-layergroup-controller.js b/lib/api/map/clustered-features-layergroup-controller.js similarity index 99% rename from lib/cartodb/api/map/clustered-features-layergroup-controller.js rename to lib/api/map/clustered-features-layergroup-controller.js index 5c17c5b1..573436d8 100644 --- a/lib/cartodb/api/map/clustered-features-layergroup-controller.js +++ b/lib/api/map/clustered-features-layergroup-controller.js @@ -32,7 +32,7 @@ module.exports = class AggregatedFeaturesLayergroupController { this.surrogateKeysCache = surrogateKeysCache; } - register (mapRouter) { + route (mapRouter) { mapRouter.get('/:token/:layer/:z/cluster/:clusterId', this.middlewares()); } diff --git a/lib/cartodb/api/map/dataview-layergroup-controller.js b/lib/api/map/dataview-layergroup-controller.js similarity index 99% rename from lib/cartodb/api/map/dataview-layergroup-controller.js rename to lib/api/map/dataview-layergroup-controller.js index d82556b8..234e6106 100644 --- a/lib/cartodb/api/map/dataview-layergroup-controller.js +++ b/lib/api/map/dataview-layergroup-controller.js @@ -47,7 +47,7 @@ module.exports = class DataviewLayergroupController { this.surrogateKeysCache = surrogateKeysCache; } - register (mapRouter) { + route (mapRouter) { // Undocumented/non-supported API endpoint methods. // Use at your own peril. diff --git a/lib/cartodb/api/map/map-router.js b/lib/api/map/map-router.js similarity index 83% rename from lib/cartodb/api/map/map-router.js rename to lib/api/map/map-router.js index 8fb7b8b2..c5070627 100644 --- a/lib/cartodb/api/map/map-router.js +++ b/lib/api/map/map-router.js @@ -126,19 +126,25 @@ module.exports = class MapRouter { ); } - register (apiRouter, mapPaths) { + route (apiRouter, routes) { const mapRouter = router({ mergeParams: true }); - this.analysisLayergroupController.register(mapRouter); - this.attributesLayergroupController.register(mapRouter); - this.dataviewLayergroupController.register(mapRouter); - this.previewLayergroupController.register(mapRouter); - this.tileLayergroupController.register(mapRouter); - this.anonymousMapController.register(mapRouter); - this.previewTemplateController.register(mapRouter); - this.analysesController.register(mapRouter); - this.clusteredFeaturesLayergroupController.register(mapRouter); + routes.forEach(route => { + const { paths, middlewares = [] } = route; - mapPaths.forEach(path => apiRouter.use(path, mapRouter)); + middlewares.forEach(middleware => mapRouter.use(middleware())); + + this.analysisLayergroupController.route(mapRouter); + this.attributesLayergroupController.route(mapRouter); + this.dataviewLayergroupController.route(mapRouter); + this.previewLayergroupController.route(mapRouter); + this.tileLayergroupController.route(mapRouter); + this.anonymousMapController.route(mapRouter); + this.previewTemplateController.route(mapRouter); + this.analysesController.route(mapRouter); + this.clusteredFeaturesLayergroupController.route(mapRouter); + + paths.forEach(path => apiRouter.use(path, mapRouter)); + }); } }; diff --git a/lib/cartodb/api/map/preview-layergroup-controller.js b/lib/api/map/preview-layergroup-controller.js similarity index 99% rename from lib/cartodb/api/map/preview-layergroup-controller.js rename to lib/api/map/preview-layergroup-controller.js index f8980866..698d94ff 100644 --- a/lib/cartodb/api/map/preview-layergroup-controller.js +++ b/lib/api/map/preview-layergroup-controller.js @@ -35,7 +35,7 @@ module.exports = class PreviewLayergroupController { this.surrogateKeysCache = surrogateKeysCache; } - register (mapRouter) { + route (mapRouter) { mapRouter.get('/static/center/:token/:z/:lat/:lng/:width/:height.:format', this.middlewares({ validateZoom: true, previewType: 'centered' diff --git a/lib/cartodb/api/map/preview-template-controller.js b/lib/api/map/preview-template-controller.js similarity index 99% rename from lib/cartodb/api/map/preview-template-controller.js rename to lib/api/map/preview-template-controller.js index e4f42cae..e4c0beed 100644 --- a/lib/cartodb/api/map/preview-template-controller.js +++ b/lib/api/map/preview-template-controller.js @@ -46,7 +46,7 @@ module.exports = class PreviewTemplateController { this.userLimitsBackend = userLimitsBackend; } - register (mapRouter) { + route (mapRouter) { mapRouter.get('/static/named/:template_id/:width/:height.:format', this.middlewares()); } diff --git a/lib/cartodb/api/map/tile-layergroup-controller.js b/lib/api/map/tile-layergroup-controller.js similarity index 99% rename from lib/cartodb/api/map/tile-layergroup-controller.js rename to lib/api/map/tile-layergroup-controller.js index 422fa8b6..18fe23be 100644 --- a/lib/cartodb/api/map/tile-layergroup-controller.js +++ b/lib/api/map/tile-layergroup-controller.js @@ -43,7 +43,7 @@ module.exports = class TileLayergroupController { this.surrogateKeysCache = surrogateKeysCache; } - register (mapRouter) { + route (mapRouter) { // REGEXP: doesn't match with `val` const not = (val) => `(?!${val})([^\/]+?)`; diff --git a/lib/cartodb/api/middlewares/augment-layergroup-data.js b/lib/api/middlewares/augment-layergroup-data.js similarity index 100% rename from lib/cartodb/api/middlewares/augment-layergroup-data.js rename to lib/api/middlewares/augment-layergroup-data.js diff --git a/lib/cartodb/api/middlewares/authorize.js b/lib/api/middlewares/authorize.js similarity index 100% rename from lib/cartodb/api/middlewares/authorize.js rename to lib/api/middlewares/authorize.js diff --git a/lib/cartodb/api/middlewares/cache-channel-header.js b/lib/api/middlewares/cache-channel-header.js similarity index 100% rename from lib/cartodb/api/middlewares/cache-channel-header.js rename to lib/api/middlewares/cache-channel-header.js diff --git a/lib/cartodb/api/middlewares/cache-control-header.js b/lib/api/middlewares/cache-control-header.js similarity index 100% rename from lib/cartodb/api/middlewares/cache-control-header.js rename to lib/api/middlewares/cache-control-header.js diff --git a/lib/cartodb/api/middlewares/check-json-content-type.js b/lib/api/middlewares/check-json-content-type.js similarity index 100% rename from lib/cartodb/api/middlewares/check-json-content-type.js rename to lib/api/middlewares/check-json-content-type.js diff --git a/lib/cartodb/api/middlewares/check-static-image-format.js b/lib/api/middlewares/check-static-image-format.js similarity index 100% rename from lib/cartodb/api/middlewares/check-static-image-format.js rename to lib/api/middlewares/check-static-image-format.js diff --git a/lib/cartodb/api/middlewares/clean-up-query-params.js b/lib/api/middlewares/clean-up-query-params.js similarity index 100% rename from lib/cartodb/api/middlewares/clean-up-query-params.js rename to lib/api/middlewares/clean-up-query-params.js diff --git a/lib/cartodb/api/middlewares/coordinates.js b/lib/api/middlewares/coordinates.js similarity index 100% rename from lib/cartodb/api/middlewares/coordinates.js rename to lib/api/middlewares/coordinates.js diff --git a/lib/cartodb/api/middlewares/cors.js b/lib/api/middlewares/cors.js similarity index 100% rename from lib/cartodb/api/middlewares/cors.js rename to lib/api/middlewares/cors.js diff --git a/lib/cartodb/api/middlewares/credentials.js b/lib/api/middlewares/credentials.js similarity index 100% rename from lib/cartodb/api/middlewares/credentials.js rename to lib/api/middlewares/credentials.js diff --git a/lib/cartodb/api/middlewares/db-conn-setup.js b/lib/api/middlewares/db-conn-setup.js similarity index 100% rename from lib/cartodb/api/middlewares/db-conn-setup.js rename to lib/api/middlewares/db-conn-setup.js diff --git a/lib/cartodb/api/middlewares/error-middleware.js b/lib/api/middlewares/error-middleware.js similarity index 100% rename from lib/cartodb/api/middlewares/error-middleware.js rename to lib/api/middlewares/error-middleware.js diff --git a/lib/cartodb/api/middlewares/increment-map-view-count.js b/lib/api/middlewares/increment-map-view-count.js similarity index 100% rename from lib/cartodb/api/middlewares/increment-map-view-count.js rename to lib/api/middlewares/increment-map-view-count.js diff --git a/lib/cartodb/api/middlewares/init-profiler.js b/lib/api/middlewares/init-profiler.js similarity index 100% rename from lib/cartodb/api/middlewares/init-profiler.js rename to lib/api/middlewares/init-profiler.js diff --git a/lib/cartodb/api/middlewares/initialize-status-code.js b/lib/api/middlewares/initialize-status-code.js similarity index 100% rename from lib/cartodb/api/middlewares/initialize-status-code.js rename to lib/api/middlewares/initialize-status-code.js diff --git a/lib/cartodb/api/middlewares/last-modified-header.js b/lib/api/middlewares/last-modified-header.js similarity index 100% rename from lib/cartodb/api/middlewares/last-modified-header.js rename to lib/api/middlewares/last-modified-header.js diff --git a/lib/cartodb/api/middlewares/last-updated-time-layergroup.js b/lib/api/middlewares/last-updated-time-layergroup.js similarity index 100% rename from lib/cartodb/api/middlewares/last-updated-time-layergroup.js rename to lib/api/middlewares/last-updated-time-layergroup.js diff --git a/lib/cartodb/api/middlewares/layer-stats.js b/lib/api/middlewares/layer-stats.js similarity index 100% rename from lib/cartodb/api/middlewares/layer-stats.js rename to lib/api/middlewares/layer-stats.js diff --git a/lib/cartodb/api/middlewares/layergroup-id-header.js b/lib/api/middlewares/layergroup-id-header.js similarity index 100% rename from lib/cartodb/api/middlewares/layergroup-id-header.js rename to lib/api/middlewares/layergroup-id-header.js diff --git a/lib/cartodb/api/middlewares/layergroup-metadata.js b/lib/api/middlewares/layergroup-metadata.js similarity index 100% rename from lib/cartodb/api/middlewares/layergroup-metadata.js rename to lib/api/middlewares/layergroup-metadata.js diff --git a/lib/cartodb/api/middlewares/layergroup-token.js b/lib/api/middlewares/layergroup-token.js similarity index 100% rename from lib/cartodb/api/middlewares/layergroup-token.js rename to lib/api/middlewares/layergroup-token.js diff --git a/lib/cartodb/api/middlewares/logger.js b/lib/api/middlewares/logger.js similarity index 100% rename from lib/cartodb/api/middlewares/logger.js rename to lib/api/middlewares/logger.js diff --git a/lib/cartodb/api/middlewares/lzma.js b/lib/api/middlewares/lzma.js similarity index 100% rename from lib/cartodb/api/middlewares/lzma.js rename to lib/api/middlewares/lzma.js diff --git a/lib/cartodb/api/middlewares/map-error.js b/lib/api/middlewares/map-error.js similarity index 100% rename from lib/cartodb/api/middlewares/map-error.js rename to lib/api/middlewares/map-error.js diff --git a/lib/cartodb/api/middlewares/map-store-map-config-provider.js b/lib/api/middlewares/map-store-map-config-provider.js similarity index 100% rename from lib/cartodb/api/middlewares/map-store-map-config-provider.js rename to lib/api/middlewares/map-store-map-config-provider.js diff --git a/lib/cartodb/api/middlewares/named-map-provider.js b/lib/api/middlewares/named-map-provider.js similarity index 100% rename from lib/cartodb/api/middlewares/named-map-provider.js rename to lib/api/middlewares/named-map-provider.js diff --git a/lib/cartodb/api/middlewares/noop.js b/lib/api/middlewares/noop.js similarity index 100% rename from lib/cartodb/api/middlewares/noop.js rename to lib/api/middlewares/noop.js diff --git a/lib/cartodb/api/middlewares/rate-limit.js b/lib/api/middlewares/rate-limit.js similarity index 100% rename from lib/cartodb/api/middlewares/rate-limit.js rename to lib/api/middlewares/rate-limit.js diff --git a/lib/cartodb/api/middlewares/send-response.js b/lib/api/middlewares/send-response.js similarity index 100% rename from lib/cartodb/api/middlewares/send-response.js rename to lib/api/middlewares/send-response.js diff --git a/lib/cartodb/api/middlewares/served-by-host-header.js b/lib/api/middlewares/served-by-host-header.js similarity index 100% rename from lib/cartodb/api/middlewares/served-by-host-header.js rename to lib/api/middlewares/served-by-host-header.js diff --git a/lib/cartodb/api/middlewares/stats.js b/lib/api/middlewares/stats.js similarity index 93% rename from lib/cartodb/api/middlewares/stats.js rename to lib/api/middlewares/stats.js index 51dbdf53..24facbcf 100644 --- a/lib/cartodb/api/middlewares/stats.js +++ b/lib/api/middlewares/stats.js @@ -1,6 +1,6 @@ 'use strict'; -const Profiler = require('../../stats/profiler_proxy'); +const Profiler = require('../../stats/profiler-proxy'); const debug = require('debug')('windshaft:cartodb:stats'); const onHeaders = require('on-headers'); diff --git a/lib/cartodb/api/middlewares/surrogate-key-header.js b/lib/api/middlewares/surrogate-key-header.js similarity index 93% rename from lib/cartodb/api/middlewares/surrogate-key-header.js rename to lib/api/middlewares/surrogate-key-header.js index f616b009..b4b6c922 100644 --- a/lib/cartodb/api/middlewares/surrogate-key-header.js +++ b/lib/api/middlewares/surrogate-key-header.js @@ -1,6 +1,6 @@ 'use strict'; -const NamedMapsCacheEntry = require('../../cache/model/named_maps_entry'); +const NamedMapsCacheEntry = require('../../cache/model/named-maps-entry'); const NamedMapMapConfigProvider = require('../../models/mapconfig/provider/named-map-provider'); module.exports = function setSurrogateKeyHeader ({ surrogateKeysCache }) { diff --git a/lib/cartodb/api/middlewares/syntax-error.js b/lib/api/middlewares/syntax-error.js similarity index 100% rename from lib/cartodb/api/middlewares/syntax-error.js rename to lib/api/middlewares/syntax-error.js diff --git a/lib/cartodb/api/middlewares/user.js b/lib/api/middlewares/user.js similarity index 80% rename from lib/cartodb/api/middlewares/user.js rename to lib/api/middlewares/user.js index 4dda75e7..17a85260 100644 --- a/lib/cartodb/api/middlewares/user.js +++ b/lib/api/middlewares/user.js @@ -1,6 +1,6 @@ 'use strict'; -const CdbRequest = require('../../models/cdb_request'); +const CdbRequest = require('../../models/cdb-request'); module.exports = function user () { const cdbRequest = new CdbRequest(); diff --git a/lib/cartodb/api/middlewares/vector-error.js b/lib/api/middlewares/vector-error.js similarity index 95% rename from lib/cartodb/api/middlewares/vector-error.js rename to lib/api/middlewares/vector-error.js index 4de1ebce..6e69f982 100644 --- a/lib/cartodb/api/middlewares/vector-error.js +++ b/lib/api/middlewares/vector-error.js @@ -1,7 +1,7 @@ 'use strict'; const fs = require('fs'); -const timeoutErrorVectorTile = fs.readFileSync(__dirname + '/../../../../assets/render-timeout-fallback.mvt'); +const timeoutErrorVectorTile = fs.readFileSync(__dirname + '/../../../assets/render-timeout-fallback.mvt'); module.exports = function vectorError() { return function vectorErrorMiddleware(err, req, res, next) { diff --git a/lib/cartodb/api/template/admin-template-controller.js b/lib/api/template/admin-template-controller.js similarity index 98% rename from lib/cartodb/api/template/admin-template-controller.js rename to lib/api/template/admin-template-controller.js index c8d2ba97..082d4f34 100644 --- a/lib/cartodb/api/template/admin-template-controller.js +++ b/lib/api/template/admin-template-controller.js @@ -1,6 +1,6 @@ 'use strict'; -const { templateName } = require('../../backends/template_maps'); +const { templateName } = require('../../backends/template-maps'); const credentials = require('../middlewares/credentials'); const rateLimit = require('../middlewares/rate-limit'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; @@ -18,7 +18,7 @@ module.exports = class AdminTemplateController { this.userLimitsBackend = userLimitsBackend; } - register (templateRouter) { + route (templateRouter) { templateRouter.options(`/:template_id`); templateRouter.post('/', this.middlewares({ diff --git a/lib/cartodb/api/template/named-template-controller.js b/lib/api/template/named-template-controller.js similarity index 99% rename from lib/cartodb/api/template/named-template-controller.js rename to lib/api/template/named-template-controller.js index b28143dd..7a7ee9d2 100644 --- a/lib/cartodb/api/template/named-template-controller.js +++ b/lib/api/template/named-template-controller.js @@ -63,7 +63,7 @@ module.exports = class NamedMapController { this.layergroupMetadata = layergroupMetadata; } - register (templateRouter) { + route (templateRouter) { templateRouter.get('/:template_id/jsonp', this.middlewares()); templateRouter.post('/:template_id', this.middlewares()); } diff --git a/lib/cartodb/api/template/template-router.js b/lib/api/template/template-router.js similarity index 77% rename from lib/cartodb/api/template/template-router.js rename to lib/api/template/template-router.js index 0299679d..ecdc9802 100644 --- a/lib/cartodb/api/template/template-router.js +++ b/lib/api/template/template-router.js @@ -54,13 +54,19 @@ module.exports = class TemplateRouter { ); } - register (apiRouter, templatePaths) { + route (apiRouter, routes) { const templateRouter = router({ mergeParams: true }); - this.namedMapController.register(templateRouter); - this.tileTemplateController.register(templateRouter); - this.adminTemplateController.register(templateRouter); + routes.forEach(route => { + const { paths, middlewares = [] } = route; - templatePaths.forEach(path => apiRouter.use(path, templateRouter)); + middlewares.forEach(middleware => templateRouter.use(middleware())); + + this.namedMapController.route(templateRouter); + this.tileTemplateController.route(templateRouter); + this.adminTemplateController.route(templateRouter); + + paths.forEach(path => apiRouter.use(path, templateRouter)); + }); } }; diff --git a/lib/cartodb/api/template/tile-template-controller.js b/lib/api/template/tile-template-controller.js similarity index 99% rename from lib/cartodb/api/template/tile-template-controller.js rename to lib/api/template/tile-template-controller.js index daf751e6..90904027 100644 --- a/lib/cartodb/api/template/tile-template-controller.js +++ b/lib/api/template/tile-template-controller.js @@ -31,7 +31,7 @@ module.exports = class TileTemplateController { this.userLimitsBackend = userLimitsBackend; } - register (templateRouter) { + route (templateRouter) { templateRouter.get('/:template_id/:layer/:z/:x/:y.(:format)', this.middlewares()); } diff --git a/lib/cartodb/backends/analysis-status.js b/lib/backends/analysis-status.js similarity index 100% rename from lib/cartodb/backends/analysis-status.js rename to lib/backends/analysis-status.js diff --git a/lib/cartodb/backends/analysis.js b/lib/backends/analysis.js similarity index 100% rename from lib/cartodb/backends/analysis.js rename to lib/backends/analysis.js diff --git a/lib/cartodb/backends/auth.js b/lib/backends/auth.js similarity index 100% rename from lib/cartodb/backends/auth.js rename to lib/backends/auth.js diff --git a/lib/cartodb/backends/cluster.js b/lib/backends/cluster.js similarity index 100% rename from lib/cartodb/backends/cluster.js rename to lib/backends/cluster.js diff --git a/lib/cartodb/backends/dataview.js b/lib/backends/dataview.js similarity index 99% rename from lib/cartodb/backends/dataview.js rename to lib/backends/dataview.js index acdf24a7..86ead292 100644 --- a/lib/cartodb/backends/dataview.js +++ b/lib/backends/dataview.js @@ -6,7 +6,7 @@ var BBoxFilter = require('../models/filter/bbox'); var DataviewFactory = require('../models/dataview/factory'); var DataviewFactoryWithOverviews = require('../models/dataview/overviews/factory'); const dbParamsFromReqParams = require('../utils/database-params'); -var OverviewsQueryRewriter = require('../utils/overviews_query_rewriter'); +var OverviewsQueryRewriter = require('../utils/overviews-query-rewriter'); var overviewsQueryRewriter = new OverviewsQueryRewriter({ zoom_level: 'CDB_ZoomFromScale(!scale_denominator!)' }); diff --git a/lib/cartodb/backends/filter-stats.js b/lib/backends/filter-stats.js similarity index 100% rename from lib/cartodb/backends/filter-stats.js rename to lib/backends/filter-stats.js diff --git a/lib/cartodb/backends/layer-stats/empty-layer-stats.js b/lib/backends/layer-stats/empty-layer-stats.js similarity index 100% rename from lib/cartodb/backends/layer-stats/empty-layer-stats.js rename to lib/backends/layer-stats/empty-layer-stats.js diff --git a/lib/cartodb/backends/layer-stats/factory.js b/lib/backends/layer-stats/factory.js similarity index 100% rename from lib/cartodb/backends/layer-stats/factory.js rename to lib/backends/layer-stats/factory.js diff --git a/lib/cartodb/backends/layer-stats/layer-stats.js b/lib/backends/layer-stats/layer-stats.js similarity index 100% rename from lib/cartodb/backends/layer-stats/layer-stats.js rename to lib/backends/layer-stats/layer-stats.js diff --git a/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js b/lib/backends/layer-stats/mapnik-layer-stats.js similarity index 100% rename from lib/cartodb/backends/layer-stats/mapnik-layer-stats.js rename to lib/backends/layer-stats/mapnik-layer-stats.js diff --git a/lib/cartodb/backends/layer-stats/torque-layer-stats.js b/lib/backends/layer-stats/torque-layer-stats.js similarity index 100% rename from lib/cartodb/backends/layer-stats/torque-layer-stats.js rename to lib/backends/layer-stats/torque-layer-stats.js diff --git a/lib/cartodb/backends/overviews-metadata.js b/lib/backends/overviews-metadata.js similarity index 100% rename from lib/cartodb/backends/overviews-metadata.js rename to lib/backends/overviews-metadata.js diff --git a/lib/cartodb/backends/pg_connection.js b/lib/backends/pg-connection.js similarity index 100% rename from lib/cartodb/backends/pg_connection.js rename to lib/backends/pg-connection.js diff --git a/lib/cartodb/backends/pg_query_runner.js b/lib/backends/pg-query-runner.js similarity index 100% rename from lib/cartodb/backends/pg_query_runner.js rename to lib/backends/pg-query-runner.js diff --git a/lib/cartodb/backends/stats.js b/lib/backends/stats.js similarity index 100% rename from lib/cartodb/backends/stats.js rename to lib/backends/stats.js diff --git a/lib/cartodb/backends/tables-extent.js b/lib/backends/tables-extent.js similarity index 100% rename from lib/cartodb/backends/tables-extent.js rename to lib/backends/tables-extent.js diff --git a/lib/cartodb/backends/template_maps.js b/lib/backends/template-maps.js similarity index 100% rename from lib/cartodb/backends/template_maps.js rename to lib/backends/template-maps.js diff --git a/lib/cartodb/backends/turbo-carto-postgres-datasource.js b/lib/backends/turbo-carto-postgres-datasource.js similarity index 100% rename from lib/cartodb/backends/turbo-carto-postgres-datasource.js rename to lib/backends/turbo-carto-postgres-datasource.js diff --git a/lib/cartodb/backends/user-limits.js b/lib/backends/user-limits.js similarity index 100% rename from lib/cartodb/backends/user-limits.js rename to lib/backends/user-limits.js diff --git a/lib/cartodb/cache/backend/fastly.js b/lib/cache/backend/fastly.js similarity index 100% rename from lib/cartodb/cache/backend/fastly.js rename to lib/cache/backend/fastly.js diff --git a/lib/cartodb/cache/backend/varnish_http.js b/lib/cache/backend/varnish-http.js similarity index 100% rename from lib/cartodb/cache/backend/varnish_http.js rename to lib/cache/backend/varnish-http.js diff --git a/lib/cartodb/cache/layergroup_affected_tables.js b/lib/cache/layergroup-affected-tables.js similarity index 100% rename from lib/cartodb/cache/layergroup_affected_tables.js rename to lib/cache/layergroup-affected-tables.js diff --git a/lib/cartodb/cache/model/named_maps_entry.js b/lib/cache/model/named-maps-entry.js similarity index 100% rename from lib/cartodb/cache/model/named_maps_entry.js rename to lib/cache/model/named-maps-entry.js diff --git a/lib/cartodb/cache/named_map_provider_cache.js b/lib/cache/named-map-provider-cache.js similarity index 97% rename from lib/cartodb/cache/named_map_provider_cache.js rename to lib/cache/named-map-provider-cache.js index ea24f2f5..844a2038 100644 --- a/lib/cartodb/cache/named_map_provider_cache.js +++ b/lib/cache/named-map-provider-cache.js @@ -3,7 +3,7 @@ const LruCache = require('lru-cache'); const NamedMapMapConfigProvider = require('../models/mapconfig/provider/named-map-provider'); -const { templateName } = require('../backends/template_maps'); +const { templateName } = require('../backends/template-maps'); const TEN_MINUTES_IN_MILLISECONDS = 1000 * 60 * 10; const ACTIONS = ['update', 'delete']; diff --git a/lib/cartodb/cache/surrogate_keys_cache.js b/lib/cache/surrogate-keys-cache.js similarity index 100% rename from lib/cartodb/cache/surrogate_keys_cache.js rename to lib/cache/surrogate-keys-cache.js diff --git a/lib/cartodb/models/aggregation/aggregation-mapconfig.js b/lib/models/aggregation/aggregation-mapconfig.js similarity index 100% rename from lib/cartodb/models/aggregation/aggregation-mapconfig.js rename to lib/models/aggregation/aggregation-mapconfig.js diff --git a/lib/cartodb/models/aggregation/aggregation-query.js b/lib/models/aggregation/aggregation-query.js similarity index 100% rename from lib/cartodb/models/aggregation/aggregation-query.js rename to lib/models/aggregation/aggregation-query.js diff --git a/lib/cartodb/models/aggregation/aggregation-validator.js b/lib/models/aggregation/aggregation-validator.js similarity index 100% rename from lib/cartodb/models/aggregation/aggregation-validator.js rename to lib/models/aggregation/aggregation-validator.js diff --git a/lib/cartodb/models/aggregation/time-dimension.js b/lib/models/aggregation/time-dimension.js similarity index 100% rename from lib/cartodb/models/aggregation/time-dimension.js rename to lib/models/aggregation/time-dimension.js diff --git a/lib/cartodb/models/cdb_request.js b/lib/models/cdb-request.js similarity index 100% rename from lib/cartodb/models/cdb_request.js rename to lib/models/cdb-request.js diff --git a/lib/cartodb/models/dataview/aggregation.js b/lib/models/dataview/aggregation.js similarity index 100% rename from lib/cartodb/models/dataview/aggregation.js rename to lib/models/dataview/aggregation.js diff --git a/lib/cartodb/models/dataview/base.js b/lib/models/dataview/base.js similarity index 100% rename from lib/cartodb/models/dataview/base.js rename to lib/models/dataview/base.js diff --git a/lib/cartodb/models/dataview/factory.js b/lib/models/dataview/factory.js similarity index 94% rename from lib/cartodb/models/dataview/factory.js rename to lib/models/dataview/factory.js index 729305fc..bd035270 100644 --- a/lib/cartodb/models/dataview/factory.js +++ b/lib/models/dataview/factory.js @@ -1,6 +1,6 @@ 'use strict'; -const dataviews = require('./'); +const dataviews = require('.'); module.exports = class DataviewFactory { static get dataviews() { diff --git a/lib/cartodb/models/dataview/formula.js b/lib/models/dataview/formula.js similarity index 100% rename from lib/cartodb/models/dataview/formula.js rename to lib/models/dataview/formula.js diff --git a/lib/cartodb/models/dataview/histogram.js b/lib/models/dataview/histogram.js similarity index 100% rename from lib/cartodb/models/dataview/histogram.js rename to lib/models/dataview/histogram.js diff --git a/lib/cartodb/models/dataview/histograms/base-histogram.js b/lib/models/dataview/histograms/base-histogram.js similarity index 100% rename from lib/cartodb/models/dataview/histograms/base-histogram.js rename to lib/models/dataview/histograms/base-histogram.js diff --git a/lib/cartodb/models/dataview/histograms/date-histogram.js b/lib/models/dataview/histograms/date-histogram.js similarity index 100% rename from lib/cartodb/models/dataview/histograms/date-histogram.js rename to lib/models/dataview/histograms/date-histogram.js diff --git a/lib/cartodb/models/dataview/histograms/numeric-histogram.js b/lib/models/dataview/histograms/numeric-histogram.js similarity index 100% rename from lib/cartodb/models/dataview/histograms/numeric-histogram.js rename to lib/models/dataview/histograms/numeric-histogram.js diff --git a/lib/cartodb/models/dataview/index.js b/lib/models/dataview/index.js similarity index 100% rename from lib/cartodb/models/dataview/index.js rename to lib/models/dataview/index.js diff --git a/lib/cartodb/models/dataview/overviews/aggregation.js b/lib/models/dataview/overviews/aggregation.js similarity index 100% rename from lib/cartodb/models/dataview/overviews/aggregation.js rename to lib/models/dataview/overviews/aggregation.js diff --git a/lib/cartodb/models/dataview/overviews/base.js b/lib/models/dataview/overviews/base.js similarity index 100% rename from lib/cartodb/models/dataview/overviews/base.js rename to lib/models/dataview/overviews/base.js diff --git a/lib/cartodb/models/dataview/overviews/factory.js b/lib/models/dataview/overviews/factory.js similarity index 97% rename from lib/cartodb/models/dataview/overviews/factory.js rename to lib/models/dataview/overviews/factory.js index 1a402f88..c67aea8e 100644 --- a/lib/cartodb/models/dataview/overviews/factory.js +++ b/lib/models/dataview/overviews/factory.js @@ -1,7 +1,7 @@ 'use strict'; var parentFactory = require('../factory'); -var dataviews = require('./'); +var dataviews = require('.'); function OverviewsDataviewFactory(queryRewriter, queryRewriteData, options) { this.queryRewriter = queryRewriter; diff --git a/lib/cartodb/models/dataview/overviews/formula.js b/lib/models/dataview/overviews/formula.js similarity index 100% rename from lib/cartodb/models/dataview/overviews/formula.js rename to lib/models/dataview/overviews/formula.js diff --git a/lib/cartodb/models/dataview/overviews/histogram.js b/lib/models/dataview/overviews/histogram.js similarity index 100% rename from lib/cartodb/models/dataview/overviews/histogram.js rename to lib/models/dataview/overviews/histogram.js diff --git a/lib/cartodb/models/dataview/overviews/index.js b/lib/models/dataview/overviews/index.js similarity index 100% rename from lib/cartodb/models/dataview/overviews/index.js rename to lib/models/dataview/overviews/index.js diff --git a/lib/cartodb/models/filter/analysis.js b/lib/models/filter/analysis.js similarity index 100% rename from lib/cartodb/models/filter/analysis.js rename to lib/models/filter/analysis.js diff --git a/lib/cartodb/models/filter/analysis/category.js b/lib/models/filter/analysis/category.js similarity index 100% rename from lib/cartodb/models/filter/analysis/category.js rename to lib/models/filter/analysis/category.js diff --git a/lib/cartodb/models/filter/analysis/range.js b/lib/models/filter/analysis/range.js similarity index 100% rename from lib/cartodb/models/filter/analysis/range.js rename to lib/models/filter/analysis/range.js diff --git a/lib/cartodb/models/filter/bbox.js b/lib/models/filter/bbox.js similarity index 100% rename from lib/cartodb/models/filter/bbox.js rename to lib/models/filter/bbox.js diff --git a/lib/cartodb/models/layergroup-token.js b/lib/models/layergroup-token.js similarity index 100% rename from lib/cartodb/models/layergroup-token.js rename to lib/models/layergroup-token.js diff --git a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js b/lib/models/mapconfig/adapter/aggregation-mapconfig-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js rename to lib/models/mapconfig/adapter/aggregation-mapconfig-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/analysis-mapconfig-adapter.js b/lib/models/mapconfig/adapter/analysis-mapconfig-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/analysis-mapconfig-adapter.js rename to lib/models/mapconfig/adapter/analysis-mapconfig-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/dataviews-widgets-adapter.js b/lib/models/mapconfig/adapter/dataviews-widgets-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/dataviews-widgets-adapter.js rename to lib/models/mapconfig/adapter/dataviews-widgets-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/index.js b/lib/models/mapconfig/adapter/index.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/index.js rename to lib/models/mapconfig/adapter/index.js diff --git a/lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js b/lib/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js rename to lib/models/mapconfig/adapter/mapconfig-buffer-size-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/mapconfig-named-layers-adapter.js b/lib/models/mapconfig/adapter/mapconfig-named-layers-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/mapconfig-named-layers-adapter.js rename to lib/models/mapconfig/adapter/mapconfig-named-layers-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js b/lib/models/mapconfig/adapter/mapconfig-overviews-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter.js rename to lib/models/mapconfig/adapter/mapconfig-overviews-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/sql-wrap-mapconfig-adapter.js b/lib/models/mapconfig/adapter/sql-wrap-mapconfig-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/sql-wrap-mapconfig-adapter.js rename to lib/models/mapconfig/adapter/sql-wrap-mapconfig-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/turbo-carto-adapter.js b/lib/models/mapconfig/adapter/turbo-carto-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/turbo-carto-adapter.js rename to lib/models/mapconfig/adapter/turbo-carto-adapter.js diff --git a/lib/cartodb/models/mapconfig/adapter/vector-mapconfig-adapter.js b/lib/models/mapconfig/adapter/vector-mapconfig-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/adapter/vector-mapconfig-adapter.js rename to lib/models/mapconfig/adapter/vector-mapconfig-adapter.js diff --git a/lib/cartodb/models/mapconfig/provider/base-mapconfig-adapter.js b/lib/models/mapconfig/provider/base-mapconfig-adapter.js similarity index 100% rename from lib/cartodb/models/mapconfig/provider/base-mapconfig-adapter.js rename to lib/models/mapconfig/provider/base-mapconfig-adapter.js diff --git a/lib/cartodb/models/mapconfig/provider/create-layergroup-provider.js b/lib/models/mapconfig/provider/create-layergroup-provider.js similarity index 100% rename from lib/cartodb/models/mapconfig/provider/create-layergroup-provider.js rename to lib/models/mapconfig/provider/create-layergroup-provider.js diff --git a/lib/cartodb/models/mapconfig/provider/map-store-provider.js b/lib/models/mapconfig/provider/map-store-provider.js similarity index 100% rename from lib/cartodb/models/mapconfig/provider/map-store-provider.js rename to lib/models/mapconfig/provider/map-store-provider.js diff --git a/lib/cartodb/models/mapconfig/provider/named-map-provider.js b/lib/models/mapconfig/provider/named-map-provider.js similarity index 99% rename from lib/cartodb/models/mapconfig/provider/named-map-provider.js rename to lib/models/mapconfig/provider/named-map-provider.js index 292e5dcb..4b235986 100644 --- a/lib/cartodb/models/mapconfig/provider/named-map-provider.js +++ b/lib/models/mapconfig/provider/named-map-provider.js @@ -4,7 +4,7 @@ const BaseMapConfigProvider = require('./base-mapconfig-adapter'); const crypto = require('crypto'); const dot = require('dot'); const MapConfig = require('windshaft').model.MapConfig; -const templateName = require('../../../backends/template_maps').templateName; +const templateName = require('../../../backends/template-maps').templateName; // Configure bases for cache keys suitable for string interpolation const baseKey = '{{=it.dbname}}:{{=it.user}}:{{=it.templateName}}'; diff --git a/lib/cartodb/models/resource-locator.js b/lib/models/resource-locator.js similarity index 100% rename from lib/cartodb/models/resource-locator.js rename to lib/models/resource-locator.js diff --git a/lib/cartodb/monitoring/health_check.js b/lib/monitoring/health-check.js similarity index 100% rename from lib/cartodb/monitoring/health_check.js rename to lib/monitoring/health-check.js diff --git a/lib/cartodb/server-info-controller.js b/lib/server-info-controller.js similarity index 91% rename from lib/cartodb/server-info-controller.js rename to lib/server-info-controller.js index d81051cb..fe1f1a19 100644 --- a/lib/cartodb/server-info-controller.js +++ b/lib/server-info-controller.js @@ -1,6 +1,6 @@ 'use strict'; -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"; @@ -14,7 +14,7 @@ function ServerInfoController(versions) { module.exports = ServerInfoController; -ServerInfoController.prototype.register = function(monitorRouter) { +ServerInfoController.prototype.route = function(monitorRouter) { monitorRouter.get('/health', this.health.bind(this)); monitorRouter.get('/', this.welcome.bind(this)); monitorRouter.get('/version', this.version.bind(this)); diff --git a/lib/cartodb/server_options.js b/lib/server-options.js similarity index 66% rename from lib/cartodb/server_options.js rename to lib/server-options.js index 5c9da8c6..5dc7b72d 100644 --- a/lib/cartodb/server_options.js +++ b/lib/server-options.js @@ -2,7 +2,7 @@ const fqdn = require('@carto/fqdn-sync'); var _ = require('underscore'); -var OverviewsQueryRewriter = require('./utils/overviews_query_rewriter'); +var OverviewsQueryRewriter = require('./utils/overviews-query-rewriter'); var rendererConfig = _.defaults(global.environment.renderer || {}, { cache_ttl: 60000, // milliseconds @@ -58,75 +58,57 @@ var analysisConfig = _.defaults(global.environment.analysis || {}, { limits: {} }); +const routesConfig = global.environment.routes || { + api: [{ + paths: [ + '/api/v1', + '/user/:user/api/v1', + ], + // Base url for the Detached Maps API + // "/api/v1/map" is the new API, + map: [{ + paths: [ + '/map', + ] + }], + // Base url for the Templated Maps API + // "/api/v1/map/named" is the new API, + template: [{ + paths: [ + '/map/named' + ] + }] + }] +}; + +if (routesConfig.v1 && !Array.isArray(routesConfig.v1)) { + routesConfig.api = [ routesConfig.v1 ]; + delete routesConfig.v1; +} + +if (routesConfig.api && !Array.isArray(routesConfig.api)) { + routesConfig.api = [ routesConfig.api ]; +} + +routesConfig.api.forEach(route => { + if (!Array.isArray(route.map)) { + route.map = [ route.map ]; + } + + if (!Array.isArray(route.template)) { + route.template = [ route.template ]; + } +}); + module.exports = { bind: { port: global.environment.port, host: global.environment.host }, - // FIXME: Remove it. This is no longer needed, paths are defined in routers - // This is for inline maps and table maps - base_url: global.environment.base_url_legacy || '/tiles/:table', - - /// @deprecated with Windshaft-0.17.0 - ///base_url_notable: '/tiles', - - // FIXME: Remove it. This is no longer needed, paths are defined in routers - // This is for Detached maps - // - // "maps" is the official, while - // "tiles/layergroup" is for backward compatibility up to 1.6.x - // - base_url_mapconfig: global.environment.base_url_detached || '(?:/maps|/tiles/layergroup)', - - // FIXME: Remove it. This is no longer needed, paths are defined in routers - base_url_templated: global.environment.base_url_templated || '(?:/maps/named|/tiles/template)', - // Base URLs for the APIs // // See http://github.com/CartoDB/Windshaft-cartodb/wiki/Unified-Map-API - routes: global.environment.routes || { - v1: { - paths: [ - '/api/v1', - '/user/:user/api/v1', - ], - // Base url for the Detached Maps API - // "/api/v1/map" is the new API, - map: { - paths: [ - '/map', - ] - }, - // Base url for the Templated Maps API - // "/api/v1/map/named" is the new API, - template: { - paths: [ - '/map/named' - ] - } - }, - // For compatibility with versions up to 1.6.x - v0: { - paths: [ - '/tiles' - ], - // Base url for the Detached Maps API - // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - map: { - paths: [ - '/layergroup' - ] - }, - // Base url for the Templated Maps API - // "/tiles/template" is for compatibility with versions up to 1.6.x - template: { - paths: [ - '/template' - ] - } - } - }, - + routes: routesConfig, grainstore: { map: { // TODO: allow to specify in configuration diff --git a/lib/cartodb/server.js b/lib/server.js similarity index 87% rename from lib/cartodb/server.js rename to lib/server.js index a200b062..9f7b7ee0 100644 --- a/lib/cartodb/server.js +++ b/lib/server.js @@ -14,7 +14,9 @@ const ServerInfoController = require('./server-info-controller'); const StatsClient = require('./stats/client'); module.exports = function createServer (serverOptions) { - validateOptions(serverOptions); + if (!serverOptions.hasOwnProperty('routes')) { + throw new Error('Must initialise server with "routes" as base paths configuration'); + } // Make stats client globally accessible global.statsClient = StatsClient.getInstance(serverOptions.statsd); @@ -31,22 +33,22 @@ module.exports = function createServer (serverOptions) { app.set('json replacer', jsonReplacer()); const apiRouter = new ApiRouter({ serverOptions, environmentOptions: global.environment }); - apiRouter.register(app); + + // TODO: remove it before releasing next major version + if (!Array.isArray(serverOptions.routes.api)) { + serverOptions.routes.api = [ serverOptions.routes.api ]; + } + + apiRouter.route(app, serverOptions.routes.api); const versions = getAndValidateVersions(serverOptions); const serverInfoController = new ServerInfoController(versions); - serverInfoController.register(app); + serverInfoController.route(app); return app; }; -function validateOptions(opts) { - if (!_.isString(opts.base_url) || !_.isString(opts.base_url_mapconfig) || !_.isString(opts.base_url_templated)) { - throw new Error("Must initialise server with: 'base_url'/'base_url_mapconfig'/'base_url_templated' URLs"); - } -} - function bootstrapFonts(opts) { // Set carto renderer configuration for MMLStore opts.grainstore.carto_env = opts.grainstore.carto_env || {}; @@ -66,7 +68,7 @@ function mapnikVersion(opts) { function getAndValidateVersions(options) { var warn = console.warn.bind(console); // jshint ignore:line - var packageDefinition = require('../../package.json'); + var packageDefinition = require('../package.json'); var declaredDependencies = packageDefinition.dependencies || {}; var installedDependenciesVersions = { diff --git a/lib/cartodb/stats/client.js b/lib/stats/client.js similarity index 100% rename from lib/cartodb/stats/client.js rename to lib/stats/client.js diff --git a/lib/cartodb/stats/profiler_proxy.js b/lib/stats/profiler-proxy.js similarity index 100% rename from lib/cartodb/stats/profiler_proxy.js rename to lib/stats/profiler-proxy.js diff --git a/lib/cartodb/stats/reporter/named-map-provider.js b/lib/stats/reporter/named-map-provider.js similarity index 100% rename from lib/cartodb/stats/reporter/named-map-provider.js rename to lib/stats/reporter/named-map-provider.js diff --git a/lib/cartodb/stats/reporter/renderer.js b/lib/stats/reporter/renderer.js similarity index 100% rename from lib/cartodb/stats/reporter/renderer.js rename to lib/stats/reporter/renderer.js diff --git a/lib/cartodb/stats/timer.js b/lib/stats/timer.js similarity index 100% rename from lib/cartodb/stats/timer.js rename to lib/stats/timer.js diff --git a/lib/cartodb/utils/database-params.js b/lib/utils/database-params.js similarity index 100% rename from lib/cartodb/utils/database-params.js rename to lib/utils/database-params.js diff --git a/lib/cartodb/utils/date-wrapper.js b/lib/utils/date-wrapper.js similarity index 100% rename from lib/cartodb/utils/date-wrapper.js rename to lib/utils/date-wrapper.js diff --git a/lib/cartodb/utils/icu_data_env_setter.js b/lib/utils/icu-data-env-setter.js similarity index 100% rename from lib/cartodb/utils/icu_data_env_setter.js rename to lib/utils/icu-data-env-setter.js diff --git a/lib/cartodb/utils/json-replacer.js b/lib/utils/json-replacer.js similarity index 100% rename from lib/cartodb/utils/json-replacer.js rename to lib/utils/json-replacer.js diff --git a/lib/cartodb/utils/layergroup-metadata.js b/lib/utils/layergroup-metadata.js similarity index 100% rename from lib/cartodb/utils/layergroup-metadata.js rename to lib/utils/layergroup-metadata.js diff --git a/lib/cartodb/utils/overviews_query_rewriter.js b/lib/utils/overviews-query-rewriter.js similarity index 99% rename from lib/cartodb/utils/overviews_query_rewriter.js rename to lib/utils/overviews-query-rewriter.js index cf61b070..82164d6d 100644 --- a/lib/cartodb/utils/overviews_query_rewriter.js +++ b/lib/utils/overviews-query-rewriter.js @@ -1,7 +1,7 @@ 'use strict'; var _ = require('underscore'); -var TableNameParser = require('./table_name_parser'); +var TableNameParser = require('./table-name-parser'); var BBoxFilter = require('../models/filter/bbox'); var AnalysisFilter = require('../models/filter/analysis'); diff --git a/lib/cartodb/utils/query-utils.js b/lib/utils/query-utils.js similarity index 100% rename from lib/cartodb/utils/query-utils.js rename to lib/utils/query-utils.js diff --git a/lib/cartodb/utils/substitution-tokens.js b/lib/utils/substitution-tokens.js similarity index 100% rename from lib/cartodb/utils/substitution-tokens.js rename to lib/utils/substitution-tokens.js diff --git a/lib/cartodb/utils/table_name_parser.js b/lib/utils/table-name-parser.js similarity index 100% rename from lib/cartodb/utils/table_name_parser.js rename to lib/utils/table-name-parser.js diff --git a/package-lock.json b/package-lock.json index 34b12b1d..b254d14f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "windshaft-cartodb", - "version": "7.2.0", + "version": "8.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 86673cf5..c983c5ab 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "7.2.0", + "version": "8.0.0", "description": "A map tile server for CartoDB", "keywords": [ "cartodb" diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation-test.js similarity index 99% rename from test/acceptance/aggregation.js rename to test/acceptance/aggregation-test.js index 7bc5e6de..e1975f8a 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); -const serverOptions = require('../../lib/cartodb/server_options'); +const serverOptions = require('../../lib/server-options'); const WebMercatorHelper = require('cartodb-query-tables').utils.webMercatorHelper; const webmercator = new WebMercatorHelper(); diff --git a/test/acceptance/analysis/analyses-controller.js b/test/acceptance/analysis/analyses-controller-test.js similarity index 98% rename from test/acceptance/analysis/analyses-controller.js rename to test/acceptance/analysis/analyses-controller-test.js index 6ed0808b..04aea78c 100644 --- a/test/acceptance/analysis/analyses-controller.js +++ b/test/acceptance/analysis/analyses-controller-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/analysis/analyses-filters-params.js b/test/acceptance/analysis/analyses-filters-params-test.js similarity index 99% rename from test/acceptance/analysis/analyses-filters-params.js rename to test/acceptance/analysis/analyses-filters-params-test.js index 21fd8f01..342fcb4d 100644 --- a/test/acceptance/analysis/analyses-filters-params.js +++ b/test/acceptance/analysis/analyses-filters-params-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); const assert = require('../../support/assert'); const TestClient = require('../../support/test-client'); diff --git a/test/acceptance/analysis/analyses-filters.js b/test/acceptance/analysis/analyses-filters-test.js similarity index 98% rename from test/acceptance/analysis/analyses-filters.js rename to test/acceptance/analysis/analyses-filters-test.js index ff86855f..5e8390e2 100644 --- a/test/acceptance/analysis/analyses-filters.js +++ b/test/acceptance/analysis/analyses-filters-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); const assert = require('../../support/assert'); const TestClient = require('../../support/test-client'); diff --git a/test/acceptance/analysis/analysis-layers-dataviews.js b/test/acceptance/analysis/analysis-layers-dataviews-test.js similarity index 99% rename from test/acceptance/analysis/analysis-layers-dataviews.js rename to test/acceptance/analysis/analysis-layers-dataviews-test.js index 7a35607f..95436185 100644 --- a/test/acceptance/analysis/analysis-layers-dataviews.js +++ b/test/acceptance/analysis/analysis-layers-dataviews-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/analysis/analysis-layers.js b/test/acceptance/analysis/analysis-layers-test.js similarity index 99% rename from test/acceptance/analysis/analysis-layers.js rename to test/acceptance/analysis/analysis-layers-test.js index b7eeac48..2c871a3b 100644 --- a/test/acceptance/analysis/analysis-layers.js +++ b/test/acceptance/analysis/analysis-layers-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/analysis/analysis-layers-use-cases.js b/test/acceptance/analysis/analysis-layers-use-cases-test.js similarity index 99% rename from test/acceptance/analysis/analysis-layers-use-cases.js rename to test/acceptance/analysis/analysis-layers-use-cases-test.js index cc10c7dc..d765ae4e 100644 --- a/test/acceptance/analysis/analysis-layers-use-cases.js +++ b/test/acceptance/analysis/analysis-layers-use-cases-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/analysis/error-cases.js b/test/acceptance/analysis/error-cases-test.js similarity index 99% rename from test/acceptance/analysis/error-cases.js rename to test/acceptance/analysis/error-cases-test.js index 5c610dde..eeb8d3e3 100644 --- a/test/acceptance/analysis/error-cases.js +++ b/test/acceptance/analysis/error-cases-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/analysis/named-maps.js b/test/acceptance/analysis/named-maps-test.js similarity index 97% rename from test/acceptance/analysis/named-maps.js rename to test/acceptance/analysis/named-maps-test.js index dd34b7dd..5a092a11 100644 --- a/test/acceptance/analysis/named-maps.js +++ b/test/acceptance/analysis/named-maps-test.js @@ -2,13 +2,13 @@ var assert = require('../../support/assert'); -var helper = require('../../support/test_helper'); +var helper = require('../../support/test-helper'); -var CartodbWindshaft = require('../../../lib/cartodb/server'); -var serverOptions = require('../../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../../lib/server'); +var serverOptions = require('../../../lib/server-options'); var TestClient = require('../../support/test-client'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('named-maps analysis', function() { var server; diff --git a/test/acceptance/analysis/regressions.js b/test/acceptance/analysis/regressions-test.js similarity index 99% rename from test/acceptance/analysis/regressions.js rename to test/acceptance/analysis/regressions-test.js index 72fd9a35..c1758a20 100644 --- a/test/acceptance/analysis/regressions.js +++ b/test/acceptance/analysis/regressions-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/auth/authorization-basic-use-cases.js b/test/acceptance/auth/authorization-basic-use-cases-test.js similarity index 95% rename from test/acceptance/auth/authorization-basic-use-cases.js rename to test/acceptance/auth/authorization-basic-use-cases-test.js index d0c3a17c..491b81b0 100644 --- a/test/acceptance/auth/authorization-basic-use-cases.js +++ b/test/acceptance/auth/authorization-basic-use-cases-test.js @@ -1,10 +1,10 @@ 'use strict'; const assert = require('../../support/assert'); -const testHelper = require('../../support/test_helper'); -const CartodbWindshaft = require('../../../lib/cartodb/server'); -const serverOptions = require('../../../lib/cartodb/server_options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +const testHelper = require('../../support/test-helper'); +const CartodbWindshaft = require('../../../lib/server'); +const serverOptions = require('../../../lib/server-options'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); function singleLayergroupConfig(sql, cartocss) { return { diff --git a/test/acceptance/auth/authorization.js b/test/acceptance/auth/authorization-test.js similarity index 99% rename from test/acceptance/auth/authorization.js rename to test/acceptance/auth/authorization-test.js index 7fff7aa3..62384d84 100644 --- a/test/acceptance/auth/authorization.js +++ b/test/acceptance/auth/authorization-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); const assert = require('../../support/assert'); const TestClient = require('../../support/test-client'); diff --git a/test/acceptance/buffer-size-format.js b/test/acceptance/buffer-size-format-test.js similarity index 99% rename from test/acceptance/buffer-size-format.js rename to test/acceptance/buffer-size-format-test.js index e3daf626..62d19ccc 100644 --- a/test/acceptance/buffer-size-format.js +++ b/test/acceptance/buffer-size-format-test.js @@ -1,11 +1,11 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var fs = require('fs'); var assert = require('../support/assert'); var TestClient = require('../support/test-client'); -var serverOptions = require('../../lib/cartodb/server_options'); +var serverOptions = require('../../lib/server-options'); var mapnik = require('windshaft').mapnik; var IMAGE_TOLERANCE_PER_MIL = 5; diff --git a/test/acceptance/cache/cache-control-header.js b/test/acceptance/cache/cache-control-header-test.js similarity index 99% rename from test/acceptance/cache/cache-control-header.js rename to test/acceptance/cache/cache-control-header-test.js index 5a738700..d3b89863 100644 --- a/test/acceptance/cache/cache-control-header.js +++ b/test/acceptance/cache/cache-control-header-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); const assert = require('../../support/assert'); const TestClient = require('../../support/test-client'); diff --git a/test/acceptance/cache/cache_headers.js b/test/acceptance/cache/cache-headers-test.js similarity index 98% rename from test/acceptance/cache/cache_headers.js rename to test/acceptance/cache/cache-headers-test.js index 46a22026..974a60ff 100644 --- a/test/acceptance/cache/cache_headers.js +++ b/test/acceptance/cache/cache-headers-test.js @@ -1,14 +1,14 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var qs = require('querystring'); -var CartodbWindshaft = require('../../../lib/cartodb/server'); -var serverOptions = require('../../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../../lib/server'); +var serverOptions = require('../../../lib/server-options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('get requests with cache headers', function() { var server; diff --git a/test/acceptance/cache/surrogate_keys_invalidation.js b/test/acceptance/cache/surrogate-keys-invalidation-test.js similarity index 97% rename from test/acceptance/cache/surrogate_keys_invalidation.js rename to test/acceptance/cache/surrogate-keys-invalidation-test.js index aa22892b..f884b07c 100644 --- a/test/acceptance/cache/surrogate_keys_invalidation.js +++ b/test/acceptance/cache/surrogate-keys-invalidation-test.js @@ -1,19 +1,18 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var step = require('step'); var FastlyPurge = require('fastly-purge'); var _ = require('underscore'); - -var NamedMapsCacheEntry = require(__dirname + '/../../../lib/cartodb/cache/model/named_maps_entry'); -var CartodbWindshaft = require(__dirname + '/../../../lib/cartodb/server'); +var NamedMapsCacheEntry = require('../../../lib/cache/model/named-maps-entry'); +var CartodbWindshaft = require('../../../lib/server'); var nock = require('nock'); describe('templates surrogate keys', function() { - var serverOptions = require('../../../lib/cartodb/server_options'); + var serverOptions = require('../../../lib/server-options'); // Enable Varnish purge for tests var varnishHost = serverOptions.varnish_host; diff --git a/test/acceptance/cluster.js b/test/acceptance/cluster-test.js similarity index 99% rename from test/acceptance/cluster.js rename to test/acceptance/cluster-test.js index 840757a8..33ea4234 100644 --- a/test/acceptance/cluster.js +++ b/test/acceptance/cluster-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); diff --git a/test/acceptance/custom-middlewares-test.js b/test/acceptance/custom-middlewares-test.js new file mode 100644 index 00000000..7348479c --- /dev/null +++ b/test/acceptance/custom-middlewares-test.js @@ -0,0 +1,331 @@ +'use strict'; + +const helper = require('../support/test-helper'); +const assert = require('../support/assert'); +const createServer = require('../../lib/server'); +const serverOptions = require('../../lib/server-options'); + +describe('custom middlewares', function () { + const RESPONSE_OK = { + statusCode: 200 + }; + const RESPONSE_KO_TEAPOT = { + statusCode: 418 + }; + + describe('wired in /api/v1', function () { + before(function () { + const options = Object.assign({}, serverOptions, { + routes: { + api: [{ + paths: [ + '/api/v1', + '/user/:user/api/v1', + ], + middlewares: [ + function teapot () { + return function teapotMiddleware (req, res) { + res.status(418).send('I\'m a teapot'); + }; + } + ], + // Base url for the Detached Maps API + // "/api/v1/map" is the new API, + map: [{ + paths: [ + '/map', + ] + }], + // Base url for the Templated Maps API + // "/api/v1/map/named" is the new API, + template: [{ + paths: [ + '/map/named' + ] + }] + }] + } + }); + + this.server = createServer(options); + }); + + it('POST /api/v1/map/named returns 418: "I\'m a teapot"', function (done) { + const templateid = `custom-middlewares-test-${Date.now()}`; + const template = { + version: '0.0.1', + name: templateid, + layergroup: { + layers: [{ + type: 'cartodb', + options: { + sql: 'select 1 as cartodb_id, null::geometry as the_geom_webmercator' + } + }] + } + }; + const request = { + url: '/api/v1/map/named?api_key=1234', + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(template) + }; + + assert.response(this.server, request, RESPONSE_KO_TEAPOT, (res, err) => { + if (err) { + return done(err); + } + + assert.equal(res.body, 'I\'m a teapot'); + + done(); + }); + }); + + it('POST /api/v1/map returns 418: "I\'m a teapot"', function (done) { + const mapConfig = { + layers: [{ + type: 'cartodb', + options: { + sql: 'select 1 as cartodb_id, null::geometry as the_geom_webmercator' + } + }] + }; + const request = { + url: '/api/v1/map', + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(mapConfig) + }; + + assert.response(this.server, request, RESPONSE_KO_TEAPOT, (res, err) => { + if (err) { + return done(err); + } + + assert.equal(res.body, 'I\'m a teapot'); + + done(); + }); + }); + }); + + describe('wired in /api/v1/map', function () { + before(function () { + const options = Object.assign({}, serverOptions, { + routes: { + api: [{ + paths: [ + '/api/v1', + '/user/:user/api/v1', + ], + // Base url for the Detached Maps API + // "/api/v1/map" is the new API, + map: [{ + paths: [ + '/map', + ], + middlewares: [ + function teapot () { + return function teapotMiddleware (req, res, next) { + if (req.path === '/') { + return res.status(418).send('I\'m a teapot'); + } + next(); + }; + } + ] + }], + // Base url for the Templated Maps API + // "/api/v1/map/named" is the new API, + template: [{ + paths: [ + '/map/named' + ] + }] + }] + } + }); + + this.server = createServer(options); + }); + + it('POST /api/v1/map/named returns 200: template created', function (done) { + const templateid = `custom-middlewares-test-${Date.now()}`; + const template = { + version: '0.0.1', + name: templateid, + layergroup: { + layers: [{ + type: 'cartodb', + options: { + sql: 'select 1 as cartodb_id, null::geometry as the_geom_webmercator' + } + }] + } + }; + const request = { + url: '/api/v1/map/named?api_key=1234', + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(template) + }; + + assert.response(this.server, request, RESPONSE_OK, (res, err) => { + if (err) { + return done(err); + } + + const body = JSON.parse(res.body); + + assert.deepEqual(body, { template_id: templateid }); + + helper.deleteRedisKeys({ ['map_tpl|localhost']: 0 }, done); + }); + }); + + it('POST /api/v1/map returns 418: "I\'m a teapot"', function (done) { + const mapConfig = { + layers: [{ + type: 'cartodb', + options: { + sql: 'select 1 as cartodb_id, null::geometry as the_geom_webmercator' + } + }] + }; + const request = { + url: '/api/v1/map', + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(mapConfig) + }; + + assert.response(this.server, request, RESPONSE_KO_TEAPOT, (res, err) => { + if (err) { + return done(err); + } + + assert.equal(res.body, 'I\'m a teapot'); + + done(); + }); + }); + }); + + describe('wired in /api/v1/map/named', function () { + before(function () { + const options = Object.assign({}, serverOptions, { + routes: { + api: [{ + paths: [ + '/api/v1', + '/user/:user/api/v1', + ], + // Base url for the Detached Maps API + // "/api/v1/map" is the new API, + map: [{ + paths: [ + '/map', + ] + }], + // Base url for the Templated Maps API + // "/api/v1/map/named" is the new API, + template: [{ + paths: [ + '/map/named' + ], + middlewares: [ + function teapot () { + return function teapotMiddleware (req, res) { + res.status(418).send('I\'m a teapot'); + }; + } + ] + }] + }] + } + }); + + this.server = createServer(options); + }); + + it('POST /api/v1/map/named returns 418: "I\'m a teapot"', function (done) { + const templateid = `custom-middlewares-test-${Date.now()}`; + const template = { + version: '0.0.1', + name: templateid, + layergroup: { + layers: [{ + type: 'cartodb', + options: { + sql: 'select 1 as cartodb_id, null::geometry as the_geom_webmercator' + } + }] + } + }; + const request = { + url: '/api/v1/map/named?api_key=1234', + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(template) + }; + + assert.response(this.server, request, RESPONSE_KO_TEAPOT, (res, err) => { + if (err) { + return done(err); + } + + assert.equal(res.body, 'I\'m a teapot'); + + done(); + }); + }); + + it('POST /api/v1/map returns 200: anonymous map created', function (done) { + const mapConfig = { + layers: [{ + type: 'cartodb', + options: { + sql: 'select 1 as cartodb_id, null::geometry as the_geom_webmercator' + } + }] + }; + const request = { + url: '/api/v1/map', + method: 'POST', + headers: { + host: 'localhost', + 'Content-Type': 'application/json' + }, + data: JSON.stringify(mapConfig) + }; + + assert.response(this.server, request, RESPONSE_OK, (res, err) => { + if (err) { + return done(err); + } + + const body = JSON.parse(res.body); + + assert.ok(body.layergroupid); + + helper.deleteRedisKeys({ ['user:localhost:mapviews:global']: 5 }, done); + }); + }); + }); +}); diff --git a/test/acceptance/dataviews/aggregation.js b/test/acceptance/dataviews/aggregation-test.js similarity index 99% rename from test/acceptance/dataviews/aggregation.js rename to test/acceptance/dataviews/aggregation-test.js index c6df346b..ae357dce 100644 --- a/test/acceptance/dataviews/aggregation.js +++ b/test/acceptance/dataviews/aggregation-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/dataviews/error-cases.js b/test/acceptance/dataviews/error-cases-test.js similarity index 99% rename from test/acceptance/dataviews/error-cases.js rename to test/acceptance/dataviews/error-cases-test.js index 835efa53..64af27a2 100644 --- a/test/acceptance/dataviews/error-cases.js +++ b/test/acceptance/dataviews/error-cases-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/dataviews/formula.js b/test/acceptance/dataviews/formula-test.js similarity index 99% rename from test/acceptance/dataviews/formula.js rename to test/acceptance/dataviews/formula-test.js index 028b6368..9f8b2877 100644 --- a/test/acceptance/dataviews/formula.js +++ b/test/acceptance/dataviews/formula-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/dataviews/histogram.js b/test/acceptance/dataviews/histogram-test.js similarity index 99% rename from test/acceptance/dataviews/histogram.js rename to test/acceptance/dataviews/histogram-test.js index f517a59a..945fc9dd 100644 --- a/test/acceptance/dataviews/histogram.js +++ b/test/acceptance/dataviews/histogram-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/dataviews/overviews.js b/test/acceptance/dataviews/overviews-test.js similarity index 99% rename from test/acceptance/dataviews/overviews.js rename to test/acceptance/dataviews/overviews-test.js index 7642dc73..8df298b3 100644 --- a/test/acceptance/dataviews/overviews.js +++ b/test/acceptance/dataviews/overviews-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/date-wrapping.spec.js b/test/acceptance/date-wrapping-test.js similarity index 99% rename from test/acceptance/date-wrapping.spec.js rename to test/acceptance/date-wrapping-test.js index f26caf1e..85b56111 100644 --- a/test/acceptance/date-wrapping.spec.js +++ b/test/acceptance/date-wrapping-test.js @@ -4,7 +4,7 @@ const assert = require('assert'); const TestClient = require('../support/test-client'); const mapConfigFactory = require('../fixtures/test_mapconfigFactory'); -const serverOptions = require('../../lib/cartodb/server_options'); +const serverOptions = require('../../lib/server-options'); const usePgMvtRenderer = serverOptions.renderer.mvt.usePostGIS; const describe_mvt = !usePgMvtRenderer ? describe : describe.skip; diff --git a/test/acceptance/dynamic-styling-named-maps.js b/test/acceptance/dynamic-styling-named-maps-test.js similarity index 94% rename from test/acceptance/dynamic-styling-named-maps.js rename to test/acceptance/dynamic-styling-named-maps-test.js index 994e347f..988b2a0e 100644 --- a/test/acceptance/dynamic-styling-named-maps.js +++ b/test/acceptance/dynamic-styling-named-maps-test.js @@ -2,10 +2,10 @@ var assert = require('../support/assert'); var step = require('step'); -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); -var testHelper = require(__dirname + '/../support/test_helper'); -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +var LayergroupToken = require('../../lib/models/layergroup-token'); +var testHelper = require('../support/test-helper'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); describe('dynamic styling for named maps', function() { var server; diff --git a/test/acceptance/error-middleware.js b/test/acceptance/error-middleware-test.js similarity index 100% rename from test/acceptance/error-middleware.js rename to test/acceptance/error-middleware-test.js diff --git a/test/acceptance/errors-with-context.js b/test/acceptance/errors-with-context-test.js similarity index 94% rename from test/acceptance/errors-with-context.js rename to test/acceptance/errors-with-context-test.js index 1adc877a..4d58b57a 100644 --- a/test/acceptance/errors-with-context.js +++ b/test/acceptance/errors-with-context-test.js @@ -1,8 +1,8 @@ 'use strict'; var assert = require('../support/assert'); -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); describe('error with context', function () { var server; diff --git a/test/acceptance/health_check.js b/test/acceptance/health-check-test.js similarity index 94% rename from test/acceptance/health_check.js rename to test/acceptance/health-check-test.js index 112cc88d..cff4b41e 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health-check-test.js @@ -1,12 +1,12 @@ 'use strict'; -require(__dirname + '/../support/test_helper'); +require('../support/test-helper'); var fs = require('fs'); var assert = require('../support/assert'); -var CartodbWindshaft = require('../../lib/cartodb/server'); -var serverOptions = require('../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); describe('health checks', function () { diff --git a/test/acceptance/label-wrap.js b/test/acceptance/label-wrap-test.js similarity index 98% rename from test/acceptance/label-wrap.js rename to test/acceptance/label-wrap-test.js index 914b2842..2a968e61 100644 --- a/test/acceptance/label-wrap.js +++ b/test/acceptance/label-wrap-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var TestClient = require('../support/test-client'); var assert = require('../support/assert'); diff --git a/test/acceptance/layergroup-metadata.js b/test/acceptance/layergroup-metadata-test.js similarity index 95% rename from test/acceptance/layergroup-metadata.js rename to test/acceptance/layergroup-metadata-test.js index 50e30895..831a5b8e 100644 --- a/test/acceptance/layergroup-metadata.js +++ b/test/acceptance/layergroup-metadata-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); -const serverOptions = require('../../lib/cartodb/server_options'); +const serverOptions = require('../../lib/server-options'); describe('layergroup metadata', function () { const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS; diff --git a/test/acceptance/layers-filters.js b/test/acceptance/layers-filters-test.js similarity index 97% rename from test/acceptance/layers-filters.js rename to test/acceptance/layers-filters-test.js index 2767300f..29bfb5ff 100644 --- a/test/acceptance/layers-filters.js +++ b/test/acceptance/layers-filters-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var TestClient = require('../support/test-client'); describe('layers filters', function() { diff --git a/test/acceptance/max-waiting-workers.js b/test/acceptance/max-waiting-workers-test.js similarity index 98% rename from test/acceptance/max-waiting-workers.js rename to test/acceptance/max-waiting-workers-test.js index adf259de..576bd07b 100644 --- a/test/acceptance/max-waiting-workers.js +++ b/test/acceptance/max-waiting-workers-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); diff --git a/test/acceptance/multilayer_server.js b/test/acceptance/multilayer-server-test.js similarity index 97% rename from test/acceptance/multilayer_server.js rename to test/acceptance/multilayer-server-test.js index 3f6c1b45..7a7b7e72 100644 --- a/test/acceptance/multilayer_server.js +++ b/test/acceptance/multilayer-server-test.js @@ -1,17 +1,17 @@ 'use strict'; -var testHelper = require('../support/test_helper'); +var testHelper = require('../support/test-helper'); var assert = require('../support/assert'); var _ = require('underscore'); -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../lib/models/layergroup-token'); -var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); +var PgQueryRunner = require('../../lib/backends/pg-query-runner'); var QueryTables = require('cartodb-query-tables').queryTables; -var CartodbWindshaft = require('../../lib/cartodb/server'); -var serverOptions = require('../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); describe('tests from old api translated to multilayer', function() { var server; diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer-test.js similarity index 99% rename from test/acceptance/multilayer.js rename to test/acceptance/multilayer-test.js index 28d9914f..10fb4451 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer-test.js @@ -10,16 +10,16 @@ var redis_stats_db = 5; var mapnik = require('windshaft').mapnik; var semver = require('semver'); -var helper = require(__dirname + '/../support/test_helper'); -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); +var helper = require('../support/test-helper'); +var LayergroupToken = require('../../lib/models/layergroup-token'); var windshaft_fixtures = __dirname + '/../../node_modules/windshaft/test/fixtures'; var IMAGE_EQUALS_TOLERANCE_PER_MIL = 20; var IMAGE_EQUALS_HIGHER_TOLERANCE_PER_MIL = 25; -var CartodbWindshaft = require('../../lib/cartodb/server'); -var serverOptions = require('../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); var QueryTables = require('cartodb-query-tables').queryTables; diff --git a/test/acceptance/mvt-regressions.js b/test/acceptance/mvt-regressions-test.js similarity index 98% rename from test/acceptance/mvt-regressions.js rename to test/acceptance/mvt-regressions-test.js index c660e23d..56c7ff0e 100644 --- a/test/acceptance/mvt-regressions.js +++ b/test/acceptance/mvt-regressions-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); -const serverOptions = require('../../lib/cartodb/server_options'); +const serverOptions = require('../../lib/server-options'); const suites = [ { diff --git a/test/acceptance/mvt.js b/test/acceptance/mvt-test.js similarity index 99% rename from test/acceptance/mvt.js rename to test/acceptance/mvt-test.js index bb446680..15e28297 100644 --- a/test/acceptance/mvt.js +++ b/test/acceptance/mvt-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('../support/assert'); var TestClient = require('../support/test-client'); -var serverOptions = require('../../lib/cartodb/server_options'); +var serverOptions = require('../../lib/server-options'); function createMapConfig(sql = TestClient.SQL.ONE_POINT) { return { diff --git a/test/acceptance/named_layers.js b/test/acceptance/named-layers-test.js similarity index 98% rename from test/acceptance/named_layers.js rename to test/acceptance/named-layers-test.js index b80bfacc..a7da4e86 100644 --- a/test/acceptance/named_layers.js +++ b/test/acceptance/named-layers-test.js @@ -1,15 +1,15 @@ 'use strict'; -var test_helper = require('../support/test_helper'); +var test_helper = require('../support/test-helper'); var assert = require('../support/assert'); -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../lib/models/layergroup-token'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js'); +var TemplateMaps = require('../../lib/backends/template-maps'); var step = require('step'); diff --git a/test/acceptance/named_layers_visibility.js b/test/acceptance/named-layers-visibility-test.js similarity index 95% rename from test/acceptance/named_layers_visibility.js rename to test/acceptance/named-layers-visibility-test.js index 0df92ed6..a68314fe 100644 --- a/test/acceptance/named_layers_visibility.js +++ b/test/acceptance/named-layers-visibility-test.js @@ -1,14 +1,14 @@ 'use strict'; var step = require('step'); -var test_helper = require('../support/test_helper'); +var test_helper = require('../support/test-helper'); var assert = require('../support/assert'); -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js'); +var TemplateMaps = require('../../lib/backends/template-maps'); var mapnik = require('windshaft').mapnik; var IMAGE_TOLERANCE = 20; diff --git a/test/acceptance/named-map-cache-regressions.js b/test/acceptance/named-map-cache-regressions-test.js similarity index 97% rename from test/acceptance/named-map-cache-regressions.js rename to test/acceptance/named-map-cache-regressions-test.js index 8521ca8a..d8089cf5 100644 --- a/test/acceptance/named-map-cache-regressions.js +++ b/test/acceptance/named-map-cache-regressions-test.js @@ -1,13 +1,13 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const request = require('request'); const assert = require('assert'); -const Server = require('../../lib/cartodb/server'); -const serverOptions = require('../../lib/cartodb/server_options'); +const Server = require('../../lib/server'); +const serverOptions = require('../../lib/server-options'); const { mapnik } = require('windshaft'); -const helper = require('../support/test_helper'); +const helper = require('../support/test-helper'); const namedTileUrlTemplate = (ctx) => { return `http://${ctx.address}/api/v1/map/static/named/${ctx.templateId}/256/256.png?api_key=${ctx.apiKey}`; diff --git a/test/acceptance/named_maps_authentication.js b/test/acceptance/named-maps-authentication-test.js similarity index 95% rename from test/acceptance/named_maps_authentication.js rename to test/acceptance/named-maps-authentication-test.js index 4f8e343c..ac898c5e 100644 --- a/test/acceptance/named_maps_authentication.js +++ b/test/acceptance/named-maps-authentication-test.js @@ -1,15 +1,15 @@ 'use strict'; -var test_helper = require('../support/test_helper'); +var test_helper = require('../support/test-helper'); var RedisPool = require('redis-mpool'); var querystring = require('querystring'); var assert = require('../support/assert'); var mapnik = require('windshaft').mapnik; -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js'); -var NamedMapsCacheEntry = require('../../lib/cartodb/cache/model/named_maps_entry'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); +var TemplateMaps = require('../../lib/backends/template-maps'); +var NamedMapsCacheEntry = require('../../lib/cache/model/named-maps-entry'); describe('named maps authentication', function() { var server; diff --git a/test/acceptance/named_maps_cache.js b/test/acceptance/named-maps-cache-test.js similarity index 96% rename from test/acceptance/named_maps_cache.js rename to test/acceptance/named-maps-cache-test.js index 0cdc2a49..c369dc0e 100644 --- a/test/acceptance/named_maps_cache.js +++ b/test/acceptance/named-maps-cache-test.js @@ -1,12 +1,12 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); -const helper = require('../support/test_helper'); +const helper = require('../support/test-helper'); var assert = require('../support/assert'); var mapnik = require('windshaft').mapnik; -var CartodbWindshaft = require('../../lib/cartodb/server'); -var serverOptions = require('../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); describe('named maps provider cache', function() { var server; diff --git a/test/acceptance/named_maps_static_view.js b/test/acceptance/named-maps-static-view-test.js similarity index 97% rename from test/acceptance/named_maps_static_view.js rename to test/acceptance/named-maps-static-view-test.js index 8a9b1402..e6e54195 100644 --- a/test/acceptance/named_maps_static_view.js +++ b/test/acceptance/named-maps-static-view-test.js @@ -1,14 +1,14 @@ 'use strict'; var qs = require('querystring'); -var testHelper = require('../support/test_helper'); +var testHelper = require('../support/test-helper'); var RedisPool = require('redis-mpool'); var assert = require('../support/assert'); var mapnik = require('windshaft').mapnik; -var CartodbWindshaft = require('../../lib/cartodb/server'); -var serverOptions = require('../../lib/cartodb/server_options'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); +var TemplateMaps = require('../../lib/backends/template-maps'); describe('named maps static view', function() { // configure redis pool instance to use in tests diff --git a/test/acceptance/named_maps_stats.js b/test/acceptance/named-maps-stats-test.js similarity index 90% rename from test/acceptance/named_maps_stats.js rename to test/acceptance/named-maps-stats-test.js index fc80cbbc..a41644ba 100644 --- a/test/acceptance/named_maps_stats.js +++ b/test/acceptance/named-maps-stats-test.js @@ -1,15 +1,15 @@ 'use strict'; -var test_helper = require('../support/test_helper'); +var test_helper = require('../support/test-helper'); var RedisPool = require('redis-mpool'); var querystring = require('querystring'); var assert = require('../support/assert'); var mapnik = require('windshaft').mapnik; -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js'); -var NamedMapsCacheEntry = require('../../lib/cartodb/cache/model/named_maps_entry'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); +var TemplateMaps = require('../../lib/backends/template-maps'); +var NamedMapsCacheEntry = require('../../lib/cache/model/named-maps-entry'); describe('named maps preview stats', function() { var server; diff --git a/test/acceptance/overviews_metadata_named_maps.js b/test/acceptance/overviews-metadata-named-maps-test.js similarity index 97% rename from test/acceptance/overviews_metadata_named_maps.js rename to test/acceptance/overviews-metadata-named-maps-test.js index 9e66cf07..5dc11240 100644 --- a/test/acceptance/overviews_metadata_named_maps.js +++ b/test/acceptance/overviews-metadata-named-maps-test.js @@ -1,12 +1,12 @@ 'use strict'; -var test_helper = require('../support/test_helper'); +var test_helper = require('../support/test-helper'); var assert = require('../support/assert'); -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../lib/models/layergroup-token'); var RedisPool = require('redis-mpool'); diff --git a/test/acceptance/overviews_metadata.js b/test/acceptance/overviews-metadata-test.js similarity index 97% rename from test/acceptance/overviews_metadata.js rename to test/acceptance/overviews-metadata-test.js index 90642777..92ab562a 100644 --- a/test/acceptance/overviews_metadata.js +++ b/test/acceptance/overviews-metadata-test.js @@ -1,12 +1,12 @@ 'use strict'; -var test_helper = require('../support/test_helper'); +var test_helper = require('../support/test-helper'); var assert = require('../support/assert'); -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../lib/models/layergroup-token'); var RedisPool = require('redis-mpool'); diff --git a/test/acceptance/overviews_queries.js b/test/acceptance/overviews-queries-test.js similarity index 90% rename from test/acceptance/overviews_queries.js rename to test/acceptance/overviews-queries-test.js index c3726a61..b89b3660 100644 --- a/test/acceptance/overviews_queries.js +++ b/test/acceptance/overviews-queries-test.js @@ -1,11 +1,11 @@ 'use strict'; -var testHelper = require('../support/test_helper'); +var testHelper = require('../support/test-helper'); var assert = require('../support/assert'); -var cartodbServer = require('../../lib/cartodb/server'); -var ServerOptions = require('./ported/support/ported_server_options'); -var testClient = require('./ported/support/test_client'); +var cartodbServer = require('../../lib/server'); +var ServerOptions = require('./ported/support/ported-server-options'); +var testClient = require('./ported/support/test-client'); describe('overviews_queries', function() { var server; diff --git a/test/acceptance/ported/attributes.js b/test/acceptance/ported/attributes-test.js similarity index 92% rename from test/acceptance/ported/attributes.js rename to test/acceptance/ported/attributes-test.js index 6f899c64..86527e2f 100644 --- a/test/acceptance/ported/attributes.js +++ b/test/acceptance/ported/attributes-test.js @@ -1,12 +1,12 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var step = require('step'); -var cartodbServer = require('../../../lib/cartodb/server'); -var PortedServerOptions = require('./support/ported_server_options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var cartodbServer = require('../../../lib/server'); +var PortedServerOptions = require('./support/ported-server-options'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('attributes', function() { var server; @@ -58,7 +58,7 @@ describe('attributes', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -86,7 +86,7 @@ describe('attributes', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/attributes/1', + url: '/api/v1/map/' + expected_token + '/0/attributes/1', method: 'GET', headers: { host: 'localhost' @@ -109,7 +109,7 @@ describe('attributes', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/1', + url: '/api/v1/map/' + expected_token + '/1/attributes/1', method: 'GET', headers: { host: 'localhost' @@ -128,7 +128,7 @@ describe('attributes', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/-666', + url: '/api/v1/map/' + expected_token + '/1/attributes/-666', method: 'GET', headers: { host: 'localhost' @@ -169,7 +169,7 @@ describe('attributes', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -202,7 +202,7 @@ describe('attributes', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -230,7 +230,7 @@ describe('attributes', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/0/attributes/1?callback=test', method: 'GET', headers: { @@ -257,7 +257,7 @@ describe('attributes', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/1', + url: '/api/v1/map/' + expected_token + '/1/attributes/1', method: 'GET', headers: { host: 'localhost' @@ -297,7 +297,7 @@ describe('attributes', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', diff --git a/test/acceptance/ported/blend_filtering.js b/test/acceptance/ported/blend-filtering-test.js similarity index 98% rename from test/acceptance/ported/blend_filtering.js rename to test/acceptance/ported/blend-filtering-test.js index fcb0d41f..2bb5ca9e 100644 --- a/test/acceptance/ported/blend_filtering.js +++ b/test/acceptance/ported/blend-filtering-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); var fs = require('fs'); var http = require('http'); diff --git a/test/acceptance/ported/blend_http_fallback.js b/test/acceptance/ported/blend-http-fallback-test.js similarity index 98% rename from test/acceptance/ported/blend_http_fallback.js rename to test/acceptance/ported/blend-http-fallback-test.js index 13fac245..f2dc1d8b 100644 --- a/test/acceptance/ported/blend_http_fallback.js +++ b/test/acceptance/ported/blend-http-fallback-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); var fs = require('fs'); var http = require('http'); diff --git a/test/acceptance/ported/blend_http_timeout.js b/test/acceptance/ported/blend-http-timeout-test.js similarity index 94% rename from test/acceptance/ported/blend_http_timeout.js rename to test/acceptance/ported/blend-http-timeout-test.js index 7edd8996..d71c6868 100644 --- a/test/acceptance/ported/blend_http_timeout.js +++ b/test/acceptance/ported/blend-http-timeout-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); -var serverOptions = require('./support/ported_server_options'); +var testClient = require('./support/test-client'); +var serverOptions = require('./support/ported-server-options'); var fs = require('fs'); var http = require('http'); diff --git a/test/acceptance/ported/blend.js b/test/acceptance/ported/blend-test.js similarity index 97% rename from test/acceptance/ported/blend.js rename to test/acceptance/ported/blend-test.js index 2f4a8714..269b35fd 100644 --- a/test/acceptance/ported/blend.js +++ b/test/acceptance/ported/blend-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); describe('blend png renderer', function() { var IMAGE_TOLERANCE_PER_MIL = 20; diff --git a/test/acceptance/ported/external_resources.js b/test/acceptance/ported/external-resources-test.js similarity index 96% rename from test/acceptance/ported/external_resources.js rename to test/acceptance/ported/external-resources-test.js index 6f4f13b3..6ac05df1 100644 --- a/test/acceptance/ported/external_resources.js +++ b/test/acceptance/ported/external-resources-test.js @@ -1,12 +1,12 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var fs = require('fs'); -var PortedServerOptions = require('./support/ported_server_options'); +var PortedServerOptions = require('./support/ported-server-options'); var http = require('http'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); var nock = require('nock'); describe('external resources', function() { diff --git a/test/acceptance/ported/limits.js b/test/acceptance/ported/limits-test.js similarity index 95% rename from test/acceptance/ported/limits.js rename to test/acceptance/ported/limits-test.js index ea549fa3..1ee70123 100644 --- a/test/acceptance/ported/limits.js +++ b/test/acceptance/ported/limits-test.js @@ -1,12 +1,12 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var fs = require('fs'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); -var serverOptions = require('./support/ported_server_options'); +var testClient = require('./support/test-client'); +var serverOptions = require('./support/ported-server-options'); describe.skip('render limits', function() { diff --git a/test/acceptance/ported/multilayer_error_cases.js b/test/acceptance/ported/multilayer-error-cases-test.js similarity index 95% rename from test/acceptance/ported/multilayer_error_cases.js rename to test/acceptance/ported/multilayer-error-cases-test.js index 6194879b..b4f9a9be 100644 --- a/test/acceptance/ported/multilayer_error_cases.js +++ b/test/acceptance/ported/multilayer-error-cases-test.js @@ -1,12 +1,12 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var step = require('step'); -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); -var testClient = require('./support/test_client'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); +var testClient = require('./support/test-client'); var TestClient = require('../../support/test-client'); describe('multilayer error cases', function() { @@ -27,7 +27,7 @@ describe('multilayer error cases', function() { it("post layergroup with wrong Content-Type", function(done) { assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -43,7 +43,7 @@ describe('multilayer error cases', function() { it("post layergroup with no layers", function(done) { assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -59,7 +59,7 @@ describe('multilayer error cases', function() { it("post layergroup jsonp errors are returned with 200 status", function(done) { assert.response(server, { - url: '/database/windshaft_test/layergroup?callback=test', + url: '/api/v1/map?callback=test', method: 'POST', headers: { host: 'localhost', @@ -90,7 +90,7 @@ describe('multilayer error cases', function() { ] }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -116,7 +116,7 @@ describe('multilayer error cases', function() { }}] }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -199,7 +199,7 @@ describe('multilayer error cases', function() { ] }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -238,7 +238,7 @@ describe('multilayer error cases', function() { ] }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -283,7 +283,7 @@ describe('multilayer error cases', function() { }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -389,7 +389,7 @@ describe('multilayer error cases', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/deadbeef/0/0/0/0.grid.json', + url: '/api/v1/map/deadbeef/0/0/0/0.grid.json', method: 'GET', encoding: 'binary', headers: { @@ -425,7 +425,7 @@ describe('multilayer error cases', function() { }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: {'Content-Type': 'application/json; charset=utf-8' }, data: '{' + JSON.stringify(layergroup) diff --git a/test/acceptance/ported/multilayer_interactivity.js b/test/acceptance/ported/multilayer-interactivity-test.js similarity index 97% rename from test/acceptance/ported/multilayer_interactivity.js rename to test/acceptance/ported/multilayer-interactivity-test.js index c2c11fad..48e1d007 100644 --- a/test/acceptance/ported/multilayer_interactivity.js +++ b/test/acceptance/ported/multilayer-interactivity-test.js @@ -1,13 +1,13 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var _ = require('underscore'); -var cartodbServer = require('../../../lib/cartodb/server'); +var cartodbServer = require('../../../lib/server'); var getLayerTypeFn = require('windshaft').model.MapConfig.prototype.getType; -var PortedServerOptions = require('./support/ported_server_options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var PortedServerOptions = require('./support/ported-server-options'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('multilayer interactivity and layers order', function() { var server; @@ -30,7 +30,7 @@ describe('multilayer interactivity and layers order', function() { assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', diff --git a/test/acceptance/ported/multilayer.js b/test/acceptance/ported/multilayer-test.js similarity index 93% rename from test/acceptance/ported/multilayer.js rename to test/acceptance/ported/multilayer-test.js index d7a0b0c7..1ff22011 100644 --- a/test/acceptance/ported/multilayer.js +++ b/test/acceptance/ported/multilayer-test.js @@ -1,15 +1,15 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var _ = require('underscore'); var querystring = require('querystring'); var step = require('step'); var mapnik = require('windshaft').mapnik; -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('multilayer', function() { var server; @@ -51,7 +51,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json; charset=utf-8' }, data: JSON.stringify(layergroup) @@ -92,7 +92,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -108,7 +108,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -162,7 +162,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -185,7 +185,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -204,7 +204,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json', + url: '/api/v1/map/' + expected_token + '/0/0/0/0.grid.json', method: 'GET', headers: { host: 'localhost' } }, {}, function(res) { @@ -222,7 +222,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/1/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } @@ -275,7 +275,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup?' + querystring.stringify({ + url: '/api/v1/map?' + querystring.stringify({ config: JSON.stringify(layergroup) }), method: 'GET', @@ -300,7 +300,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -319,7 +319,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/0/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } @@ -338,7 +338,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/1/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } @@ -391,7 +391,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup?' + querystring.stringify({ + url: '/api/v1/map?' + querystring.stringify({ config: JSON.stringify(layergroup), callback: 'jsonp_test' }), @@ -427,7 +427,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -446,7 +446,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/0/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } @@ -465,7 +465,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/1/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } @@ -527,7 +527,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -547,7 +547,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -566,7 +566,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/0/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } @@ -585,7 +585,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + + url: '/api/v1/map/' + expected_token + '/1/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } @@ -604,7 +604,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/1/attributes/4', + url: '/api/v1/map/' + expected_token + '/1/attributes/4', method: 'GET', headers: { host: 'localhost' } }, {}, function(res, err) { @@ -624,7 +624,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/2/0/0/0.json.torque', + url: '/api/v1/map/' + expected_token + '/2/0/0/0.json.torque', method: 'GET', headers: { host: 'localhost' } }, {}, function(res, err) { next(err, res); }); @@ -647,7 +647,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/1/0/0/0.json.torque', + url: '/api/v1/map/' + expected_token + '/1/0/0/0.json.torque', method: 'GET', headers: { host: 'localhost' } }, {}, function(res, err) { next(err, res); }); @@ -707,7 +707,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup1) @@ -723,7 +723,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup2) @@ -740,7 +740,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0.png', + url: '/api/v1/map/' + token1 + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -759,7 +759,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0/0.grid.json?interactivity=cartodb_id', + url: '/api/v1/map/' + token1 + '/0/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } }, {}, function(res) { @@ -777,7 +777,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + token2 + '/0/0/0.png', + url: '/api/v1/map/' + token2 + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -796,7 +796,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + token2 + '/0/0/0/0.grid.json?interactivity=cartodb_id', + url: '/api/v1/map/' + token2 + '/0/0/0/0.grid.json?interactivity=cartodb_id', method: 'GET', headers: { host: 'localhost' } }, {}, function(res) { @@ -853,7 +853,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -875,7 +875,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -921,7 +921,7 @@ describe('multilayer', function() { }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -950,7 +950,7 @@ describe('multilayer', function() { ] }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -985,7 +985,7 @@ describe('multilayer', function() { function doBadPost() { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: _.template(tpl, {font:'bogus'}) @@ -1005,7 +1005,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: _.template(tpl, {font:available_system_fonts[0]}) @@ -1033,7 +1033,7 @@ describe('multilayer', function() { it("geting options on layergroup should return CORS headers", function(done){ const allowHeaders = 'X-Requested-With, X-Prototype-Version, X-CSRF-Token, Authorization, Content-Type'; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'OPTIONS' },{ status: 200, @@ -1069,7 +1069,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1091,7 +1091,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json', + url: '/api/v1/map/' + expected_token + '/0/0/0/0.grid.json', method: 'GET', headers: { host: 'localhost' } }, {}, function(res) { @@ -1145,7 +1145,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1208,7 +1208,7 @@ describe('multilayer', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1226,7 +1226,7 @@ describe('multilayer', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + token1 + '/0/0/0.png', + url: '/api/v1/map/' + token1 + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } diff --git a/test/acceptance/ported/raster.js b/test/acceptance/ported/raster-test.js similarity index 91% rename from test/acceptance/ported/raster.js rename to test/acceptance/ported/raster-test.js index 58a6b2bf..313bca02 100644 --- a/test/acceptance/ported/raster.js +++ b/test/acceptance/ported/raster-test.js @@ -1,12 +1,12 @@ 'use strict'; -var testHelper =require('../../support/test_helper'); +var testHelper =require('../../support/test-helper'); var assert = require('../../support/assert'); var step = require('step'); -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('raster', function() { @@ -48,7 +48,7 @@ describe('raster', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(mapconfig) @@ -73,7 +73,7 @@ describe('raster', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { host: 'localhost' } @@ -131,7 +131,7 @@ describe('raster', function() { assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', diff --git a/test/acceptance/ported/regressions.js b/test/acceptance/ported/regressions-test.js similarity index 92% rename from test/acceptance/ported/regressions.js rename to test/acceptance/ported/regressions-test.js index 5e6a6293..1533d400 100644 --- a/test/acceptance/ported/regressions.js +++ b/test/acceptance/ported/regressions-test.js @@ -1,9 +1,9 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); describe('regressions', function() { after(function() { diff --git a/test/acceptance/ported/retina.js b/test/acceptance/ported/retina-test.js similarity index 89% rename from test/acceptance/ported/retina.js rename to test/acceptance/ported/retina-test.js index bdc1188c..ceca71a9 100644 --- a/test/acceptance/ported/retina.js +++ b/test/acceptance/ported/retina-test.js @@ -1,13 +1,13 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var mapnik = require('windshaft').mapnik; -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('retina support', function() { @@ -40,7 +40,7 @@ describe('retina support', function() { assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -71,7 +71,7 @@ describe('retina support', function() { function testRetinaImage(scaleFactor, responseHead, assertFn) { assert.response(server, { - url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/0/0' + scaleFactor + '.png', + url: '/api/v1/map/' + layergroupId + '/0/0/0' + scaleFactor + '.png', method: 'GET', encoding: 'binary', headers: { diff --git a/test/acceptance/ported/server_gettile.js b/test/acceptance/ported/server-gettile-test.js similarity index 97% rename from test/acceptance/ported/server_gettile.js rename to test/acceptance/ported/server-gettile-test.js index 61daa568..1d75a536 100644 --- a/test/acceptance/ported/server_gettile.js +++ b/test/acceptance/ported/server-gettile-test.js @@ -1,13 +1,13 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var mapnik = require('windshaft').mapnik; var semver = require('semver'); -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); -var testClient = require('./support/test_client'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); +var testClient = require('./support/test-client'); describe('server_gettile', function() { var server; diff --git a/test/acceptance/ported/server_png8_format.js b/test/acceptance/ported/server-png8-format-test.js similarity index 93% rename from test/acceptance/ported/server_png8_format.js rename to test/acceptance/ported/server-png8-format-test.js index 86af4682..66a4c820 100644 --- a/test/acceptance/ported/server_png8_format.js +++ b/test/acceptance/ported/server-png8-format-test.js @@ -1,14 +1,14 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var _ = require('underscore'); var fs = require('fs'); -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); var IMAGE_EQUALS_TOLERANCE_PER_MIL = 85; @@ -66,7 +66,7 @@ describe('server_png8_format', function() { assert.response( serverPng32, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -87,7 +87,7 @@ describe('server_png8_format', function() { var tilePartialUrl = _.template('/<%= z %>/<%= x %>/<%= y %>.png', tile); var requestPayload = { - url: '/database/windshaft_test/layergroup/' + layergroupId + tilePartialUrl, + url: '/api/v1/map/' + layergroupId + tilePartialUrl, method: 'GET', encoding: 'binary', headers: { diff --git a/test/acceptance/ported/server.js b/test/acceptance/ported/server-test.js similarity index 96% rename from test/acceptance/ported/server.js rename to test/acceptance/ported/server-test.js index 58febf38..9bd0e7e5 100644 --- a/test/acceptance/ported/server.js +++ b/test/acceptance/ported/server-test.js @@ -1,11 +1,11 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); -var testClient = require('./support/test_client'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); +var testClient = require('./support/test-client'); describe('server', function() { var server; diff --git a/test/acceptance/ported/static_maps.js b/test/acceptance/ported/static-maps-test.js similarity index 98% rename from test/acceptance/ported/static_maps.js rename to test/acceptance/ported/static-maps-test.js index ce3721f0..f5458a76 100644 --- a/test/acceptance/ported/static_maps.js +++ b/test/acceptance/ported/static-maps-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); var http = require('http'); var fs = require('fs'); diff --git a/test/acceptance/ported/support/ported_server_options.js b/test/acceptance/ported/support/ported-server-options.js similarity index 60% rename from test/acceptance/ported/support/ported_server_options.js rename to test/acceptance/ported/support/ported-server-options.js index cf040a48..ea84a4d2 100644 --- a/test/acceptance/ported/support/ported_server_options.js +++ b/test/acceptance/ported/support/ported-server-options.js @@ -1,43 +1,14 @@ 'use strict'; var _ = require('underscore'); -var serverOptions = require('../../../../lib/cartodb/server_options'); +var serverOptions = require('../../../../lib/server-options'); var mapnik = require('windshaft').mapnik; -var OverviewsQueryRewriter = require('../../../../lib/cartodb/utils/overviews_query_rewriter'); +var OverviewsQueryRewriter = require('../../../../lib/utils/overviews-query-rewriter'); var overviewsQueryRewriter = new OverviewsQueryRewriter({ zoom_level: 'CDB_ZoomFromScale(!scale_denominator!)' }); module.exports = _.extend({}, serverOptions, { - // FIXME: Remove it. This is no longer needed, paths are defined in routers - base_url: '/database/:dbname/table/:table', - // FIXME: Remove it. This is no longer needed, paths are defined in routers - base_url_mapconfig: '/database/:dbname/layergroup', - - routes: { - v0: { - paths: [ - '/tiles', - '/database/:dbname' - ], - // Base url for the Detached Maps API - // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - map: { - paths: [ - '/layergroup' - ] - }, - // Base url for the Templated Maps API - // "/tiles/template" is for compatibility with versions up to 1.6.x - template: { - paths: [ - '/template' - ] - } - } - }, - - grainstore: { datasource: { geometry_field: 'the_geom', diff --git a/test/acceptance/ported/support/test_client.js b/test/acceptance/ported/support/test-client.js similarity index 96% rename from test/acceptance/ported/support/test_client.js rename to test/acceptance/ported/support/test-client.js index 01d00bf2..e6328527 100644 --- a/test/acceptance/ported/support/test_client.js +++ b/test/acceptance/ported/support/test-client.js @@ -1,15 +1,15 @@ 'use strict'; -var testHelper = require('../../../support/test_helper'); -var LayergroupToken = require('../../../../lib/cartodb/models/layergroup-token'); +var testHelper = require('../../../support/test-helper'); +var LayergroupToken = require('../../../../lib/models/layergroup-token'); var step = require('step'); var assert = require('../../../support/assert'); var _ = require('underscore'); var querystring = require('querystring'); var mapnik = require('windshaft').mapnik; -var CartodbServer = require('../../../../lib/cartodb/server'); -var PortedServerOptions = require('./ported_server_options'); +var CartodbServer = require('../../../../lib/server'); +var PortedServerOptions = require('./ported-server-options'); var DEFAULT_POINT_STYLE = [ '#layer {', @@ -138,7 +138,7 @@ function layergroupRequest(layergroupConfig, method, callbackName, extraParams) method = method || 'POST'; var request = { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', headers: { host: 'localhost', 'Content-Type': 'application/json' @@ -346,7 +346,7 @@ function getGeneric(layergroupConfig, url, expectedResponse, callback) { function requestLayergroup() { var next = this; var request = { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', @@ -379,7 +379,7 @@ function getGeneric(layergroupConfig, url, expectedResponse, callback) { var next = this; - var finalUrl = '/database/windshaft_test/layergroup/' + _.template(url, { + var finalUrl = '/api/v1/map/' + _.template(url, { layergroupid: layergroupid }); @@ -475,7 +475,7 @@ function withLayergroup(layergroupConfig, options, callback) { const urlTpl = function ({layergroupid, cache_buster = null, tile }) { const { signer, token , cacheBuster } = LayergroupToken.parse(layergroupid); - const base = '/database/windshaft_test/layergroup/'; + const base = '/api/v1/map/'; return `${base}${signerTpl({signer})}${token}${cacheTpl({cache_buster, cacheBuster})}${tile}`; }; diff --git a/test/acceptance/ported/torque_boundaries.js b/test/acceptance/ported/torque-boundaries-test.js similarity index 95% rename from test/acceptance/ported/torque_boundaries.js rename to test/acceptance/ported/torque-boundaries-test.js index 1f0fcd80..e4854ac7 100644 --- a/test/acceptance/ported/torque_boundaries.js +++ b/test/acceptance/ported/torque-boundaries-test.js @@ -1,12 +1,12 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('torque boundary points', function() { var server; @@ -241,7 +241,7 @@ describe('torque boundary points', function() { it(desc, function (done) { assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(boundaryPointsMapConfig) @@ -255,7 +255,7 @@ describe('torque boundary points', function() { var partialUrl = tileRequest.z + '/' + tileRequest.x + '/' + tileRequest.y; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/' + partialUrl + '.json.torque', + url: '/api/v1/map/' + expected_token + '/0/' + partialUrl + '.json.torque', method: 'GET', headers: { host: 'localhost' @@ -358,7 +358,7 @@ describe('torque boundary points', function() { }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(londonPointMapConfig) @@ -371,7 +371,7 @@ describe('torque boundary points', function() { assert.response(server, { - url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/2/1/1.json.torque', + url: '/api/v1/map/' + layergroupId + '/0/2/1/1.json.torque', method: 'GET', headers: { host: 'localhost' @@ -424,7 +424,7 @@ describe('torque boundary points', function() { }; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(londonPointMapConfig) @@ -437,7 +437,7 @@ describe('torque boundary points', function() { assert.response(server, { - url: '/database/windshaft_test/layergroup/' + layergroupId + '/0/13/4255/2765.json.torque', + url: '/api/v1/map/' + layergroupId + '/0/13/4255/2765.json.torque', method: 'GET', headers: { host: 'localhost' diff --git a/test/acceptance/ported/torque_png.js b/test/acceptance/ported/torque-png-test.js similarity index 98% rename from test/acceptance/ported/torque_png.js rename to test/acceptance/ported/torque-png-test.js index 9c8480bd..1b0fed8e 100644 --- a/test/acceptance/ported/torque_png.js +++ b/test/acceptance/ported/torque-png-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); describe('torque png renderer', function() { var IMAGE_TOLERANCE_PER_MIL = 20; diff --git a/test/acceptance/ported/torque.js b/test/acceptance/ported/torque-test.js similarity index 93% rename from test/acceptance/ported/torque.js rename to test/acceptance/ported/torque-test.js index 82f3fda1..b40650cc 100644 --- a/test/acceptance/ported/torque.js +++ b/test/acceptance/ported/torque-test.js @@ -1,14 +1,14 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../../support/test-helper'); var assert = require('../../support/assert'); var _ = require('underscore'); var step = require('step'); -var cartodbServer = require('../../../lib/cartodb/server'); -var ServerOptions = require('./support/ported_server_options'); +var cartodbServer = require('../../../lib/server'); +var ServerOptions = require('./support/ported-server-options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('torque', function() { var server; @@ -54,7 +54,7 @@ describe('torque', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -77,7 +77,7 @@ describe('torque', function() { var css = 'Map { -torque-frame-count: 2; }'; layergroup.layers[0].options.cartocss = css; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -100,7 +100,7 @@ describe('torque', function() { var css = 'Map { -torque-frame-count: 2; -torque-resolution: 3; }'; layergroup.layers[0].options.cartocss = css; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -142,7 +142,7 @@ describe('torque', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -185,7 +185,7 @@ describe('torque', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(mapconfig) @@ -224,7 +224,7 @@ describe('torque', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0.png', + url: '/api/v1/map/' + expected_token + '/0/0/0.png', method: 'GET', encoding: 'binary', headers: { @@ -245,7 +245,7 @@ describe('torque', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.grid.json', + url: '/api/v1/map/' + expected_token + '/0/0/0/0.grid.json', method: 'GET', headers: { host: 'localhost' @@ -265,7 +265,7 @@ describe('torque', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.json.torque', + url: '/api/v1/map/' + expected_token + '/0/0/0/0.json.torque', method: 'GET', headers: { host: 'localhost' @@ -286,7 +286,7 @@ describe('torque', function() { assert.ifError(err); var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup/' + expected_token + '/0/0/0/0.torque.json', + url: '/api/v1/map/' + expected_token + '/0/0/0/0.torque.json', method: 'GET', headers: { host: 'localhost' @@ -333,7 +333,7 @@ describe('torque', function() { { var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(mapconfig) @@ -382,7 +382,7 @@ describe('torque', function() { var next = this; global.environment.postgres.port = 54777; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(mapconfig) @@ -431,7 +431,7 @@ describe('torque', function() { function request(){ var next = this; assert.response(server, { - url: '/database/windshaft_test/layergroup', + url: '/api/v1/map', method: 'POST', headers: { host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) diff --git a/test/acceptance/ported/torque_zero_zero.js b/test/acceptance/ported/torque-zero-zero-test.js similarity index 96% rename from test/acceptance/ported/torque_zero_zero.js rename to test/acceptance/ported/torque-zero-zero-test.js index 2d81f517..9b76183e 100644 --- a/test/acceptance/ported/torque_zero_zero.js +++ b/test/acceptance/ported/torque-zero-zero-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); describe('torque tiles at 0,0 point', function() { /* diff --git a/test/acceptance/ported/wrap.js b/test/acceptance/ported/wrap-test.js similarity index 98% rename from test/acceptance/ported/wrap.js rename to test/acceptance/ported/wrap-test.js index 6434d6fa..cafa2ea3 100644 --- a/test/acceptance/ported/wrap.js +++ b/test/acceptance/ported/wrap-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); -var testClient = require('./support/test_client'); +var testClient = require('./support/test-client'); describe('wrap x coordinate', function() { describe('renders correct tile', function() { diff --git a/test/acceptance/rate-limit.test.js b/test/acceptance/rate-limit-test.js similarity index 97% rename from test/acceptance/rate-limit.test.js rename to test/acceptance/rate-limit-test.js index f5b6f456..4560fd57 100644 --- a/test/acceptance/rate-limit.test.js +++ b/test/acceptance/rate-limit-test.js @@ -1,15 +1,15 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const redis = require('redis'); const RedisPool = require('redis-mpool'); const cartodbRedis = require('cartodb-redis'); const TestClient = require('../support/test-client'); -const UserLimitsBackend = require('../../lib/cartodb/backends/user-limits'); -const rateLimitMiddleware = require('../../lib/cartodb/api/middlewares/rate-limit'); -const serverOptions = require('../../lib/cartodb/server_options'); +const UserLimitsBackend = require('../../lib/backends/user-limits'); +const rateLimitMiddleware = require('../../lib/api/middlewares/rate-limit'); +const serverOptions = require('../../lib/server-options'); const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitMiddleware; let userLimitsApi; diff --git a/test/acceptance/regressions.js b/test/acceptance/regressions-test.js similarity index 95% rename from test/acceptance/regressions.js rename to test/acceptance/regressions-test.js index 21d9c970..8ac63a83 100644 --- a/test/acceptance/regressions.js +++ b/test/acceptance/regressions-test.js @@ -1,12 +1,12 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('../support/assert'); -const helper = require('../support/test_helper'); +const helper = require('../support/test-helper'); var TestClient = require('../support/test-client'); -const LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); -const CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -const serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +const LayergroupToken = require('../../lib/models/layergroup-token'); +const CartodbWindshaft = require('../../lib/server'); +const serverOptions = require('../../lib/server-options'); describe('regressions', function() { diff --git a/test/acceptance/server.js b/test/acceptance/server-test.js similarity index 94% rename from test/acceptance/server.js rename to test/acceptance/server-test.js index 183d6bac..976066a7 100644 --- a/test/acceptance/server.js +++ b/test/acceptance/server-test.js @@ -1,13 +1,13 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('../support/assert'); var querystring = require('querystring'); var step = require('step'); -var CartodbWindshaft = require('../../lib/cartodb/server'); -var serverOptions = require('../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); describe('server', function() { diff --git a/test/acceptance/special-numeric-values.js b/test/acceptance/special-numeric-values-test.js similarity index 98% rename from test/acceptance/special-numeric-values.js rename to test/acceptance/special-numeric-values-test.js index 6b328286..0ac183fd 100644 --- a/test/acceptance/special-numeric-values.js +++ b/test/acceptance/special-numeric-values-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('../support/assert'); var TestClient = require('../support/test-client'); diff --git a/test/acceptance/sql-wrap.js b/test/acceptance/sql-wrap-test.js similarity index 98% rename from test/acceptance/sql-wrap.js rename to test/acceptance/sql-wrap-test.js index 7b2f9d57..87eb705f 100644 --- a/test/acceptance/sql-wrap.js +++ b/test/acceptance/sql-wrap-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('../support/assert'); var TestClient = require('../support/test-client'); diff --git a/test/acceptance/stats/mapnik_stats_layergroup.js b/test/acceptance/stats/mapnik-stats-layergroup-test.js similarity index 99% rename from test/acceptance/stats/mapnik_stats_layergroup.js rename to test/acceptance/stats/mapnik-stats-layergroup-test.js index 55ca7a64..0071a3ae 100644 --- a/test/acceptance/stats/mapnik_stats_layergroup.js +++ b/test/acceptance/stats/mapnik-stats-layergroup-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); -const serverOptions = require('../../../lib/cartodb/server_options'); +const serverOptions = require('../../../lib/server-options'); const suites = [ { diff --git a/test/acceptance/stats/multilayer_stats.js b/test/acceptance/stats/multilayer-stats-test.js similarity index 99% rename from test/acceptance/stats/multilayer_stats.js rename to test/acceptance/stats/multilayer-stats-test.js index dcf9b402..17b3fe14 100644 --- a/test/acceptance/stats/multilayer_stats.js +++ b/test/acceptance/stats/multilayer-stats-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/templates.js b/test/acceptance/templates-test.js similarity index 99% rename from test/acceptance/templates.js rename to test/acceptance/templates-test.js index 72e6fa73..b9c36b63 100644 --- a/test/acceptance/templates.js +++ b/test/acceptance/templates-test.js @@ -6,7 +6,7 @@ var redis = require('redis'); var step = require('step'); var strftime = require('strftime'); var QueryTables = require('cartodb-query-tables').queryTables; -var NamedMapsCacheEntry = require('../../lib/cartodb/cache/model/named_maps_entry'); +var NamedMapsCacheEntry = require('../../lib/cache/model/named-maps-entry'); var redis_stats_db = 5; // Pollute the PG environment to make sure @@ -18,12 +18,12 @@ process.env.PGHOST = 'fake'; var fs = require('fs'); var http = require('http'); -var helper = require(__dirname + '/../support/test_helper'); +var helper = require('../support/test-helper'); -var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server'); -var serverOptions = require(__dirname + '/../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../lib/models/layergroup-token'); describe('template_api', function() { var server; diff --git a/test/acceptance/tilejson.js b/test/acceptance/tilejson-test.js similarity index 98% rename from test/acceptance/tilejson.js rename to test/acceptance/tilejson-test.js index 19ef158f..1c0ea21b 100644 --- a/test/acceptance/tilejson.js +++ b/test/acceptance/tilejson-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); -const serverOptions = require('../../lib/cartodb/server_options'); +const serverOptions = require('../../lib/server-options'); const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS; diff --git a/test/acceptance/turbo-carto/anonymous-maps.js b/test/acceptance/turbo-carto/anonymous-maps-test.js similarity index 100% rename from test/acceptance/turbo-carto/anonymous-maps.js rename to test/acceptance/turbo-carto/anonymous-maps-test.js diff --git a/test/acceptance/turbo-carto/error-cases.js b/test/acceptance/turbo-carto/error-cases-test.js similarity index 99% rename from test/acceptance/turbo-carto/error-cases.js rename to test/acceptance/turbo-carto/error-cases-test.js index 94b07fe0..5b7df33c 100644 --- a/test/acceptance/turbo-carto/error-cases.js +++ b/test/acceptance/turbo-carto/error-cases-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/turbo-carto/named-maps.js b/test/acceptance/turbo-carto/named-maps-test.js similarity index 97% rename from test/acceptance/turbo-carto/named-maps.js rename to test/acceptance/turbo-carto/named-maps-test.js index 6a302498..c8e389a8 100644 --- a/test/acceptance/turbo-carto/named-maps.js +++ b/test/acceptance/turbo-carto/named-maps-test.js @@ -2,10 +2,10 @@ var assert = require('../../support/assert'); var step = require('step'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); -var testHelper = require('../../support/test_helper'); -var CartodbWindshaft = require('../../../lib/cartodb/server'); -var serverOptions = require('../../../lib/cartodb/server_options'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); +var testHelper = require('../../support/test-helper'); +var CartodbWindshaft = require('../../../lib/server'); +var serverOptions = require('../../../lib/server-options'); var mapnik = require('windshaft').mapnik; var IMAGE_TOLERANCE_PER_MIL = 10; diff --git a/test/acceptance/turbo-carto/regressions.js b/test/acceptance/turbo-carto/regressions-test.js similarity index 99% rename from test/acceptance/turbo-carto/regressions.js rename to test/acceptance/turbo-carto/regressions-test.js index 40dec6de..66769da1 100644 --- a/test/acceptance/turbo-carto/regressions.js +++ b/test/acceptance/turbo-carto/regressions-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/user-database-timeout-limit.js b/test/acceptance/user-database-timeout-limit-test.js similarity index 99% rename from test/acceptance/user-database-timeout-limit.js rename to test/acceptance/user-database-timeout-limit-test.js index 629d3778..747ef2c2 100644 --- a/test/acceptance/user-database-timeout-limit.js +++ b/test/acceptance/user-database-timeout-limit-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); -const serverOptions = require('../../lib/cartodb/server_options'); +const serverOptions = require('../../lib/server-options'); const timeoutErrorTilePath = `${process.cwd()}/assets/render-timeout-fallback.png`; diff --git a/test/acceptance/user-render-timeout-limit.js b/test/acceptance/user-render-timeout-limit-test.js similarity index 99% rename from test/acceptance/user-render-timeout-limit.js rename to test/acceptance/user-render-timeout-limit-test.js index a011ce70..37083752 100644 --- a/test/acceptance/user-render-timeout-limit.js +++ b/test/acceptance/user-render-timeout-limit-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); -var serverOptions = require('../../lib/cartodb/server_options'); +var serverOptions = require('../../lib/server-options'); const timeoutErrorTilePath = `${process.cwd()}/assets/render-timeout-fallback.png`; diff --git a/test/acceptance/vector-layergroup.js b/test/acceptance/vector-layergroup-test.js similarity index 98% rename from test/acceptance/vector-layergroup.js rename to test/acceptance/vector-layergroup-test.js index d23403db..47fdf1be 100644 --- a/test/acceptance/vector-layergroup.js +++ b/test/acceptance/vector-layergroup-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); const assert = require('../support/assert'); const TestClient = require('../support/test-client'); -const serverOptions = require('../../lib/cartodb/server_options'); +const serverOptions = require('../../lib/server-options'); const POINTS_SQL_1 = ` diff --git a/test/acceptance/widgets/aggregation.js b/test/acceptance/widgets/aggregation-test.js similarity index 98% rename from test/acceptance/widgets/aggregation.js rename to test/acceptance/widgets/aggregation-test.js index 8977ef19..dbca2c82 100644 --- a/test/acceptance/widgets/aggregation.js +++ b/test/acceptance/widgets/aggregation-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/widgets/histogram.js b/test/acceptance/widgets/histogram-test.js similarity index 99% rename from test/acceptance/widgets/histogram.js rename to test/acceptance/widgets/histogram-test.js index 503218e9..dafed514 100644 --- a/test/acceptance/widgets/histogram.js +++ b/test/acceptance/widgets/histogram-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/widgets/named-maps.js b/test/acceptance/widgets/named-maps-test.js similarity index 96% rename from test/acceptance/widgets/named-maps.js rename to test/acceptance/widgets/named-maps-test.js index ab136dc0..622b7bc0 100644 --- a/test/acceptance/widgets/named-maps.js +++ b/test/acceptance/widgets/named-maps-test.js @@ -6,12 +6,12 @@ var step = require('step'); var url = require('url'); var queue = require('queue-async'); -var helper = require('../../support/test_helper'); +var helper = require('../../support/test-helper'); -var CartodbWindshaft = require('../../../lib/cartodb/server'); -var serverOptions = require('../../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../../lib/server'); +var serverOptions = require('../../../lib/server-options'); -var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../../lib/models/layergroup-token'); describe('named-maps widgets', function() { var server; diff --git a/test/acceptance/widgets/ported/aggregation.js b/test/acceptance/widgets/ported/aggregation-test.js similarity index 99% rename from test/acceptance/widgets/ported/aggregation.js rename to test/acceptance/widgets/ported/aggregation-test.js index 2f36d3bb..d16faad2 100644 --- a/test/acceptance/widgets/ported/aggregation.js +++ b/test/acceptance/widgets/ported/aggregation-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../../support/test_helper'); +require('../../../support/test-helper'); var assert = require('../../../support/assert'); var TestClient = require('../../../support/test-client'); diff --git a/test/acceptance/widgets/ported/formula.js b/test/acceptance/widgets/ported/formula-test.js similarity index 98% rename from test/acceptance/widgets/ported/formula.js rename to test/acceptance/widgets/ported/formula-test.js index c3ca2bc6..546c86d3 100644 --- a/test/acceptance/widgets/ported/formula.js +++ b/test/acceptance/widgets/ported/formula-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../../support/test_helper'); +require('../../../support/test-helper'); var assert = require('../../../support/assert'); var TestClient = require('../../../support/test-client'); diff --git a/test/acceptance/widgets/ported/histogram.js b/test/acceptance/widgets/ported/histogram-test.js similarity index 99% rename from test/acceptance/widgets/ported/histogram.js rename to test/acceptance/widgets/ported/histogram-test.js index 510feb9e..587a7fef 100644 --- a/test/acceptance/widgets/ported/histogram.js +++ b/test/acceptance/widgets/ported/histogram-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../../support/test_helper'); +require('../../../support/test-helper'); var assert = require('../../../support/assert'); var TestClient = require('../../../support/test-client'); diff --git a/test/acceptance/widgets/regressions.js b/test/acceptance/widgets/regressions-test.js similarity index 99% rename from test/acceptance/widgets/regressions.js rename to test/acceptance/widgets/regressions-test.js index 755e2a96..6b67a138 100644 --- a/test/acceptance/widgets/regressions.js +++ b/test/acceptance/widgets/regressions-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/acceptance/widgets/widgets.js b/test/acceptance/widgets/widgets-test.js similarity index 99% rename from test/acceptance/widgets/widgets.js rename to test/acceptance/widgets/widgets-test.js index 94ecb0a2..a760a5c4 100644 --- a/test/acceptance/widgets/widgets.js +++ b/test/acceptance/widgets/widgets-test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../support/test_helper'); +require('../../support/test-helper'); var assert = require('../../support/assert'); var TestClient = require('../../support/test-client'); diff --git a/test/integration/analysis-backend-limits.js b/test/integration/analysis-backend-limits-test.js similarity index 97% rename from test/integration/analysis-backend-limits.js rename to test/integration/analysis-backend-limits-test.js index 21e7d9cc..be16ef90 100644 --- a/test/integration/analysis-backend-limits.js +++ b/test/integration/analysis-backend-limits-test.js @@ -1,6 +1,6 @@ 'use strict'; -var testHelper = require('../support/test_helper'); +var testHelper = require('../support/test-helper'); var assert = require('assert'); var redis = require('redis'); @@ -8,7 +8,7 @@ var redis = require('redis'); var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); -var AnalysisBackend = require('../../lib/cartodb/backends/analysis'); +var AnalysisBackend = require('../../lib/backends/analysis'); describe('analysis-backend limits', function() { diff --git a/test/integration/mapconfig_named_layers_datasource.js b/test/integration/mapconfig-named-layers-datasource-test.js similarity index 97% rename from test/integration/mapconfig_named_layers_datasource.js rename to test/integration/mapconfig-named-layers-datasource-test.js index d3eefd28..261069cb 100644 --- a/test/integration/mapconfig_named_layers_datasource.js +++ b/test/integration/mapconfig-named-layers-datasource-test.js @@ -1,12 +1,12 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js'); -var PgConnection = require(__dirname + '/../../lib/cartodb/backends/pg_connection'); -var MapConfigNamedLayersAdapter = require('../../lib/cartodb/models/mapconfig/adapter/mapconfig-named-layers-adapter'); +var TemplateMaps = require('../../lib/backends/template-maps'); +var PgConnection = require('../../lib/backends/pg-connection'); +var MapConfigNamedLayersAdapter = require('../../lib/models/mapconfig/adapter/mapconfig-named-layers-adapter'); // configure redis pool instance to use in tests var redisPool = new RedisPool(global.environment.redis); diff --git a/test/integration/mapconfig_named_layers_expanded.js b/test/integration/mapconfig-named-layers-expanded-test.js similarity index 97% rename from test/integration/mapconfig_named_layers_expanded.js rename to test/integration/mapconfig-named-layers-expanded-test.js index ea3a34a4..b0d2ea22 100644 --- a/test/integration/mapconfig_named_layers_expanded.js +++ b/test/integration/mapconfig-named-layers-expanded-test.js @@ -1,12 +1,12 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js'); -var PgConnection = require(__dirname + '/../../lib/cartodb/backends/pg_connection'); -var MapConfigNamedLayersAdapter = require('../../lib/cartodb/models/mapconfig/adapter/mapconfig-named-layers-adapter'); +var TemplateMaps = require('../../lib/backends/template-maps'); +var PgConnection = require('../../lib/backends/pg-connection'); +var MapConfigNamedLayersAdapter = require('../../lib/models/mapconfig/adapter/mapconfig-named-layers-adapter'); describe('mapconfig-named-layers-adapter', function() { diff --git a/test/integration/mapconfig_overviews_adapter.js b/test/integration/mapconfig-overviews-adapter-test.js similarity index 88% rename from test/integration/mapconfig_overviews_adapter.js rename to test/integration/mapconfig-overviews-adapter-test.js index 64a2d0c9..e1bb932a 100644 --- a/test/integration/mapconfig_overviews_adapter.js +++ b/test/integration/mapconfig-overviews-adapter-test.js @@ -1,15 +1,15 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); 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 OverviewsMetadataBackend = require('../../lib/cartodb/backends/overviews-metadata'); -var FilterStatsBackend = require('../../lib/cartodb/backends/filter-stats'); -var MapConfigOverviewsAdapter = require('../../lib/cartodb/models/mapconfig/adapter/mapconfig-overviews-adapter'); +var PgConnection = require('../../lib/backends/pg-connection'); +var PgQueryRunner = require('../../lib/backends/pg-query-runner'); +var OverviewsMetadataBackend = require('../../lib/backends/overviews-metadata'); +var FilterStatsBackend = require('../../lib/backends/filter-stats'); +var MapConfigOverviewsAdapter = require('../../lib/models/mapconfig/adapter/mapconfig-overviews-adapter'); var redisPool = new RedisPool(global.environment.redis); var metadataBackend = cartodbRedis({pool: redisPool}); diff --git a/test/integration/overviews-metadata-api.js b/test/integration/overviews-metadata-api-test.js similarity index 84% rename from test/integration/overviews-metadata-api.js rename to test/integration/overviews-metadata-api-test.js index c3e241ec..237fb2f9 100644 --- a/test/integration/overviews-metadata-api.js +++ b/test/integration/overviews-metadata-api-test.js @@ -1,15 +1,15 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); -var PgConnection = require('../../lib/cartodb/backends/pg_connection'); -var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); -var OverviewsMetadataBackend = require('../../lib/cartodb/backends/overviews-metadata'); +var PgConnection = require('../../lib/backends/pg-connection'); +var PgQueryRunner = require('../../lib/backends/pg-query-runner'); +var OverviewsMetadataBackend = require('../../lib/backends/overviews-metadata'); describe('OverviewsMetadataBackend', function() { diff --git a/test/integration/pg-query-runner.js b/test/integration/pg-query-runner-test.js similarity index 86% rename from test/integration/pg-query-runner.js rename to test/integration/pg-query-runner-test.js index a979ee81..e7f403f4 100644 --- a/test/integration/pg-query-runner.js +++ b/test/integration/pg-query-runner-test.js @@ -1,14 +1,14 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); -var PgConnection = require('../../lib/cartodb/backends/pg_connection'); -var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); +var PgConnection = require('../../lib/backends/pg-connection'); +var PgQueryRunner = require('../../lib/backends/pg-query-runner'); describe('PgQueryRunner', function() { diff --git a/test/integration/profiler.js b/test/integration/profiler-test.js similarity index 87% rename from test/integration/profiler.js rename to test/integration/profiler-test.js index 4bc7ee0e..2db98261 100644 --- a/test/integration/profiler.js +++ b/test/integration/profiler-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); -var StatsClient = require('../../lib/cartodb/stats/client'); -var ProfilerProxy = require('../../lib/cartodb/stats/profiler_proxy'); +var StatsClient = require('../../lib/stats/client'); +var ProfilerProxy = require('../../lib/stats/profiler-proxy'); describe('profiler + statsd', function() { var statsInstance; diff --git a/test/integration/query-tables.js b/test/integration/query-tables-test.js similarity index 95% rename from test/integration/query-tables.js rename to test/integration/query-tables-test.js index 721de841..e44d66b9 100644 --- a/test/integration/query-tables.js +++ b/test/integration/query-tables-test.js @@ -1,13 +1,13 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); -var PgConnection = require('../../lib/cartodb/backends/pg_connection'); +var PgConnection = require('../../lib/backends/pg-connection'); var QueryTables = require('cartodb-query-tables').queryTables; diff --git a/test/integration/template-maps-limits.js b/test/integration/template-maps-limits-test.js similarity index 95% rename from test/integration/template-maps-limits.js rename to test/integration/template-maps-limits-test.js index 37f3ca9f..95bcc410 100644 --- a/test/integration/template-maps-limits.js +++ b/test/integration/template-maps-limits-test.js @@ -1,11 +1,11 @@ 'use strict'; -require('../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var redis = require('redis'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../lib/cartodb/backends/template_maps'); +var TemplateMaps = require('../../lib/backends/template-maps'); describe('TemplateMaps limits', function() { diff --git a/test/support/test-client.js b/test/support/test-client.js index 5d88f6e0..0483f0ce 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -7,13 +7,13 @@ var PSQL = require('cartodb-psql'); var _ = require('underscore'); var mapnik = require('windshaft').mapnik; -var LayergroupToken = require('../../lib/cartodb/models/layergroup-token'); +var LayergroupToken = require('../../lib/models/layergroup-token'); var assert = require('./assert'); -var helper = require('./test_helper'); +var helper = require('./test-helper'); -var CartodbWindshaft = require('../../lib/cartodb/server'); -var serverOptions = require('../../lib/cartodb/server_options'); +var CartodbWindshaft = require('../../lib/server'); +var serverOptions = require('../../lib/server-options'); serverOptions.analysis.batch.inlineExecution = true; const MAPNIK_SUPPORTED_FORMATS = { diff --git a/test/support/test_helper.js b/test/support/test-helper.js similarity index 97% rename from test/support/test_helper.js rename to test/support/test-helper.js index 55fad97a..1ae8d77d 100644 --- a/test/support/test_helper.js +++ b/test/support/test-helper.js @@ -15,10 +15,10 @@ var lzmaWorker = new LZMA(); var redis = require('redis'); var log4js = require('log4js'); -const setICUEnvVariable = require('../../lib/cartodb/utils/icu_data_env_setter'); +const setICUEnvVariable = require('../../lib/utils/icu-data-env-setter'); // set environment specific variables -global.environment = require(__dirname + '/../../config/environments/test'); +global.environment = require('../../config/environments/test'); global.environment.name = 'test'; process.env.NODE_ENV = 'test'; diff --git a/test/unit/cartodb/backends/layer-stats/mapnik-layer-stats.js b/test/unit/backends/layer-stats/mapnik-layer-stats-test.js similarity index 98% rename from test/unit/cartodb/backends/layer-stats/mapnik-layer-stats.js rename to test/unit/backends/layer-stats/mapnik-layer-stats-test.js index 874fba28..6860a781 100644 --- a/test/unit/cartodb/backends/layer-stats/mapnik-layer-stats.js +++ b/test/unit/backends/layer-stats/mapnik-layer-stats-test.js @@ -1,7 +1,7 @@ 'use strict'; var assert = require('assert'); -var MapnikLayerStats = require('../../../../../lib/cartodb/backends/layer-stats/mapnik-layer-stats'); +var MapnikLayerStats = require('../../../../lib/backends/layer-stats/mapnik-layer-stats'); var MapConfig = require('windshaft').model.MapConfig; function getDbConnectionMock () { diff --git a/test/unit/cartodb/backends/layer-stats/torque-layer-stats.js b/test/unit/backends/layer-stats/torque-layer-stats-test.js similarity index 91% rename from test/unit/cartodb/backends/layer-stats/torque-layer-stats.js rename to test/unit/backends/layer-stats/torque-layer-stats-test.js index c00260c8..6156bbe6 100644 --- a/test/unit/cartodb/backends/layer-stats/torque-layer-stats.js +++ b/test/unit/backends/layer-stats/torque-layer-stats-test.js @@ -1,7 +1,7 @@ 'use strict'; var assert = require('assert'); -var TorqueLayerStats = require('../../../../../lib/cartodb/backends/layer-stats/torque-layer-stats'); +var TorqueLayerStats = require('../../../../lib/backends/layer-stats/torque-layer-stats'); var MapConfig = require('windshaft').model.MapConfig; describe('torque-layer-stats', function () { diff --git a/test/unit/cartodb/backends/turbo-carto-postgres-datasource.js b/test/unit/backends/turbo-carto-postgres-datasource-test.js similarity index 93% rename from test/unit/cartodb/backends/turbo-carto-postgres-datasource.js rename to test/unit/backends/turbo-carto-postgres-datasource-test.js index 861f51d8..303517e1 100644 --- a/test/unit/cartodb/backends/turbo-carto-postgres-datasource.js +++ b/test/unit/backends/turbo-carto-postgres-datasource-test.js @@ -1,6 +1,6 @@ 'use strict'; -var PostgresDatasource = require('../../../../lib/cartodb/backends/turbo-carto-postgres-datasource'); +var PostgresDatasource = require('../../../lib/backends/turbo-carto-postgres-datasource'); var PSQL = require('cartodb-psql'); var _ = require('underscore'); var assert = require('assert'); diff --git a/test/unit/cartodb/cache/model/named_maps_entry.test.js b/test/unit/cache/model/named-maps-entry-test.js similarity index 81% rename from test/unit/cartodb/cache/model/named_maps_entry.test.js rename to test/unit/cache/model/named-maps-entry-test.js index 335f30c7..69ba81b2 100644 --- a/test/unit/cartodb/cache/model/named_maps_entry.test.js +++ b/test/unit/cache/model/named-maps-entry-test.js @@ -1,12 +1,12 @@ 'use strict'; -require('../../../../support/test_helper'); +require('../../../support/test-helper'); var assert = require('assert'); var _ = require('underscore'); -var NamedMapsCacheEntry = require('../../../../../lib/cartodb/cache/model/named_maps_entry'); +var NamedMapsCacheEntry = require('../../../../lib/cache/model/named-maps-entry'); -describe('cache named_maps_entry', function() { +describe('cache named maps entry', function() { var namedMapOwner = 'foo', namedMapName = 'wadus_name', diff --git a/test/unit/cartodb/cdb_request.test.js b/test/unit/cdb-request-test.js similarity index 95% rename from test/unit/cartodb/cdb_request.test.js rename to test/unit/cdb-request-test.js index 0dbf35a3..49b1253b 100644 --- a/test/unit/cartodb/cdb_request.test.js +++ b/test/unit/cdb-request-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); -var CdbRequest = require('../../../lib/cartodb/models/cdb_request'); +var CdbRequest = require('../../lib/models/cdb-request'); describe('req2params', function() { diff --git a/test/unit/cartodb/error_messages.test.js b/test/unit/error-messages-test.js similarity index 86% rename from test/unit/cartodb/error_messages.test.js rename to test/unit/error-messages-test.js index 13ea1661..86b3b43a 100644 --- a/test/unit/cartodb/error_messages.test.js +++ b/test/unit/error-messages-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); -var errorMiddleware = require('../../../lib/cartodb/api/middlewares/error-middleware'); +var errorMiddleware = require('../../lib/api/middlewares/error-middleware'); describe('error messages clean up', function() { diff --git a/test/unit/cartodb/error-middleware.test.js b/test/unit/error-middleware-test.js similarity index 97% rename from test/unit/cartodb/error-middleware.test.js rename to test/unit/error-middleware-test.js index 1f17ed9c..d7670c6a 100644 --- a/test/unit/cartodb/error-middleware.test.js +++ b/test/unit/error-middleware-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper.js'); +require('../support/test-helper'); var assert = require('assert'); -var errorMiddleware = require('../../../lib/cartodb/api/middlewares/error-middleware'); +var errorMiddleware = require('../../lib/api/middlewares/error-middleware'); describe('error-middleware', function() { diff --git a/test/unit/cartodb/lzmaMiddleware.test.js b/test/unit/lzma-middleware-test.js similarity index 89% rename from test/unit/cartodb/lzmaMiddleware.test.js rename to test/unit/lzma-middleware-test.js index 4dc355fb..b176a207 100644 --- a/test/unit/cartodb/lzmaMiddleware.test.js +++ b/test/unit/lzma-middleware-test.js @@ -1,9 +1,9 @@ 'use strict'; var assert = require('assert'); -var testHelper = require('../../support/test_helper'); +var testHelper = require('../support/test-helper'); -var lzmaMiddleware = require('../../../lib/cartodb/api/middlewares/lzma'); +var lzmaMiddleware = require('../../lib/api/middlewares/lzma'); describe('lzma-middleware', function() { diff --git a/test/unit/cartodb/mapconfig/adapter.test.js b/test/unit/mapconfig/adapter-test.js similarity index 96% rename from test/unit/cartodb/mapconfig/adapter.test.js rename to test/unit/mapconfig/adapter-test.js index d2832c78..5adeb4a5 100644 --- a/test/unit/cartodb/mapconfig/adapter.test.js +++ b/test/unit/mapconfig/adapter-test.js @@ -1,9 +1,9 @@ 'use strict'; -//require('../../../support/test_helper'); +//require('../../../support/test-helper'); var assert = require('assert'); -var MapConfigAdapter = require('../../../../lib/cartodb/models/mapconfig/adapter'); +var MapConfigAdapter = require('../../../lib/models/mapconfig/adapter'); describe('MapConfigAdapter', function() { var user = 'wadus'; diff --git a/test/unit/cartodb/mapconfig/dataviews-widgets-adapter.test.js b/test/unit/mapconfig/dataviews-widgets-adapter-test.js similarity index 98% rename from test/unit/cartodb/mapconfig/dataviews-widgets-adapter.test.js rename to test/unit/mapconfig/dataviews-widgets-adapter-test.js index 58eaa709..1b1e657b 100644 --- a/test/unit/cartodb/mapconfig/dataviews-widgets-adapter.test.js +++ b/test/unit/mapconfig/dataviews-widgets-adapter-test.js @@ -1,9 +1,9 @@ 'use strict'; -//require('../../../support/test_helper'); +//require('../../../support/test-helper'); var assert = require('assert'); -var DataviewsMapConfigAdapter = require('../../../../lib/cartodb/models/mapconfig/adapter/dataviews-widgets-adapter'); +var DataviewsMapConfigAdapter = require('../../../lib/models/mapconfig/adapter/dataviews-widgets-adapter'); describe('dataviews-widgets-adapter', function() { diff --git a/test/unit/cartodb/middlewares/coordinates.test.js b/test/unit/middlewares/coordinates-test.js similarity index 98% rename from test/unit/cartodb/middlewares/coordinates.test.js rename to test/unit/middlewares/coordinates-test.js index f6c39d88..f2f94357 100644 --- a/test/unit/cartodb/middlewares/coordinates.test.js +++ b/test/unit/middlewares/coordinates-test.js @@ -1,7 +1,7 @@ 'use strict'; const assert = require('assert'); -const coordinates = require('../../../../lib/cartodb/api/middlewares/coordinates'); +const coordinates = require('../../../lib/api/middlewares/coordinates'); describe('coordinates middleware', function () { it('should return error: invalid zoom paramenter (-1)', function (done) { diff --git a/test/unit/cartodb/model/filter/bbox-filters.test.js b/test/unit/model/filter/bbox-filters-test.js similarity index 96% rename from test/unit/cartodb/model/filter/bbox-filters.test.js rename to test/unit/model/filter/bbox-filters-test.js index a0e7a14b..6e5100a6 100644 --- a/test/unit/cartodb/model/filter/bbox-filters.test.js +++ b/test/unit/model/filter/bbox-filters-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../../../support/test_helper'); +require('../../../support/test-helper'); var util = require('util'); -var assert = require('../../../../support/assert'); -var BboxFilter = require('../../../../../lib/cartodb/models/filter/bbox'); +var assert = require('../../../support/assert'); +var BboxFilter = require('../../../../lib/models/filter/bbox'); var MAX_EXTENT_MERCATOR_REF = [ -BboxFilter.LONGITUDE_MAX_VALUE, diff --git a/test/unit/cartodb/model/resource-locator.test.js b/test/unit/model/resource-locator-test.js similarity index 98% rename from test/unit/cartodb/model/resource-locator.test.js rename to test/unit/model/resource-locator-test.js index e9571c3e..b26ebf54 100644 --- a/test/unit/cartodb/model/resource-locator.test.js +++ b/test/unit/model/resource-locator-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../../support/test_helper'); +require('../../support/test-helper'); -var assert = require('../../../support/assert'); -var ResourceLocator = require('../../../../lib/cartodb/models/resource-locator'); +var assert = require('../../support/assert'); +var ResourceLocator = require('../../../lib/models/resource-locator'); describe('ResourceLocator', function() { var USERNAME = 'username'; diff --git a/test/unit/cartodb/overviews_query_rewriter.js b/test/unit/overviews-query-rewriter-test.js similarity index 99% rename from test/unit/cartodb/overviews_query_rewriter.js rename to test/unit/overviews-query-rewriter-test.js index a3d07e4c..4b54d426 100644 --- a/test/unit/cartodb/overviews_query_rewriter.js +++ b/test/unit/overviews-query-rewriter-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); -var OverviewsQueryRewriter = require('../../../lib/cartodb/utils/overviews_query_rewriter'); +var OverviewsQueryRewriter = require('../../lib/utils/overviews-query-rewriter'); var overviewsQueryRewriter = new OverviewsQueryRewriter({ zoom_level: 'ZoomLevel()' }); diff --git a/test/unit/cartodb/ported/profiler.test.js b/test/unit/ported/profiler-test.js similarity index 81% rename from test/unit/cartodb/ported/profiler.test.js rename to test/unit/ported/profiler-test.js index d9bc775e..5dcedf9a 100644 --- a/test/unit/cartodb/ported/profiler.test.js +++ b/test/unit/ported/profiler-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../../support/test_helper'); +require('../../support/test-helper'); var assert = require('assert'); -var ProfilerProxy = require('../../../../lib/cartodb/stats/profiler_proxy'); +var ProfilerProxy = require('../../../lib/stats/profiler-proxy'); describe('profiler', function() { diff --git a/test/unit/cartodb/ported/stats_client.test.js b/test/unit/ported/stats-client-test.js similarity index 91% rename from test/unit/cartodb/ported/stats_client.test.js rename to test/unit/ported/stats-client-test.js index 230d8b25..dba123b5 100644 --- a/test/unit/cartodb/ported/stats_client.test.js +++ b/test/unit/ported/stats-client-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../../support/test_helper'); +require('../../support/test-helper'); var assert = require('assert'); -var StatsClient = require('../../../../lib/cartodb/stats/client'); +var StatsClient = require('../../../lib/stats/client'); describe('stats client', function() { var statsInstance; diff --git a/test/unit/cartodb/ported/windshaft_server.test.js b/test/unit/ported/windshaft-server-test.js similarity index 84% rename from test/unit/cartodb/ported/windshaft_server.test.js rename to test/unit/ported/windshaft-server-test.js index 1591dc45..3085c266 100644 --- a/test/unit/cartodb/ported/windshaft_server.test.js +++ b/test/unit/ported/windshaft-server-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../../support/test_helper.js'); +require('../../support/test-helper'); var assert = require('assert'); -var cartodbServer = require('../../../../lib/cartodb/server'); -var serverOptions = require('../../../../lib/cartodb/server_options'); +var cartodbServer = require('../../../lib/server'); +var serverOptions = require('../../../lib/server-options'); describe('windshaft', function() { diff --git a/test/unit/cartodb/prepare-context.test.js b/test/unit/prepare-context-test.js similarity index 92% rename from test/unit/cartodb/prepare-context.test.js rename to test/unit/prepare-context-test.js index 5de8a677..b8675f99 100644 --- a/test/unit/cartodb/prepare-context.test.js +++ b/test/unit/prepare-context-test.js @@ -5,14 +5,14 @@ var _ = require('underscore'); var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); -var PgConnection = require('../../../lib/cartodb/backends/pg_connection'); -var AuthBackend = require('../../../lib/cartodb/backends/auth'); -var TemplateMaps = require('../../../lib/cartodb/backends/template_maps'); +var PgConnection = require('../../lib/backends/pg-connection'); +var AuthBackend = require('../../lib/backends/auth'); +var TemplateMaps = require('../../lib/backends/template-maps'); -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'); +const cleanUpQueryParamsMiddleware = require('../../lib/api/middlewares/clean-up-query-params'); +const authorizeMiddleware = require('../../lib/api/middlewares/authorize'); +const dbConnSetupMiddleware = require('../../lib/api/middlewares/db-conn-setup'); +const credentialsMiddleware = require('../../lib/api/middlewares/credentials'); var windshaft = require('windshaft'); @@ -42,7 +42,7 @@ describe('prepare-context', function() { }); - it('can be found in server_options', function(){ + it('can be found in server-options', function(){ assert.ok(_.isFunction(authorize)); assert.ok(_.isFunction(dbConnSetup)); assert.ok(_.isFunction(cleanUpQueryParams)); diff --git a/test/unit/cartodb/stats/reporter/named-map-provider.js b/test/unit/stats/reporter/named-map-provider-test.js similarity index 93% rename from test/unit/cartodb/stats/reporter/named-map-provider.js rename to test/unit/stats/reporter/named-map-provider-test.js index f99a9edf..48712be4 100644 --- a/test/unit/cartodb/stats/reporter/named-map-provider.js +++ b/test/unit/stats/reporter/named-map-provider-test.js @@ -1,7 +1,7 @@ 'use strict'; const assert = require('assert'); -const NamedMapProviderReporter = require('../../../../../lib/cartodb/stats/reporter/named-map-provider'); +const NamedMapProviderReporter = require('../../../../lib/stats/reporter/named-map-provider'); describe('named-map-provider-reporter', function () { it('should report metrics every 100 ms', function (done) { diff --git a/test/unit/cartodb/substitution-tokens.test.js b/test/unit/substitution-tokens-test.js similarity index 94% rename from test/unit/cartodb/substitution-tokens.test.js rename to test/unit/substitution-tokens-test.js index 61b78e39..7a9e5cda 100644 --- a/test/unit/cartodb/substitution-tokens.test.js +++ b/test/unit/substitution-tokens-test.js @@ -1,7 +1,7 @@ 'use strict'; var assert = require('assert'); -var SubstitutionTokens = require('../../../lib/cartodb/utils/substitution-tokens'); +var SubstitutionTokens = require('../../lib/utils/substitution-tokens'); describe('SubstitutionTokens', function() { diff --git a/test/unit/cartodb/table_name_parser.js b/test/unit/table-name-parser-test.js similarity index 95% rename from test/unit/cartodb/table_name_parser.js rename to test/unit/table-name-parser-test.js index 3c7aac48..e5cb73fa 100644 --- a/test/unit/cartodb/table_name_parser.js +++ b/test/unit/table-name-parser-test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); -var TableNameParser = require('../../../lib/cartodb/utils/table_name_parser'); +var TableNameParser = require('../../lib/utils/table-name-parser'); describe('TableNameParser', function() { diff --git a/test/unit/cartodb/template_maps_auth.test.js b/test/unit/template-maps-auth-test.js similarity index 96% rename from test/unit/cartodb/template_maps_auth.test.js rename to test/unit/template-maps-auth-test.js index 9497adde..4b7ff943 100644 --- a/test/unit/cartodb/template_maps_auth.test.js +++ b/test/unit/template-maps-auth-test.js @@ -1,11 +1,11 @@ 'use strict'; -require('../../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../../lib/cartodb/backends/template_maps'); +var TemplateMaps = require('../../lib/backends/template-maps'); describe('template_maps_auth', function() { diff --git a/test/unit/cartodb/template_maps_defaults.test.js b/test/unit/template-maps-defaults-test.js similarity index 96% rename from test/unit/cartodb/template_maps_defaults.test.js rename to test/unit/template-maps-defaults-test.js index dc612cd5..3c98e77d 100644 --- a/test/unit/cartodb/template_maps_defaults.test.js +++ b/test/unit/template-maps-defaults-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../../lib/cartodb/backends/template_maps.js'); +var TemplateMaps = require('../../lib/backends/template-maps'); var _ = require('underscore'); describe('template_maps', function() { diff --git a/test/unit/cartodb/template_maps.test.js b/test/unit/template-maps-test.js similarity index 99% rename from test/unit/cartodb/template_maps.test.js rename to test/unit/template-maps-test.js index d504dc2d..f4aa376b 100644 --- a/test/unit/cartodb/template_maps.test.js +++ b/test/unit/template-maps-test.js @@ -1,10 +1,10 @@ 'use strict'; -var testHelper = require('../../support/test_helper'); +var testHelper = require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../../lib/cartodb/backends/template_maps.js'); +var TemplateMaps = require('../../lib/backends/template-maps'); var step = require('step'); var _ = require('underscore'); diff --git a/test/unit/cartodb/utils/date-wrapper.test.js b/test/unit/utils/date-wrapper-test.js similarity index 86% rename from test/unit/cartodb/utils/date-wrapper.test.js rename to test/unit/utils/date-wrapper-test.js index 0ef7c126..a76d0792 100644 --- a/test/unit/cartodb/utils/date-wrapper.test.js +++ b/test/unit/utils/date-wrapper-test.js @@ -1,7 +1,7 @@ 'use strict'; var assert = require('assert'); -var dateWrapper = require('../../../../lib/cartodb/utils/date-wrapper'); +var dateWrapper = require('../../../lib/utils/date-wrapper'); describe('date-wrapper', function() { diff --git a/test/unit/cartodb/valid_template_maps.test.js b/test/unit/valid-template-maps-test.js similarity index 96% rename from test/unit/cartodb/valid_template_maps.test.js rename to test/unit/valid-template-maps-test.js index c9a90b2c..e38d9488 100644 --- a/test/unit/cartodb/valid_template_maps.test.js +++ b/test/unit/valid-template-maps-test.js @@ -1,10 +1,10 @@ 'use strict'; -require('../../support/test_helper'); +require('../support/test-helper'); var assert = require('assert'); var RedisPool = require('redis-mpool'); -var TemplateMaps = require('../../../lib/cartodb/backends/template_maps.js'); +var TemplateMaps = require('../../lib/backends/template-maps'); var _ = require('underscore'); describe('template_maps', function() {