From 65702de64d4f263c7e337ee2a2f26b4510571a52 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 23 Feb 2015 12:06:47 +0100 Subject: [PATCH 01/52] Update to latest test/support/sql/CDB_QueryTables.sql --- test/support/sql/CDB_QueryTables.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/support/sql/CDB_QueryTables.sql b/test/support/sql/CDB_QueryTables.sql index cd8b51b4..2fb9532a 100644 --- a/test/support/sql/CDB_QueryTables.sql +++ b/test/support/sql/CDB_QueryTables.sql @@ -16,9 +16,9 @@ BEGIN FOR rec IN SELECT CDB_QueryStatements(query) q LOOP - IF NOT ( rec.q ilike 'select%' or rec.q ilike 'with%' ) THEN - --RAISE WARNING 'Skipping %', rec.q; - CONTINUE; + IF NOT ( rec.q ilike 'select %' or rec.q ilike 'with %' ) THEN + --RAISE WARNING 'Skipping %', rec.q; + CONTINUE; END IF; BEGIN From 62e435fd9ec9fcb9f42aa9f9b63daa6cc4404f46 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 23 Feb 2015 12:08:08 +0100 Subject: [PATCH 02/52] Improve installation feedback as we did in Windshaft --- Makefile | 21 +++++---------------- package.json | 3 ++- scripts/check-node-canvas.sh | 24 ++++++++++++++++++++++++ scripts/install.sh | 7 +++++++ 4 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 scripts/check-node-canvas.sh create mode 100644 scripts/install.sh diff --git a/Makefile b/Makefile index 32a48859..c6b2cf62 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ -srcdir=$(shell pwd) - all: - npm install + @sh ./scripts/install.sh clean: rm -rf node_modules/* @@ -15,7 +13,8 @@ config.status--test: config/environments/test.js: config.status--test ./config.status--test -check-local: config/environments/test.js +test: config/environments/test.js + @echo "***tests***" ./run_tests.sh ${RUNTESTFLAGS} \ test/unit/cartodb/*.js \ test/unit/cartodb/cache/model/*.js \ @@ -23,16 +22,6 @@ check-local: config/environments/test.js test/acceptance/*.js \ test/acceptance/cache/*.js -check-submodules: - PATH="$$PATH:$(srcdir)/node_modules/.bin/"; \ - for sub in windshaft grainstore node-varnish mapnik; do \ - if test -e node_modules/$${sub}; then \ - echo "Testing submodule $${sub}"; \ - make -C node_modules/$${sub} check || exit 1; \ - fi; \ - done - -check-full: check-local check-submodules - -check: check-local +check: test +.PHONY: test diff --git a/package.json b/package.json index b6ebb47b..1b0219bf 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "semver": "~1.1.4" }, "scripts": { - "test": "make check" + "preinstall": "sh ./scripts/check-node-canvas.sh", + "test": "make test" }, "engines": { "node": ">=0.8 <0.11", diff --git a/scripts/check-node-canvas.sh b/scripts/check-node-canvas.sh new file mode 100644 index 00000000..b5fa8f30 --- /dev/null +++ b/scripts/check-node-canvas.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +if [[ "$OSTYPE" == "darwin"* ]]; then + CAIRO_PKG_CONFIG=`pkg-config cairo --cflags-only-I 2> /dev/null` + RESULT=$? + + if [[ ${RESULT} -ne 0 ]]; then + echo "###################################################################################" + echo "# PREINSTALL HOOK ERROR #" + echo "#---------------------------------------------------------------------------------#" + echo "# #" + echo "# node-canvas install error: some packages required by 'cairo' are not found #" + echo "# #" + echo "# Use '\033[1mmake all\033[0m', it will take care of common/known issues #" + echo "# #" + echo "# As an alternative try: #" + echo "# Try to 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig' #" + echo "# #" + echo "# If problems persist visit: https://github.com/Automattic/node-canvas/wiki #" + echo "# #" + echo "###################################################################################" + exit 1 + fi +fi diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 00000000..1817644c --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [[ "$OSTYPE" == "darwin"* ]]; then + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig +fi + +npm install From a287c8450031bc95201d270b8039821fd1e858be Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 23 Feb 2015 12:59:00 +0100 Subject: [PATCH 03/52] Upgrades windshaft to 0.38.0 --- NEWS.md | 3 ++- npm-shrinkwrap.json | 48 +++++++++------------------------------------ package.json | 4 ++-- 3 files changed, 13 insertions(+), 42 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1945ac26..23e65428 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ -1.28.6 -- 2015-mm-dd +1.29.0 -- 2015-mm-dd -------------------- +- Upgrades windshaft to [0.38.0](https://github.com/CartoDB/Windshaft/releases/tag/0.38.0) 1.28.5 -- 2015-02-20 diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e33b4102..67291f61 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "windshaft-cartodb", - "version": "1.28.6", + "version": "1.29.0", "dependencies": { "cartodb-psql": { "version": "0.4.0", @@ -181,8 +181,8 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" }, "windshaft": { - "version": "0.37.5", - "from": "windshaft@~0.37.5", + "version": "0.38.0", + "from": "windshaft@~0.38.0", "dependencies": { "chronograph": { "version": "0.1.0", @@ -2121,9 +2121,9 @@ } }, "carto": { - "version": "0.14.0", - "from": "https://github.com/CartoDB/carto/tarball/update_to_master", - "resolved": "https://github.com/CartoDB/carto/tarball/update_to_master", + "version": "0.15.1-cdb1", + "from": "https://github.com/CartoDB/carto/tarball/0.15.1-cdb1", + "resolved": "https://github.com/CartoDB/carto/tarball/0.15.1-cdb1", "dependencies": { "mapnik-reference": { "version": "6.0.5", @@ -2154,39 +2154,9 @@ "resolved": "git://github.com/CartoDB/node-step-profiler.git#9b97881e450445bd8a307a9cc372b5129cb4529a" }, "torque.js": { - "version": "2.7.1", - "from": "https://github.com/CartoDB/torque/tarball/2.8", - "resolved": "https://github.com/CartoDB/torque/tarball/2.8", - "dependencies": { - "carto": { - "version": "0.15.1", - "from": "https://github.com/CartoDB/carto/archive/master.tar.gz", - "resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz", - "dependencies": { - "mapnik-reference": { - "version": "6.0.5", - "from": "mapnik-reference@~6.0.2", - "resolved": "https://registry.npmjs.org/mapnik-reference/-/mapnik-reference-6.0.5.tgz" - }, - "optimist": { - "version": "0.6.1", - "from": "optimist@~0.6.0", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "from": "wordwrap@~0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" - }, - "minimist": { - "version": "0.0.10", - "from": "minimist@~0.0.1" - } - } - } - } - } - } + "version": "2.10.0", + "from": "https://github.com/CartoDB/torque/tarball/2.10.0", + "resolved": "https://github.com/CartoDB/torque/tarball/2.10.0" }, "request": { "version": "2.48.0", diff --git a/package.json b/package.json index 1b0219bf..487c00b5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "1.28.6", + "version": "1.29.0", "description": "A map tile server for CartoDB", "keywords": [ "cartodb" @@ -25,7 +25,7 @@ "node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0", "underscore" : "~1.6.0", "dot": "~1.0.2", - "windshaft": "~0.37.5", + "windshaft": "~0.38.0", "step": "~0.0.5", "queue-async": "~1.0.7", "request": "~2.9.203", From 6ae2c2630af9a348344a767baf64a9ec8cab26c3 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 25 Feb 2015 19:15:55 +0100 Subject: [PATCH 04/52] Upgrade windshaft to 0.38.1 --- NEWS.md | 2 +- npm-shrinkwrap.json | 75 +++++++++++++++++++++++---------------------- package.json | 2 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/NEWS.md b/NEWS.md index 23e65428..6c49708b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ 1.29.0 -- 2015-mm-dd -------------------- -- Upgrades windshaft to [0.38.0](https://github.com/CartoDB/Windshaft/releases/tag/0.38.0) +- Upgrades windshaft to [0.38.1](https://github.com/CartoDB/Windshaft/releases/tag/0.38.1) 1.28.5 -- 2015-02-20 diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 67291f61..6683907e 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -181,8 +181,8 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" }, "windshaft": { - "version": "0.38.0", - "from": "windshaft@~0.38.0", + "version": "0.38.1", + "from": "windshaft@~0.38.1", "dependencies": { "chronograph": { "version": "0.1.0", @@ -193,6 +193,36 @@ "version": "0.23.0", "from": "grainstore@~0.23.0", "dependencies": { + "redis-mpool": { + "version": "0.1.0", + "from": "https://github.com/CartoDB/node-redis-mpool/tarball/0.1.0", + "resolved": "https://github.com/CartoDB/node-redis-mpool/tarball/0.1.0", + "dependencies": { + "generic-pool": { + "version": "2.1.1", + "from": "generic-pool@~2.1.1" + }, + "redis": { + "version": "0.12.1", + "from": "redis@~0.12.1" + }, + "hiredis": { + "version": "0.1.17", + "from": "hiredis@~0.1.17", + "dependencies": { + "bindings": { + "version": "1.2.1", + "from": "bindings@*" + }, + "nan": { + "version": "1.1.2", + "from": "nan@~1.1.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-1.1.2.tgz" + } + } + } + } + }, "carto": { "version": "0.9.5-cdb2", "from": "https://github.com/CartoDB/carto/tarball/0.9.5-cdb2", @@ -2080,43 +2110,14 @@ } }, "canvas": { - "version": "1.1.6", - "from": "canvas@1.1.6", - "resolved": "https://registry.npmjs.org/canvas/-/canvas-1.1.6.tgz", + "version": "1.2.0", + "from": "canvas@1.2.0", + "resolved": "https://registry.npmjs.org/canvas/-/canvas-1.2.0.tgz", "dependencies": { "nan": { - "version": "1.2.0", - "from": "nan@~1.2.0" - } - } - }, - "redis-mpool": { - "version": "0.1.0", - "from": "redis-mpool@git://github.com/CartoDB/node-redis-mpool.git#0.1.0", - "resolved": "git://github.com/CartoDB/node-redis-mpool.git#47510b8d4525ee24aa2e5328976372274a1d144e", - "dependencies": { - "generic-pool": { - "version": "2.1.1", - "from": "generic-pool@~2.1.1" - }, - "redis": { - "version": "0.12.1", - "from": "redis@~0.12.1" - }, - "hiredis": { - "version": "0.1.17", - "from": "hiredis@~0.1.17", - "dependencies": { - "bindings": { - "version": "1.2.1", - "from": "bindings@*" - }, - "nan": { - "version": "1.1.2", - "from": "nan@~1.1.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-1.1.2.tgz" - } - } + "version": "1.5.3", + "from": "nan@~1.5.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-1.5.3.tgz" } } }, diff --git a/package.json b/package.json index 487c00b5..65b84126 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0", "underscore" : "~1.6.0", "dot": "~1.0.2", - "windshaft": "~0.38.0", + "windshaft": "~0.38.1", "step": "~0.0.5", "queue-async": "~1.0.7", "request": "~2.9.203", From 620160c44e03f5fefbfa2966ac3777badde4f1e7 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 26 Feb 2015 12:05:17 +0100 Subject: [PATCH 05/52] Ignore npm-debug.log --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 040b421a..e6d5b01a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ logs/ pids/ redis.pid test.log +npm-debug.log From f006d09f31e0bb913fdb6ae8c81675dac9008824 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 26 Feb 2015 12:08:48 +0100 Subject: [PATCH 06/52] Update windshaft to version 0.38.2 --- NEWS.md | 2 +- npm-shrinkwrap.json | 12 ++++++------ package.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6c49708b..45797c48 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ 1.29.0 -- 2015-mm-dd -------------------- -- Upgrades windshaft to [0.38.1](https://github.com/CartoDB/Windshaft/releases/tag/0.38.1) +- Upgrades windshaft to [0.38.2](https://github.com/CartoDB/Windshaft/releases/tag/0.38.2) 1.28.5 -- 2015-02-20 diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 6683907e..64fbd6ad 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -95,7 +95,7 @@ }, "inherits": { "version": "2.0.1", - "from": "inherits@~2.0.1" + "from": "inherits@2" } } } @@ -181,8 +181,8 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" }, "windshaft": { - "version": "0.38.1", - "from": "windshaft@~0.38.1", + "version": "0.38.2", + "from": "windshaft@~0.38.2", "dependencies": { "chronograph": { "version": "0.1.0", @@ -2110,9 +2110,9 @@ } }, "canvas": { - "version": "1.2.0", - "from": "canvas@1.2.0", - "resolved": "https://registry.npmjs.org/canvas/-/canvas-1.2.0.tgz", + "version": "1.2.1", + "from": "canvas@1.2.1", + "resolved": "https://github.com/Automattic/node-canvas/tarball/master", "dependencies": { "nan": { "version": "1.5.3", diff --git a/package.json b/package.json index 65b84126..1e31f865 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0", "underscore" : "~1.6.0", "dot": "~1.0.2", - "windshaft": "~0.38.1", + "windshaft": "~0.38.2", "step": "~0.0.5", "queue-async": "~1.0.7", "request": "~2.9.203", From cbd44192c9520d5349c41cfaa71793c7455e70f6 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 26 Feb 2015 17:00:50 +0100 Subject: [PATCH 07/52] Use bash in Makefile targets --- Makefile | 21 +++++++++++++-------- package.json | 2 +- scripts/check-node-canvas.sh | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c6b2cf62..12c9bee6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ +SHELL=/bin/bash + +pre-install: + @$(SHELL) ./scripts/check-node-canvas.sh + all: - @sh ./scripts/install.sh + @$(SHELL) ./scripts/install.sh clean: rm -rf node_modules/* @@ -15,13 +20,13 @@ config/environments/test.js: config.status--test test: config/environments/test.js @echo "***tests***" - ./run_tests.sh ${RUNTESTFLAGS} \ - test/unit/cartodb/*.js \ - test/unit/cartodb/cache/model/*.js \ - test/integration/*.js \ - test/acceptance/*.js \ - test/acceptance/cache/*.js + @$(SHELL) ./run_tests.sh ${RUNTESTFLAGS} \ + test/unit/cartodb/*.js \ + test/unit/cartodb/cache/model/*.js \ + test/integration/*.js \ + test/acceptance/*.js \ + test/acceptance/cache/*.js check: test -.PHONY: test +.PHONY: pre-install test diff --git a/package.json b/package.json index 1e31f865..68b69f6b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "semver": "~1.1.4" }, "scripts": { - "preinstall": "sh ./scripts/check-node-canvas.sh", + "preinstall": "make pre-install", "test": "make test" }, "engines": { diff --git a/scripts/check-node-canvas.sh b/scripts/check-node-canvas.sh index b5fa8f30..c2d56b83 100644 --- a/scripts/check-node-canvas.sh +++ b/scripts/check-node-canvas.sh @@ -11,7 +11,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then echo "# #" echo "# node-canvas install error: some packages required by 'cairo' are not found #" echo "# #" - echo "# Use '\033[1mmake all\033[0m', it will take care of common/known issues #" + echo -e "# Use '\033[1mmake all\033[0m', it will take care of common/known issues #" echo "# #" echo "# As an alternative try: #" echo "# Try to 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig' #" From e82131f4e8c5c0055cf974049ba8cdadda9dde06 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Fri, 6 Mar 2015 10:45:01 +0100 Subject: [PATCH 08/52] Upgrades windshaft@0.39.0 --- NEWS.md | 4 +++- npm-shrinkwrap.json | 40 +++++++++++++++++++++------------------- package.json | 2 +- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/NEWS.md b/NEWS.md index 45797c48..7e927208 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ 1.29.0 -- 2015-mm-dd -------------------- -- Upgrades windshaft to [0.38.2](https://github.com/CartoDB/Windshaft/releases/tag/0.38.2) + +Announcements: + - Upgrades windshaft to [0.39.0](https://github.com/CartoDB/Windshaft/releases/tag/0.39.0) 1.28.5 -- 2015-02-20 diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 64fbd6ad..a487deb5 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -5,7 +5,7 @@ "cartodb-psql": { "version": "0.4.0", "from": "cartodb-psql@~0.4.0", - "resolved": "https://github.com/CartoDB/node-cartodb-psql/tarball/0.4.0", + "resolved": "https://registry.npmjs.org/cartodb-psql/-/cartodb-psql-0.4.0.tgz", "dependencies": { "pg": { "version": "2.6.2-cdb1", @@ -87,7 +87,8 @@ }, "isarray": { "version": "0.0.1", - "from": "isarray@0.0.1" + "from": "isarray@0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" }, "string_decoder": { "version": "0.10.31", @@ -119,7 +120,7 @@ "redis-mpool": { "version": "0.3.0", "from": "redis-mpool@~0.3.0", - "resolved": "https://github.com/CartoDB/node-redis-mpool/tarball/0.3.0", + "resolved": "https://registry.npmjs.org/redis-mpool/-/redis-mpool-0.3.0.tgz", "dependencies": { "generic-pool": { "version": "2.1.1", @@ -157,9 +158,9 @@ "resolved": "https://registry.npmjs.org/rollbar/-/rollbar-0.3.13.tgz", "dependencies": { "node-uuid": { - "version": "1.4.2", + "version": "1.4.3", "from": "node-uuid@1.4.x", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.2.tgz" + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz" }, "lru-cache": { "version": "2.2.4", @@ -181,8 +182,9 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" }, "windshaft": { - "version": "0.38.2", - "from": "windshaft@~0.38.2", + "version": "0.39.0", + "from": "https://github.com/CartoDB/Windshaft/tarball/292-torque-buffer-size", + "resolved": "https://github.com/CartoDB/Windshaft/tarball/292-torque-buffer-size", "dependencies": { "chronograph": { "version": "0.1.0", @@ -294,9 +296,9 @@ "from": "forever-agent@~0.5.0" }, "node-uuid": { - "version": "1.4.2", + "version": "1.4.3", "from": "node-uuid@~1.4.0", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.2.tgz" + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz" }, "tough-cookie": { "version": "0.12.1", @@ -1710,9 +1712,9 @@ } }, "tilelive-mapnik": { - "version": "0.6.12", - "from": "https://github.com/CartoDB/tilelive-mapnik/tarball/cdb", - "resolved": "https://github.com/CartoDB/tilelive-mapnik/tarball/cdb", + "version": "0.6.15", + "from": "tilelive-mapnik@0.6.15", + "resolved": "https://registry.npmjs.org/tilelive-mapnik/-/tilelive-mapnik-0.6.15.tgz", "dependencies": { "generic-pool": { "version": "2.1.1", @@ -2112,7 +2114,7 @@ "canvas": { "version": "1.2.1", "from": "canvas@1.2.1", - "resolved": "https://github.com/Automattic/node-canvas/tarball/master", + "resolved": "https://registry.npmjs.org/canvas/-/canvas-1.2.1.tgz", "dependencies": { "nan": { "version": "1.5.3", @@ -2155,9 +2157,8 @@ "resolved": "git://github.com/CartoDB/node-step-profiler.git#9b97881e450445bd8a307a9cc372b5129cb4529a" }, "torque.js": { - "version": "2.10.0", - "from": "https://github.com/CartoDB/torque/tarball/2.10.0", - "resolved": "https://github.com/CartoDB/torque/tarball/2.10.0" + "version": "2.11.0", + "from": "torque.js@~2.11.0" }, "request": { "version": "2.48.0", @@ -2180,7 +2181,8 @@ }, "isarray": { "version": "0.0.1", - "from": "isarray@0.0.1" + "from": "isarray@0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" }, "string_decoder": { "version": "0.10.31", @@ -2229,9 +2231,9 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-1.0.2.tgz" }, "node-uuid": { - "version": "1.4.2", + "version": "1.4.3", "from": "node-uuid@~1.4.0", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.2.tgz" + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz" }, "qs": { "version": "2.3.3", diff --git a/package.json b/package.json index 68b69f6b..5568509c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0", "underscore" : "~1.6.0", "dot": "~1.0.2", - "windshaft": "~0.38.2", + "windshaft": "https://github.com/CartoDB/Windshaft/tarball/292-torque-buffer-size", "step": "~0.0.5", "queue-async": "~1.0.7", "request": "~2.9.203", From e95167a049f07dee4f5784caed12293e7586d746 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 8 Mar 2015 11:36:17 +0100 Subject: [PATCH 09/52] Force bash --- scripts/check-node-canvas.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-node-canvas.sh b/scripts/check-node-canvas.sh index c2d56b83..a698e412 100644 --- a/scripts/check-node-canvas.sh +++ b/scripts/check-node-canvas.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [[ "$OSTYPE" == "darwin"* ]]; then CAIRO_PKG_CONFIG=`pkg-config cairo --cflags-only-I 2> /dev/null` From 53d72761360f255db84fdb3b77f41192b9403bf6 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 8 Mar 2015 11:36:31 +0100 Subject: [PATCH 10/52] Force bash --- scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 1817644c..f596aa12 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [[ "$OSTYPE" == "darwin"* ]]; then export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig From cfe434c8ed036db99b4c8762edeea17c5348e37e Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 9 Mar 2015 13:52:47 +0100 Subject: [PATCH 11/52] Use published version --- npm-shrinkwrap.json | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index a487deb5..a6e75bf0 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -96,7 +96,7 @@ }, "inherits": { "version": "2.0.1", - "from": "inherits@2" + "from": "inherits@~2.0.1" } } } @@ -183,8 +183,7 @@ }, "windshaft": { "version": "0.39.0", - "from": "https://github.com/CartoDB/Windshaft/tarball/292-torque-buffer-size", - "resolved": "https://github.com/CartoDB/Windshaft/tarball/292-torque-buffer-size", + "from": "windshaft@~0.39.0", "dependencies": { "chronograph": { "version": "0.1.0", diff --git a/package.json b/package.json index 5568509c..276693a3 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0", "underscore" : "~1.6.0", "dot": "~1.0.2", - "windshaft": "https://github.com/CartoDB/Windshaft/tarball/292-torque-buffer-size", + "windshaft": "~0.39.0", "step": "~0.0.5", "queue-async": "~1.0.7", "request": "~2.9.203", From 661df294e129a4b84d8e0badfa695ba9cdfa1e2f Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 9 Mar 2015 14:07:47 +0100 Subject: [PATCH 12/52] Release 1.29.0 --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 7e927208..af4f525d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -1.29.0 -- 2015-mm-dd +1.29.0 -- 2015-03-09 -------------------- Announcements: From 1979697551cf51538ab0d962de21fee3a9e4a6f8 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 9 Mar 2015 14:08:38 +0100 Subject: [PATCH 13/52] Stubs next version --- NEWS.md | 4 ++++ npm-shrinkwrap.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index af4f525d..a47cfb8a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +1.29.1 -- 2015-mm-dd +-------------------- + + 1.29.0 -- 2015-03-09 -------------------- diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index a6e75bf0..d0716c66 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "windshaft-cartodb", - "version": "1.29.0", + "version": "1.29.1", "dependencies": { "cartodb-psql": { "version": "0.4.0", diff --git a/package.json b/package.json index 276693a3..5445ad42 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "1.29.0", + "version": "1.29.1", "description": "A map tile server for CartoDB", "keywords": [ "cartodb" From 6d4eb23696993abca88d0579d93a44b299308ea2 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 9 Mar 2015 14:37:26 +0100 Subject: [PATCH 14/52] Improve readme - Requirements bumped - Delete URLs documentation and point to docs directory. --- README.md | 97 ++++++++++++++++--------------------------------------- 1 file changed, 27 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 3cb2b036..59348756 100644 --- a/README.md +++ b/README.md @@ -3,36 +3,36 @@ Windshaft-CartoDB [![Build Status](https://travis-ci.org/CartoDB/Windshaft-cartodb.svg?branch=master)](https://travis-ci.org/CartoDB/Windshaft-cartodb) -This is the CartoDB map tiler. It extends Windshaft with some extra -functionality and custom filters for authentication +This is the [CartoDB Maps API](http://docs.cartodb.com/cartodb-platform/maps-api.html) tiler. It extends +[Windshaft](https://github.com/CartoDB/Windshaft) with some extra functionality and custom filters for authentication. * reads dbname from subdomain and cartodb redis for pretty tile urls -* configures windshaft to publish ``cartodb_id`` as the interactivity layer +* configures windshaft to publish `cartodb_id` as the interactivity layer * gets the default geometry type from the cartodb redis store * allows tiles to be styled individually * provides a link to varnish high speed cache * provides a ``infowindow`` endpoint for windshaft (DEPRECATED) * provides a ``map_metadata`` endpoint for windshaft (DEPRECATED) -* provides signed template maps API - (http://github.com/CartoDB/Windshaft-cartodb/wiki/Template-maps) +* provides a [template maps API](https://github.com/CartoDB/Windshaft-cartodb/blob/master/docs/Template-maps.md) Requirements ------------ + - Core + - Node.js >=0.8 + - npm >=1.2.1 + - PostgreSQL >8.3.x, PostGIS >1.5.x + - Redis >2.4.0 (http://www.redis.io) + - Mapnik 2.0.1, 2.0.2, 2.1.0, 2.2.0, 2.3.0. See Installing Mapnik. + - Windshaft: check [Windshaft dependencies and installation notes](https://github.com/CartoDB/Windshaft#dependencies) + - libcairo2, libpango1.0, libjpeg8 and libgif for server side canvas support - [core] - - node-0.8.x+ - - PostgreSQL-8.3+ - - PostGIS-1.5.0+ - - Redis 2.4.0+ (http://www.redis.io) - - Mapnik 2.0 or 2.1 +- For cache control (optional) + - CartoDB-SQL-API 1.0.0+ + - CartoDB 0.9.5+ (for `CDB_QueryTables`) + - Varnish (http://www.varnish-cache.org) - [for cache control] - - CartoDB-SQL-API 1.0.0+ - - CartoDB 0.9.5+ (for ``CDB_QueryTables``) - - Varnish (http://www.varnish-cache.org) - - [for running the testsuite] - - Imagemagick (http://www.imagemagick.org) +- For running the testsuite + - ImageMagick (http://www.imagemagick.org) Configure --------- @@ -74,59 +74,16 @@ there may be out-of-sync records in there. Take a look: http://redis.io/commands -URLs ----- +Documentation +------------- -**TILES** - -[GET] subdomain.cartodb.com/tiles/:table_name/:z/:x/:y.[png|png8|grid.json] - -Args: - -* sql - plain SQL arguments -* interactivity - specify the column to use in UTFGrid -* cache_buster - Specify an identifier for the internal tile cache. - Requesting tiles with the same cache_buster value may - result in being served a cached version of the tile - (even when requesting a tile for the first time, as tiles - can be prepared in advance) -* cache_policy - Set to "persist" to have the server send an Cache-Control - header requesting caching devices to keep the response - cached as much as possible. This is best used with a - timestamp value in cache_buster for manual control of - updates. -* geom_type - override the cartodb default -* style - override the default map style with Carto +The [docs directory](https://github.com/CartoDB/Windshaft-cartodb/tree/master/docs) contains different documentation +resources, from higher level to more detailed ones: +The [Maps API](https://github.com/CartoDB/Windshaft-cartodb/blob/master/docs/Map-API.md) defined the endpoints and their +expected parameters and outputs. -**STYLE** +Examples +-------- -[GET/POST] subdomain.cartodb.com/tiles/:table_name/style - -Args: - -* style - the style in CartoCSS you want to set -* style_version - the version of the style for POST -* style_convert - request conversion to target version (both POST and GET) - - -**INFOWINDOW** - -[GET] subdomain.cartodb.com/tiles/:table_name/infowindow - -Args: - -* infowindow - returns contents of infowindow from CartoDB. - - -**MAP METADATA** - -[GET] subdomain.cartodb.com/tiles/:table_name/map_metadata - -Args: - -* infowindow - returns contents of infowindow from CartoDB. - - -All GET requests are wrappable with JSONP using callback argument, -including the UTFGrid map tile call. +[CartoDB's Map Gallery](http://cartodb.com/gallery/) showcases several examples of visualisations built on top of this. From edde869a68ac11ceb45676824220aec0e163763c Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 9 Mar 2015 14:42:30 +0100 Subject: [PATCH 15/52] Update CDB_QueryTables --- test/support/sql/CDB_QueryTables.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/support/sql/CDB_QueryTables.sql b/test/support/sql/CDB_QueryTables.sql index 2fb9532a..cd8b51b4 100644 --- a/test/support/sql/CDB_QueryTables.sql +++ b/test/support/sql/CDB_QueryTables.sql @@ -16,9 +16,9 @@ BEGIN FOR rec IN SELECT CDB_QueryStatements(query) q LOOP - IF NOT ( rec.q ilike 'select %' or rec.q ilike 'with %' ) THEN - --RAISE WARNING 'Skipping %', rec.q; - CONTINUE; + IF NOT ( rec.q ilike 'select%' or rec.q ilike 'with%' ) THEN + --RAISE WARNING 'Skipping %', rec.q; + CONTINUE; END IF; BEGIN From 0d5242d12bcb0eb2ab5811339105bdd3e22c7cb8 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 9 Mar 2015 14:42:47 +0100 Subject: [PATCH 16/52] Add enabledFeatures configuration to the example configuration files - Enables querytables from postgres as default --- config/environments/development.js.example | 6 ++++++ config/environments/production.js.example | 6 ++++++ config/environments/staging.js.example | 6 ++++++ config/environments/test.js.example | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 2c391dd1..1c036f67 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -174,6 +174,12 @@ var config = { x: 0, y: 0 } + + // Use this as a feature flags enabling/disabling mechanism + ,enabledFeatures: { + // whether the affected tables for a given SQL must query directly postgresql or use the SQL API + cdbQueryTablesFromPostgres: true + } }; module.exports = config; diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 0d4e999a..28f2ee95 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -183,6 +183,12 @@ var config = { x: 0, y: 0 } + + // Use this as a feature flags enabling/disabling mechanism + ,enabledFeatures: { + // whether the affected tables for a given SQL must query directly postgresql or use the SQL API + cdbQueryTablesFromPostgres: true + } }; module.exports = config; diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 0c88a9c7..88a0d8e7 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -183,6 +183,12 @@ var config = { x: 0, y: 0 } + + // Use this as a feature flags enabling/disabling mechanism + ,enabledFeatures: { + // whether the affected tables for a given SQL must query directly postgresql or use the SQL API + cdbQueryTablesFromPostgres: true + } }; module.exports = config; diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 67551249..066bf1d0 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -172,6 +172,12 @@ var config = { x: 0, y: 0 } + + // Use this as a feature flags enabling/disabling mechanism + ,enabledFeatures: { + // whether the affected tables for a given SQL must query directly postgresql or use the SQL API + cdbQueryTablesFromPostgres: true + } }; module.exports = config; From 38e35a6d6115e4bdb5ba9ff51a3232b7e7b948d3 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 11 Mar 2015 14:25:36 +0100 Subject: [PATCH 17/52] Specific dependencies for building node-canvas --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59348756..aa2c7028 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Requirements - Redis >2.4.0 (http://www.redis.io) - Mapnik 2.0.1, 2.0.2, 2.1.0, 2.2.0, 2.3.0. See Installing Mapnik. - Windshaft: check [Windshaft dependencies and installation notes](https://github.com/CartoDB/Windshaft#dependencies) - - libcairo2, libpango1.0, libjpeg8 and libgif for server side canvas support + - libcairo2-dev, libpango1.0-dev, libjpeg8-dev and libgif-dev for server side canvas support - For cache control (optional) - CartoDB-SQL-API 1.0.0+ From 62661c633c2eb05f18ebf219022adc1d101988d3 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 11 Mar 2015 15:16:24 +0100 Subject: [PATCH 18/52] Adds script/tool to go from lzma base64 encoded string to mapconfig --- scripts/lzma2config.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 scripts/lzma2config.js diff --git a/scripts/lzma2config.js b/scripts/lzma2config.js new file mode 100644 index 00000000..0d8347b8 --- /dev/null +++ b/scripts/lzma2config.js @@ -0,0 +1,18 @@ +if (process.argv.length !== 3) { + console.error('Usage: node %s lzma_string', __filename); + process.exit(1); +} + +var LZMA = require('lzma').LZMA; +var lzmaWorker = new LZMA(); +var lzmaInput = decodeURIComponent(process.argv[2]); +var lzmaBuffer = new Buffer(lzmaInput, 'base64') + .toString('binary') + .split('') + .map(function(c) { + return c.charCodeAt(0) - 128 + }); + +lzmaWorker.decompress(lzmaBuffer, function(result) { + console.log(JSON.stringify(JSON.parse(JSON.parse(result).config), null, 4)); +}); From 8e9d9113d769c092949f4a51d9a2c6376d4bfb65 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 11 Mar 2015 16:19:07 +0100 Subject: [PATCH 19/52] Upgrades windshaft to 0.40.0 --- NEWS.md | 5 ++++- npm-shrinkwrap.json | 17 ++++++++--------- package.json | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index a47cfb8a..3e162ed0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ -1.29.1 -- 2015-mm-dd +1.30.0 -- 2015-mm-dd -------------------- +Announcements: + - Upgrades windshaft to [0.40.0](https://github.com/CartoDB/Windshaft/releases/tag/0.40.0) + 1.29.0 -- 2015-03-09 -------------------- diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d0716c66..9eaeead7 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "windshaft-cartodb", - "version": "1.29.1", + "version": "1.30.0", "dependencies": { "cartodb-psql": { "version": "0.4.0", @@ -96,7 +96,7 @@ }, "inherits": { "version": "2.0.1", - "from": "inherits@~2.0.1" + "from": "inherits@2" } } } @@ -182,8 +182,8 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" }, "windshaft": { - "version": "0.39.0", - "from": "windshaft@~0.39.0", + "version": "0.40.0", + "from": "windshaft@~0.40.0", "dependencies": { "chronograph": { "version": "0.1.0", @@ -1712,8 +1712,8 @@ }, "tilelive-mapnik": { "version": "0.6.15", - "from": "tilelive-mapnik@0.6.15", - "resolved": "https://registry.npmjs.org/tilelive-mapnik/-/tilelive-mapnik-0.6.15.tgz", + "from": "https://github.com/CartoDB/tilelive-mapnik/tarball/cdb", + "resolved": "https://github.com/CartoDB/tilelive-mapnik/tarball/cdb", "dependencies": { "generic-pool": { "version": "2.1.1", @@ -2151,9 +2151,8 @@ } }, "step-profiler": { - "version": "0.1.0", - "from": "step-profiler@git://github.com/CartoDB/node-step-profiler.git#0.1.0", - "resolved": "git://github.com/CartoDB/node-step-profiler.git#9b97881e450445bd8a307a9cc372b5129cb4529a" + "version": "0.2.1", + "from": "step-profiler@~0.2.1" }, "torque.js": { "version": "2.11.0", diff --git a/package.json b/package.json index 5445ad42..a718cfb4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "1.29.1", + "version": "1.30.0", "description": "A map tile server for CartoDB", "keywords": [ "cartodb" @@ -25,7 +25,7 @@ "node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0", "underscore" : "~1.6.0", "dot": "~1.0.2", - "windshaft": "~0.39.0", + "windshaft": "~0.40.0", "step": "~0.0.5", "queue-async": "~1.0.7", "request": "~2.9.203", From 9d9aafbcb3633f56acf81d70d399a1a82a84568f Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 11 Mar 2015 17:14:41 +0100 Subject: [PATCH 20/52] Release 1.30.0 --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 3e162ed0..8ac4752f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -1.30.0 -- 2015-mm-dd +1.30.0 -- 2015-03-11 -------------------- Announcements: From 75a980ff1d31ff38f6f7199db5552d8fd212e0f5 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 11 Mar 2015 17:15:44 +0100 Subject: [PATCH 21/52] Stubs next version --- NEWS.md | 4 ++++ npm-shrinkwrap.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8ac4752f..eb5dd295 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +1.30.1 -- 2015-mm-dd +-------------------- + + 1.30.0 -- 2015-03-11 -------------------- diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 9eaeead7..4f437dd6 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "windshaft-cartodb", - "version": "1.30.0", + "version": "1.30.1", "dependencies": { "cartodb-psql": { "version": "0.4.0", diff --git a/package.json b/package.json index a718cfb4..27f4c317 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "1.30.0", + "version": "1.30.1", "description": "A map tile server for CartoDB", "keywords": [ "cartodb" From f1eed600d5ad0dcb8e3a163352a5d7fe948e83ed Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 12 Mar 2015 12:20:42 +0100 Subject: [PATCH 22/52] Adds routes document (WIP) --- docs/Routes.md | 123 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 docs/Routes.md diff --git a/docs/Routes.md b/docs/Routes.md new file mode 100644 index 00000000..314f175d --- /dev/null +++ b/docs/Routes.md @@ -0,0 +1,123 @@ +This document list all routes available in Windshaft-cartodb Maps API server. + +## Routes list + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y@:scale_factor?x.:format {:token(f),:z(f),:x(f),:y(f),:scale_factor(t),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y.:format {:token(f),:z(f),:x(f),:y(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/:z/:x/:y.(:format) {:token(f),:layer(f),:z(f),:x(f),:y(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup) {} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/attributes/:fid {:token(f),:layer(f),:fid(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/static/center/:token/:z/:lat/:lng/:width/:height.:format {:token(f),:z(f),:lat(f),:lng(f),:width(f),:height(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map|/tiles/layergroup)/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format {:token(f),:west(f),:south(f),:east(f),:north(f),:width(f),:height(f),:format(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET / {} (1)` +
Notes: [DEPRECATED]? + +1. `GET /version {} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/:z/:x/:y.* {:table(f),:z(f),:x(f),:y(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id/jsonp {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET (?:/api/v1/map/named|/tiles/template) {} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/infowindow {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET /tiles/:table/map_metadata {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `GET /health {} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS (?:/api/v1/map|/tiles/layergroup) {} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS /tiles/:table/:z/:x/:y.* {:table(f),:z(f),:x(f),:y(f)} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `OPTIONS (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `POST (?:/api/v1/map|/tiles/layergroup) {} (1)` +
Notes: [DEPRECATED]? + +1. `POST /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `POST (?:/api/v1/map/named|/tiles/template) {} (1)` +
Notes: [DEPRECATED]? + +1. `POST (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `DELETE /tiles/:table/style {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `DELETE (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +1. `DELETE /tiles/:table/flush_cache {:table(f)} (1)` +
Notes: [DEPRECATED]? + +1. `PUT (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` +
Notes: [DEPRECATED]? + +## How to generate the list of routes + +Something like the following patch should do the trick + +```javascript +diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js +index 477a4c2..f69eebb 100644 +--- a/lib/cartodb/cartodb_windshaft.js ++++ b/lib/cartodb/cartodb_windshaft.js +@@ -242,6 +242,20 @@ var CartodbWindshaft = function(serverOptions) { + } + }); + ++ var format = require('util').format; ++ var routesNotes = Object.keys(ws.routes.routes) ++ .map(function(method) { return ws.routes.routes[method]; }) ++ .reduce(function(previous, current) { current.map(function(r) { previous.push(r) }); return previous;}, []) ++ .map(function(route) { ++ return format("\n1. `%s %s {%s} (%d)`\n
Notes: [DEPRECATED]? ", ++ route.method.toUpperCase(), ++ route.path, ++ route.keys.map(function(k) { return format(':%s(%s)', k.name, k.optional ? 't' : 'f'); } ).join(','), ++ route.callbacks.length ++ ); ++ }); ++ console.log(routesNotes.join('\n')); ++ + return ws; + }; + + +``` \ No newline at end of file From 83e5d889a72dd2b20599f9d616ed17f0224705fb Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 12 Mar 2015 12:38:06 +0100 Subject: [PATCH 23/52] Some notes about routes --- docs/Routes.md | 56 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/Routes.md b/docs/Routes.md index 314f175d..89efc246 100644 --- a/docs/Routes.md +++ b/docs/Routes.md @@ -3,91 +3,91 @@ This document list all routes available in Windshaft-cartodb Maps API server. ## Routes list 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y@:scale_factor?x.:format {:token(f),:z(f),:x(f),:y(f),:scale_factor(t),:format(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Mapnik retina tiles 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y.:format {:token(f),:z(f),:x(f),:y(f),:format(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Mapnik tiles 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/:z/:x/:y.(:format) {:token(f),:layer(f),:z(f),:x(f),:y(f),:format(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Per :layer rendering based on :format 1. `GET (?:/api/v1/map|/tiles/layergroup) {} (1)` -
Notes: [DEPRECATED]? +
Notes: Map instantiation 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/attributes/:fid {:token(f),:layer(f),:fid(f)} (1)`
Notes: [DEPRECATED]? 1. `GET (?:/api/v1/map|/tiles/layergroup)/static/center/:token/:z/:lat/:lng/:width/:height.:format {:token(f),:z(f),:lat(f),:lng(f),:width(f),:height(f),:format(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Static Maps API 1. `GET (?:/api/v1/map|/tiles/layergroup)/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format {:token(f),:west(f),:south(f),:east(f),:north(f),:width(f),:height(f),:format(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Static Maps API 1. `GET / {} (1)` -
Notes: [DEPRECATED]? +
Notes: Welcome message 1. `GET /version {} (1)` -
Notes: [DEPRECATED]? +
Notes: Return relevant module versions: mapnik, grainstore, etc 1. `GET /tiles/:table/:z/:x/:y.* {:table(f),:z(f),:x(f),:y(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** Per :table tiles rendering 1. `GET /tiles/:table/style {:table(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** Style for :table 1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id/jsonp {:template_id(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Named maps JSONP instantiation 1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Named map retrieval (w/ API KEY) 1. `GET (?:/api/v1/map/named|/tiles/template) {} (1)` -
Notes: [DEPRECATED]? +
Notes: List named maps (w/ API KEY) 1. `GET /tiles/:table/infowindow {:table(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** retrieve info window template for :table 1. `GET /tiles/:table/map_metadata {:table(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** retrieve map metadata for :table 1. `GET /health {} (1)` -
Notes: [DEPRECATED]? +
Notes: Healt check 1. `OPTIONS (?:/api/v1/map|/tiles/layergroup) {} (1)` -
Notes: [DEPRECATED]? +
Notes: CORS 1. `OPTIONS /tiles/:table/:z/:x/:y.* {:table(f),:z(f),:x(f),:y(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** CORS 1. `OPTIONS /tiles/:table/style {:table(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** CORS 1. `OPTIONS (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: CORS 1. `POST (?:/api/v1/map|/tiles/layergroup) {} (1)` -
Notes: [DEPRECATED]? +
Notes: Map instantiation 1. `POST /tiles/:table/style {:table(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** Create style for :table 1. `POST (?:/api/v1/map/named|/tiles/template) {} (1)` -
Notes: [DEPRECATED]? +
Notes: Create named map 1. `POST (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Instantiate named map 1. `DELETE /tiles/:table/style {:table(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** Delete :table style 1. `DELETE (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Delete named map 1. `DELETE /tiles/:table/flush_cache {:table(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: **[DEPRECATED]** Flush internal caches for :table 1. `PUT (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Update a named map ## How to generate the list of routes From 7a01d75cd802f2d84a22cd2e301e00184aa97853 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 12 Mar 2015 12:42:13 +0100 Subject: [PATCH 24/52] Attributes route --- docs/Routes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Routes.md b/docs/Routes.md index 89efc246..abb13ec6 100644 --- a/docs/Routes.md +++ b/docs/Routes.md @@ -15,7 +15,7 @@ This document list all routes available in Windshaft-cartodb Maps API server.
Notes: Map instantiation 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/attributes/:fid {:token(f),:layer(f),:fid(f)} (1)` -
Notes: [DEPRECATED]? +
Notes: Endpoint for info windows data, alternative for sql api when tables are private 1. `GET (?:/api/v1/map|/tiles/layergroup)/static/center/:token/:z/:lat/:lng/:width/:height.:format {:token(f),:z(f),:lat(f),:lng(f),:width(f),:height(f),:format(f)} (1)`
Notes: Static Maps API From d09998cce1c2bbd1254ed783f9acd90986257638 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 12 Mar 2015 12:57:29 +0100 Subject: [PATCH 25/52] Extra notes about optional but deprecated endpoints - /tiles/layergroup - /tiles/template --- docs/Routes.md | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/docs/Routes.md b/docs/Routes.md index abb13ec6..8bfa86a0 100644 --- a/docs/Routes.md +++ b/docs/Routes.md @@ -3,25 +3,25 @@ This document list all routes available in Windshaft-cartodb Maps API server. ## Routes list 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y@:scale_factor?x.:format {:token(f),:z(f),:x(f),:y(f),:scale_factor(t),:format(f)} (1)` -
Notes: Mapnik retina tiles +
Notes: Mapnik retina tiles [0] 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:z/:x/:y.:format {:token(f),:z(f),:x(f),:y(f),:format(f)} (1)` -
Notes: Mapnik tiles +
Notes: Mapnik tiles [0] 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/:z/:x/:y.(:format) {:token(f),:layer(f),:z(f),:x(f),:y(f),:format(f)} (1)` -
Notes: Per :layer rendering based on :format +
Notes: Per :layer rendering based on :format [0] 1. `GET (?:/api/v1/map|/tiles/layergroup) {} (1)` -
Notes: Map instantiation +
Notes: Map instantiation [0] 1. `GET (?:/api/v1/map|/tiles/layergroup)/:token/:layer/attributes/:fid {:token(f),:layer(f),:fid(f)} (1)` -
Notes: Endpoint for info windows data, alternative for sql api when tables are private +
Notes: Endpoint for info windows data, alternative for sql api when tables are private [0] 1. `GET (?:/api/v1/map|/tiles/layergroup)/static/center/:token/:z/:lat/:lng/:width/:height.:format {:token(f),:z(f),:lat(f),:lng(f),:width(f),:height(f),:format(f)} (1)` -
Notes: Static Maps API +
Notes: Static Maps API [0] 1. `GET (?:/api/v1/map|/tiles/layergroup)/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format {:token(f),:west(f),:south(f),:east(f),:north(f),:width(f),:height(f),:format(f)} (1)` -
Notes: Static Maps API +
Notes: Static Maps API [0] 1. `GET / {} (1)`
Notes: Welcome message @@ -36,13 +36,13 @@ This document list all routes available in Windshaft-cartodb Maps API server.
Notes: **[DEPRECATED]** Style for :table 1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id/jsonp {:template_id(f)} (1)` -
Notes: Named maps JSONP instantiation +
Notes: Named maps JSONP instantiation [1] 1. `GET (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: Named map retrieval (w/ API KEY) +
Notes: Named map retrieval (w/ API KEY) [1] 1. `GET (?:/api/v1/map/named|/tiles/template) {} (1)` -
Notes: List named maps (w/ API KEY) +
Notes: List named maps (w/ API KEY) [1] 1. `GET /tiles/:table/infowindow {:table(f)} (1)`
Notes: **[DEPRECATED]** retrieve info window template for :table @@ -54,7 +54,7 @@ This document list all routes available in Windshaft-cartodb Maps API server.
Notes: Healt check 1. `OPTIONS (?:/api/v1/map|/tiles/layergroup) {} (1)` -
Notes: CORS +
Notes: CORS [0] 1. `OPTIONS /tiles/:table/:z/:x/:y.* {:table(f),:z(f),:x(f),:y(f)} (1)`
Notes: **[DEPRECATED]** CORS @@ -63,31 +63,36 @@ This document list all routes available in Windshaft-cartodb Maps API server.
Notes: **[DEPRECATED]** CORS 1. `OPTIONS (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: CORS +
Notes: CORS [1] 1. `POST (?:/api/v1/map|/tiles/layergroup) {} (1)` -
Notes: Map instantiation +
Notes: Map instantiation [0] 1. `POST /tiles/:table/style {:table(f)} (1)`
Notes: **[DEPRECATED]** Create style for :table 1. `POST (?:/api/v1/map/named|/tiles/template) {} (1)` -
Notes: Create named map +
Notes: Create named map (w/ API KEY) [1] 1. `POST (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: Instantiate named map +
Notes: Instantiate named map [1] 1. `DELETE /tiles/:table/style {:table(f)} (1)`
Notes: **[DEPRECATED]** Delete :table style 1. `DELETE (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: Delete named map +
Notes: Delete named map (w/ API KEY) [1] 1. `DELETE /tiles/:table/flush_cache {:table(f)} (1)`
Notes: **[DEPRECATED]** Flush internal caches for :table 1. `PUT (?:/api/v1/map/named|/tiles/template)/:template_id {:template_id(f)} (1)` -
Notes: Update a named map +
Notes: Update a named map (w/ API KEY) [1] + +## Optional deprecated routes + +[0] `/tiles/layergroup` is deprecated and `/api/v1/map` should be used but we keep it for now. +[1] `/tiles/template` is deprecated and `/api/v1/map/named` should be used but we keep it for now. ## How to generate the list of routes From f35d328dbf8e967ce64a86c92febe507f9a095c5 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Thu, 12 Mar 2015 12:58:46 +0100 Subject: [PATCH 26/52] Update Routes.md --- docs/Routes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/Routes.md b/docs/Routes.md index 8bfa86a0..0920dadf 100644 --- a/docs/Routes.md +++ b/docs/Routes.md @@ -91,8 +91,8 @@ This document list all routes available in Windshaft-cartodb Maps API server. ## Optional deprecated routes -[0] `/tiles/layergroup` is deprecated and `/api/v1/map` should be used but we keep it for now. -[1] `/tiles/template` is deprecated and `/api/v1/map/named` should be used but we keep it for now. +- [0] `/tiles/layergroup` is deprecated and `/api/v1/map` should be used but we keep it for now. +- [1] `/tiles/template` is deprecated and `/api/v1/map/named` should be used but we keep it for now. ## How to generate the list of routes @@ -125,4 +125,4 @@ index 477a4c2..f69eebb 100644 }; -``` \ No newline at end of file +``` From e4da13189d7b2220806885898b528ab7ed5953e3 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:37:03 +0100 Subject: [PATCH 27/52] Adds jshint - dependency - makefile target - relax some rules Work in progress --- .jshintrc | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 4 +++ package.json | 1 + 3 files changed, 97 insertions(+) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..767df861 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,92 @@ +{ +// // JSHint Default Configuration File (as on JSHint website) +// // See http://jshint.com/docs/ for more details +// +// "maxerr" : 50, // {int} Maximum error before stopping +// +// // Enforcing +// "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) +// "camelcase" : false, // true: Identifiers must be in camelCase +// "curly" : true, // true: Require {} for every new block or scope + "eqeqeq" : true, // true: Require triple equals (===) for comparison + "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() + "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. + "immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` +// "indent" : 4, // {int} Number of spaces to use for indentation +// "latedef" : false, // true: Require variables/functions to be defined before being used +// "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` + "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` +// "noempty" : true, // true: Prohibit use of empty blocks + "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. + "nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment) +// "plusplus" : false, // true: Prohibit use of `++` & `--` +// "quotmark" : false, // Quotation mark consistency: +// // false : do nothing (default) +// // true : ensure whatever is used is consistent +// // "single" : require single quotes +// // "double" : require double quotes + "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) +// "unused" : true, // true: Require all defined variables be used +// "strict" : true, // true: Requires all functions run in ES5 Strict Mode +// "maxparams" : false, // {int} Max number of formal params allowed per function +// "maxdepth" : false, // {int} Max depth of nested blocks (within functions) +// "maxstatements" : false, // {int} Max number statements per function +// "maxcomplexity" : 8, // {int} Max cyclomatic complexity per function +// "maxlen" : 120, // {int} Max number of characters per line +// +// // Relaxing +// "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) +// "boss" : false, // true: Tolerate assignments where comparisons would be expected + "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. +// "eqnull" : false, // true: Tolerate use of `== null` +// "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) +// "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`) +// "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) +// // (ex: `for each`, multiple try/catch, function expression…) +// "evil" : false, // true: Tolerate use of `eval` and `new Function()` +// "expr" : false, // true: Tolerate `ExpressionStatement` as Programs +// "funcscope" : false, // true: Tolerate defining variables inside control statements +// "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') +// "iterator" : false, // true: Tolerate using the `__iterator__` property +// "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block +// "laxbreak" : false, // true: Tolerate possibly unsafe line breakings +// "laxcomma" : false, // true: Tolerate comma-first style coding +// "loopfunc" : false, // true: Tolerate functions being defined in loops +// "multistr" : false, // true: Tolerate multi-line strings +// "noyield" : false, // true: Tolerate generator functions with no yield statement in them. +// "notypeof" : false, // true: Tolerate invalid typeof operator values +// "proto" : false, // true: Tolerate using the `__proto__` property +// "scripturl" : false, // true: Tolerate script-targeted URLs +// "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` +// "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation +// "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` +// "validthis" : false, // true: Tolerate using this in a non-constructor function +// +// // Environments +// "browser" : true, // Web Browser (window, document, etc) +// "browserify" : false, // Browserify (node.js code in the browser) +// "couch" : false, // CouchDB +// "devel" : true, // Development/debugging (alert, confirm, etc) +// "dojo" : false, // Dojo Toolkit +// "jasmine" : false, // Jasmine +// "jquery" : false, // jQuery +// "mocha" : true, // Mocha +// "mootools" : false, // MooTools + "node" : true, // Node.js +// "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) +// "prototypejs" : false, // Prototype and Scriptaculous +// "qunit" : false, // QUnit +// "rhino" : false, // Rhino +// "shelljs" : false, // ShellJS +// "worker" : false, // Web Workers +// "wsh" : false, // Windows Scripting Host +// "yui" : false, // Yahoo User Interface + + // Custom Globals + "globals" : { // additional predefined global variables + "suite": true, + "suiteSetup": true, + "test": true, + "suiteTeardown": true + } +} diff --git a/Makefile b/Makefile index 12c9bee6..c1c5a4ac 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,10 @@ test: config/environments/test.js test/acceptance/*.js \ test/acceptance/cache/*.js +jshint: + @echo "***jshint***" + @./node_modules/.bin/jshint lib/ + check: test .PHONY: pre-install test diff --git a/package.json b/package.json index 27f4c317..af48512b 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ }, "devDependencies": { "mocha": "~1.21.4", + "jshint": "~2.6.0", "redis": "~0.8.6", "strftime": "~0.8.2", "semver": "~1.1.4" From fda8afdaf220c4ebf0dca4193020023536cac371 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:44:45 +0100 Subject: [PATCH 28/52] jshint: fix Bad line breaking --- lib/cartodb/api/query_tables_api.js | 6 +++--- lib/cartodb/cartodb_windshaft.js | 4 ++-- lib/cartodb/controllers/template_maps.js | 16 +++++++--------- lib/cartodb/server_options.js | 11 +++++------ lib/cartodb/sql/sql_api.js | 6 +++--- lib/cartodb/template_maps.js | 6 ++---- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/lib/cartodb/api/query_tables_api.js b/lib/cartodb/api/query_tables_api.js index f4795b05..57a3172e 100644 --- a/lib/cartodb/api/query_tables_api.js +++ b/lib/cartodb/api/query_tables_api.js @@ -138,7 +138,7 @@ function prepareSql(sql) { function shouldQueryPostgresDirectly() { - return global.environment - && global.environment.enabledFeatures - && global.environment.enabledFeatures.cdbQueryTablesFromPostgres; + return global.environment && + global.environment.enabledFeatures && + global.environment.enabledFeatures.cdbQueryTablesFromPostgres; } diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 477a4c24..7d1d2d9a 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -18,8 +18,8 @@ var CartodbWindshaft = function(serverOptions) { } } - var redisPool = serverOptions.redis.pool - || require('redis-mpool')(_.extend(global.environment.redis, {name: 'windshaft:cartodb'})); + var redisPool = serverOptions.redis.pool || + require('redis-mpool')(_.extend(global.environment.redis, {name: 'windshaft:cartodb'})); var cartoData = require('cartodb-redis')({pool: redisPool}); diff --git a/lib/cartodb/controllers/template_maps.js b/lib/cartodb/controllers/template_maps.js index 5b61ae56..f683412d 100644 --- a/lib/cartodb/controllers/template_maps.js +++ b/lib/cartodb/controllers/template_maps.js @@ -100,8 +100,7 @@ TemplateMapsController.prototype.update = function(req, res) { tpl_id = req.params.template_id.split('@'); if ( tpl_id.length > 1 ) { if ( tpl_id[0] != cdbuser ) { - err = new Error("Invalid template id '" - + req.params.template_id + "' for user '" + cdbuser + "'"); + err = new Error("Invalid template id '" + req.params.template_id + "' for user '" + cdbuser + "'"); err.http_status = 404; throw err; } @@ -158,8 +157,8 @@ TemplateMapsController.prototype.retrieve = function(req, res) { tpl_id = req.params.template_id.split('@'); if ( tpl_id.length > 1 ) { if ( tpl_id[0] != cdbuser ) { - var err = new Error("Cannot get template id '" - + req.params.template_id + "' for user '" + cdbuser + "'"); + var err = new Error("Cannot get template id '" + req.params.template_id + "' for user '" + cdbuser + + "'"); err.http_status = 404; throw err; } @@ -220,8 +219,8 @@ TemplateMapsController.prototype.destroy = function(req, res) { tpl_id = req.params.template_id.split('@'); if ( tpl_id.length > 1 ) { if ( tpl_id[0] != cdbuser ) { - var err = new Error("Cannot find template id '" - + req.params.template_id + "' for user '" + cdbuser + "'"); + var err = new Error("Cannot find template id '" + req.params.template_id + "' for user '" + + cdbuser + "'"); err.http_status = 404; throw err; } @@ -361,9 +360,8 @@ TemplateMapsController.prototype.instantiateTemplate = function(req, res, templa var tpl_id = req.params.template_id.split('@'); if ( tpl_id.length > 1 ) { if ( tpl_id[0] && tpl_id[0] != cdbuser ) { - var err = new Error('Cannot instanciate map of user "' - + tpl_id[0] + '" on database of user "' - + cdbuser + '"'); + var err = new Error('Cannot instanciate map of user "' + tpl_id[0] + '" on database of user "' + cdbuser + + '"'); err.http_status = 403; callback(err); return; diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index e0011795..da71e5c8 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -35,8 +35,8 @@ var REQUEST_QUERY_PARAMS_WHITELIST = [ ]; module.exports = function(redisPool) { - redisPool = redisPool - || require('redis-mpool')(_.extend(global.environment.redis, {name: 'windshaft:server_options'})); + redisPool = redisPool || + require('redis-mpool')(_.extend(global.environment.redis, {name: 'windshaft:server_options'})); var cartoData = require('cartodb-redis')({ pool: redisPool }), lzmaWorker = new LZMA(), @@ -377,14 +377,13 @@ module.exports = function(redisPool) { var host = req.headers.host; var mat = host.match(this.re_userFromHost); if ( ! mat ) { - console.error("ERROR: user pattern '" + this.re_userFromHost - + "' does not match hostname '" + host + "'"); + console.error("ERROR: user pattern '" + this.re_userFromHost + "' does not match hostname '" + host + "'"); return; } // console.log("Matches: "); console.dir(mat); if ( ! mat.length === 2 ) { - console.error("ERROR: pattern '" + this.re_userFromHost - + "' gave unexpected matches against '" + host + "': " + mat); + console.error("ERROR: pattern '" + this.re_userFromHost + "' gave unexpected matches against '" + host + "': " + + mat); return; } return mat[1]; diff --git a/lib/cartodb/sql/sql_api.js b/lib/cartodb/sql/sql_api.js index 44c831e2..d5f742f9 100644 --- a/lib/cartodb/sql/sql_api.js +++ b/lib/cartodb/sql/sql_api.js @@ -36,11 +36,11 @@ module.exports.query = function (username, api_key, sql, callback) { var reqSpec = { url:sqlapi, json:true, - headers:{host: sqlapihostname} + headers:{host: sqlapihostname}, // http://nodejs.org/api/http.html#http_agent_maxsockets - ,pool:{maxSockets:maxSockets} + pool:{maxSockets:maxSockets}, // timeout in milliseconds - ,timeout:maxSQLTime + timeout:maxSQLTime }; if ( sql.length > maxGetLen ) { reqSpec.method = 'POST'; diff --git a/lib/cartodb/template_maps.js b/lib/cartodb/template_maps.js index 164161a8..ab46ecc9 100644 --- a/lib/cartodb/template_maps.js +++ b/lib/cartodb/template_maps.js @@ -450,16 +450,14 @@ o.instance = function(template, params) { else if ( type === 'number' ) { // check it's a number if ( typeof(val) !== 'number' && ! val.match(_reNumber) ) { - throw new Error("Invalid number value for template parameter '" - + k + "': " + val); + throw new Error("Invalid number value for template parameter '" + k + "': " + val); } } else if ( type === 'css_color' ) { // check it only contains letters or // starts with # and only contains hexdigits if ( ! val.match(_reCSSColorName) && ! val.match(_reCSSColorVal) ) { - throw new Error("Invalid css_color value for template parameter '" - + k + "': " + val); + throw new Error("Invalid css_color value for template parameter '" + k + "': " + val); } } else { From d03a2c64a6a06b1bfe8dd5ee702efa61a58d763e Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:46:59 +0100 Subject: [PATCH 29/52] jshint: fix Missing semicolon --- lib/cartodb/cache_validator.js | 2 +- lib/cartodb/cartodb_windshaft.js | 2 +- lib/cartodb/server_options.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cartodb/cache_validator.js b/lib/cartodb/cache_validator.js index 22793603..b974e094 100644 --- a/lib/cartodb/cache_validator.js +++ b/lib/cartodb/cache_validator.js @@ -23,4 +23,4 @@ function invalidate_db(dbname, table) { module.exports = { init: init, invalidate_db: invalidate_db -} +}; diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 7d1d2d9a..524d572f 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -31,7 +31,7 @@ var CartodbWindshaft = function(serverOptions) { serverOptions.afterStateChange = function(req, data, callback) { Cache.invalidate_db(req.params.dbname, req.params.table); callback(null, data); - } + }; } serverOptions.beforeStateChange = function(req, callback) { diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index da71e5c8..93f08e09 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -287,7 +287,7 @@ module.exports = function(redisPool) { } requestMapConfig.layers = layers; - return callback(null, requestMapConfig, datasource) + return callback(null, requestMapConfig, datasource); }); }; @@ -558,7 +558,7 @@ module.exports = function(redisPool) { //console.log("type of req.query.lzma is " + typeof(req.query.lzma)); // Decode (from base64) - var lzma = (new Buffer(req.query.lzma, 'base64').toString('binary')).split('').map(function(c) { return c.charCodeAt(0) - 128 }); + var lzma = (new Buffer(req.query.lzma, 'base64').toString('binary')).split('').map(function(c) { return c.charCodeAt(0) - 128; }); // Decompress lzmaWorker.decompress( From e561f77d4d7b343b8b13f2a7820654c418352d1c Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:49:32 +0100 Subject: [PATCH 30/52] jshint: fix Dot notation --- lib/cartodb/backends/pg_connection.js | 4 ++-- lib/cartodb/cartodb_windshaft.js | 4 ++-- lib/cartodb/template_maps.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/cartodb/backends/pg_connection.js b/lib/cartodb/backends/pg_connection.js index 37209b98..6688e00c 100644 --- a/lib/cartodb/backends/pg_connection.js +++ b/lib/cartodb/backends/pg_connection.js @@ -30,7 +30,7 @@ PgConnection.prototype.setDBAuth = function(username, params, callback) { }, function(err, user_id) { if (err) throw err; - user_params['user_id'] = user_id; + user_params.user_id = user_id; var dbuser = _.template(auth_user, user_params); _.extend(params, {dbuser:dbuser}); @@ -42,7 +42,7 @@ PgConnection.prototype.setDBAuth = function(username, params, callback) { }, function(err, user_password) { if (err) throw err; - user_params['user_password'] = user_password; + user_params.user_password = user_password; if ( auth_pass ) { var dbpass = _.template(auth_pass, user_params); _.extend(params, {dbpassword:dbpass}); diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 524d572f..53f731f7 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -5,8 +5,8 @@ var Cache = require('./cache_validator'); var os = require('os'); var HealthCheck = require('./monitoring/health_check'); -if ( ! process.env['PGAPPNAME'] ) - process.env['PGAPPNAME']='cartodb_tiler'; +if ( ! process.env.PGAPPNAME ) + process.env.PGAPPNAME='cartodb_tiler'; var CartodbWindshaft = function(serverOptions) { // Perform keyword substitution in statsd diff --git a/lib/cartodb/template_maps.js b/lib/cartodb/template_maps.js index ab46ecc9..520266a2 100644 --- a/lib/cartodb/template_maps.js +++ b/lib/cartodb/template_maps.js @@ -56,7 +56,7 @@ var o = TemplateMaps.prototype; //--------------- PRIVATE METHODS -------------------------------- o._userTemplateLimit = function() { - return this.opts['max_user_templates'] || 0; + return this.opts.max_user_templates || 0; }; /** From bd1c24ee1c7fe6c5eb0889cd12cb5beeb9347ab3 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:52:46 +0100 Subject: [PATCH 31/52] jshint: Remove Confusing use of '!' --- lib/cartodb/server_options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 93f08e09..8c50a0d1 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -381,7 +381,7 @@ module.exports = function(redisPool) { return; } // console.log("Matches: "); console.dir(mat); - if ( ! mat.length === 2 ) { + if ( mat.length !== 2 ) { console.error("ERROR: pattern '" + this.re_userFromHost + "' gave unexpected matches against '" + host + "': " + mat); return; From 438ecd5598bc37376461bde2d82b97ec45434b33 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:56:14 +0100 Subject: [PATCH 32/52] jshint: fix Function declarations should not be placed in blocks --- .jshintrc | 2 +- lib/cartodb/cartodb_windshaft.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.jshintrc b/.jshintrc index 767df861..2b7a9367 100644 --- a/.jshintrc +++ b/.jshintrc @@ -8,7 +8,7 @@ // "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) // "camelcase" : false, // true: Identifiers must be in camelCase // "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison +// "eqeqeq" : true, // true: Require triple equals (===) for comparison "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. "immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 53f731f7..82da2d68 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -54,15 +54,15 @@ var CartodbWindshaft = function(serverOptions) { varnishHttpCacheBackend = new VarnishHttpCacheBackend(serverOptions.varnish_host, serverOptions.varnish_http_port), surrogateKeysCache = new SurrogateKeysCache(varnishHttpCacheBackend); - if (serverOptions.varnish_purge_enabled) { - function invalidateNamedMap(owner, templateName) { - surrogateKeysCache.invalidate(new NamedMapsCacheEntry(owner, templateName), function(err) { - if (err) { - console.warn('Cache: surrogate key invalidation failed'); - } - }); - } + function invalidateNamedMap (owner, templateName) { + surrogateKeysCache.invalidate(new NamedMapsCacheEntry(owner, templateName), function(err) { + if (err) { + console.warn('Cache: surrogate key invalidation failed'); + } + }); + } + if (serverOptions.varnish_purge_enabled) { ['update', 'delete'].forEach(function(eventType) { templateMaps.on(eventType, invalidateNamedMap); }); From 406a1ffb0b40c0a6e4e01b1966da2a66d9881ab8 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:58:12 +0100 Subject: [PATCH 33/52] no global replaceVars func --- lib/cartodb/template_maps.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/template_maps.js b/lib/cartodb/template_maps.js index 520266a2..e35dcbbf 100644 --- a/lib/cartodb/template_maps.js +++ b/lib/cartodb/template_maps.js @@ -424,14 +424,14 @@ var _reNumber = /^([-+]?[\d\.]?\d+([eE][+-]?\d+)?)$/, _reCSSColorName = /^[a-zA-Z]+$/, _reCSSColorVal = /^#[0-9a-fA-F]{3,6}$/; -_replaceVars = function(str, params) { +function _replaceVars (str, params) { //return _.template(str, params); // lazy way, possibly dangerous // Construct regular expressions for each param Object.keys(params).forEach(function(k) { str = str.replace(new RegExp("<%=\\s*" + k + "\\s*%>", "g"), params[k]); }); return str; -}; +} o.instance = function(template, params) { var all_params = {}; var phold = template.placeholders || {}; From 5df24e7f27da884e7e838d6bf11a572b41a92074 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Sun, 15 Mar 2015 23:58:38 +0100 Subject: [PATCH 34/52] Remove Unreachable 'break' after 'return' --- lib/cartodb/template_maps.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cartodb/template_maps.js b/lib/cartodb/template_maps.js index e35dcbbf..b9b490f5 100644 --- a/lib/cartodb/template_maps.js +++ b/lib/cartodb/template_maps.js @@ -136,7 +136,6 @@ o._checkInvalidTemplate = function(template) { break; default: return new Error("Unsupported authentication method: " + auth.method); - break; } return false; From d7f5c406450747a5f4d512ffea5d7ddc7c5ea68f Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:00:02 +0100 Subject: [PATCH 35/52] Triple === --- lib/cartodb/server_options.js | 4 ++-- lib/cartodb/sql/sql_api.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 8c50a0d1..e77a544b 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -196,7 +196,7 @@ module.exports = function(redisPool) { // strip out windshaft/mapnik inserted sql if present var sql = req.params.sql.match(/^\((.*)\)\sas\scdbq$/); - sql = (sql != null) ? sql[1] : req.params.sql; + sql = (sql !== null) ? sql[1] : req.params.sql; return sql; }, @@ -596,7 +596,7 @@ module.exports = function(redisPool) { if ( tksplit.length > 1 ) { req.params.signer = tksplit.shift(); if ( ! req.params.signer ) req.params.signer = user; - else if ( req.params.signer != user ) { + else if ( req.params.signer !== user ) { var err = new Error('Cannot use map signature of user "' + req.params.signer + '" on database of user "' + user + '"'); err.http_status = 403; callback(err); diff --git a/lib/cartodb/sql/sql_api.js b/lib/cartodb/sql/sql_api.js index d5f742f9..32885e57 100644 --- a/lib/cartodb/sql/sql_api.js +++ b/lib/cartodb/sql/sql_api.js @@ -16,7 +16,7 @@ module.exports.query = function (username, api_key, sql, callback) { var qs = { q: sql }; // add api_key if given - if (_.isString(api_key) && api_key != '') { qs.api_key = api_key; } + if (_.isString(api_key) && api_key !== '') { qs.api_key = api_key; } // call sql api // From 0a331cee372ff5816a5eef7950ac8c92f6513a69 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:03:59 +0100 Subject: [PATCH 36/52] do not redefine vars --- lib/cartodb/controllers/template_maps.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/cartodb/controllers/template_maps.js b/lib/cartodb/controllers/template_maps.js index f683412d..5dd425b2 100644 --- a/lib/cartodb/controllers/template_maps.js +++ b/lib/cartodb/controllers/template_maps.js @@ -157,10 +157,10 @@ TemplateMapsController.prototype.retrieve = function(req, res) { tpl_id = req.params.template_id.split('@'); if ( tpl_id.length > 1 ) { if ( tpl_id[0] != cdbuser ) { - var err = new Error("Cannot get template id '" + req.params.template_id + "' for user '" + cdbuser + - "'"); - err.http_status = 404; - throw err; + var templateNotFoundErr = new Error("Cannot get template id '" + req.params.template_id + + "' for user '" + cdbuser + "'"); + templateNotFoundErr.http_status = 404; + throw templateNotFoundErr; } tpl_id = tpl_id[1]; } @@ -219,10 +219,10 @@ TemplateMapsController.prototype.destroy = function(req, res) { tpl_id = req.params.template_id.split('@'); if ( tpl_id.length > 1 ) { if ( tpl_id[0] != cdbuser ) { - var err = new Error("Cannot find template id '" + req.params.template_id + "' for user '" + - cdbuser + "'"); - err.http_status = 404; - throw err; + var templateNotFoundErr = new Error("Cannot find template id '" + req.params.template_id + + "' for user '" + cdbuser + "'"); + templateNotFoundErr.http_status = 404; + throw templateNotFoundErr; } tpl_id = tpl_id[1]; } From 3c56c1fab3ca3e8ee1c5e75acc09c19029837f30 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:05:01 +0100 Subject: [PATCH 37/52] Adds next param --- lib/cartodb/controllers/template_maps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cartodb/controllers/template_maps.js b/lib/cartodb/controllers/template_maps.js index 5dd425b2..d6b6f528 100644 --- a/lib/cartodb/controllers/template_maps.js +++ b/lib/cartodb/controllers/template_maps.js @@ -310,7 +310,7 @@ TemplateMapsController.prototype.instantiate = function(req, res) { ); }; -TemplateMapsController.prototype.options = function(req, res) { +TemplateMapsController.prototype.options = function(req, res, next) { this.app.doCORS(res, "Content-Type"); return next(); }; From 4365c1dbc26aeea4bef45a2a2d5dd37586a56f89 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:07:05 +0100 Subject: [PATCH 38/52] Define mapnikXmlParams variable --- lib/cartodb/monitoring/health_check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index 873cd19d..f925c616 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -40,7 +40,7 @@ HealthCheck.prototype.check = function(config, callback) { ok: false } }; - mapnikXmlParams = config; + var mapnikXmlParams = config; Step( function getDBParams() { From 336491b54ca9f88c1f122bd37b4134fa73c1db3c Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:16:36 +0100 Subject: [PATCH 39/52] Remove unused vars --- .jshintrc | 2 +- lib/cartodb/cache_validator.js | 5 ++--- lib/cartodb/cartodb_windshaft.js | 2 +- lib/cartodb/controllers/template_maps.js | 4 +--- lib/cartodb/monitoring/health_check.js | 9 ++++----- lib/cartodb/server_options.js | 6 ++---- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.jshintrc b/.jshintrc index 2b7a9367..4f460e41 100644 --- a/.jshintrc +++ b/.jshintrc @@ -26,7 +26,7 @@ // // "single" : require single quotes // // "double" : require double quotes "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) -// "unused" : true, // true: Require all defined variables be used + "unused" : true, // true: Require all defined variables be used // "strict" : true, // true: Requires all functions run in ES5 Strict Mode // "maxparams" : false, // {int} Max number of formal params allowed per function // "maxdepth" : false, // {int} Max depth of nested blocks (within functions) diff --git a/lib/cartodb/cache_validator.js b/lib/cartodb/cache_validator.js index b974e094..4b3f2181 100644 --- a/lib/cartodb/cache_validator.js +++ b/lib/cartodb/cache_validator.js @@ -1,6 +1,5 @@ -var _ = require('underscore'), - Varnish = require('node-varnish'), - varnish_queue = null; +var Varnish = require('node-varnish'); +var varnish_queue = null; function init(host, port, secret) { varnish_queue = new Varnish.VarnishQueue(host, port, secret); diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 82da2d68..41255f9d 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -127,7 +127,7 @@ var CartodbWindshaft = function(serverOptions) { //console.log("Adding cache channel to route\n" + req.route.path + " not matching any in:\n" + mapCreateRoutes.join("\n")); serverOptions.addCacheChannel(that, req, this); }, - function sendResponse(err, added) { + function sendResponse(err/*, added*/) { if ( err ) console.log(err + err.stack); ws_sendResponse.apply(that, thatArgs); return null; diff --git a/lib/cartodb/controllers/template_maps.js b/lib/cartodb/controllers/template_maps.js index d6b6f528..c23d86a9 100644 --- a/lib/cartodb/controllers/template_maps.js +++ b/lib/cartodb/controllers/template_maps.js @@ -141,7 +141,6 @@ TemplateMapsController.prototype.retrieve = function(req, res) { this.app.doCORS(res); var cdbuser = this.serverOptions.userByReq(req); - var template; var tpl_id; Step( function checkPerms(){ @@ -203,7 +202,6 @@ TemplateMapsController.prototype.destroy = function(req, res) { this.app.doCORS(res); var cdbuser = this.serverOptions.userByReq(req); - var template; var tpl_id; Step( function checkPerms(){ @@ -228,7 +226,7 @@ TemplateMapsController.prototype.destroy = function(req, res) { } self.templateMaps.delTemplate(cdbuser, tpl_id, this); }, - function prepareResponse(err, tpl_val){ + function prepareResponse(err/*, tpl_val*/){ if ( err ) throw err; return { status: 'ok' }; }, diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index f925c616..9e239583 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -1,8 +1,7 @@ -var _ = require('underscore'), - dot = require('dot'), - fs = require('fs'), - path = require('path'), - Step = require('step'); +var dot = require('dot'); +var fs = require('fs'); +var path = require('path'); +var Step = require('step'); function HealthCheck(metadataBackend, tilelive) { this.metadataBackend = metadataBackend; diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index e77a544b..cf1f383c 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -573,7 +573,7 @@ module.exports = function(redisPool) { callback(new Error('Error parsing lzma as JSON: ' + err)); } }, - function(percent) { // progress + function(/*percent*/) { // progress //console.log("LZMA decompression " + percent + "%"); } ); @@ -603,7 +603,7 @@ module.exports = function(redisPool) { return; } if ( tksplit.length > 1 ) { - var template_hash = tksplit.shift(); // unused + /*var template_hash = */tksplit.shift(); // unused } req.params.token = tksplit.shift(); //console.log("Request for token " + req.params.token + " with signature from " + req.params.signer); @@ -616,8 +616,6 @@ module.exports = function(redisPool) { // for cartodb, ensure interactivity is cartodb_id or user specified req.params.interactivity = req.params.interactivity || 'cartodb_id'; - var that = this; - if (req.profiler) req.profiler.done('req2params.setup'); Step( From 8c09dfd230b077ea5a913db5b69e9b3a1b0a3f92 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:21:55 +0100 Subject: [PATCH 40/52] No capitalize step --- .jshintrc | 2 +- lib/cartodb/api/query_tables_api.js | 6 +++--- lib/cartodb/backends/pg_connection.js | 6 +++--- lib/cartodb/cartodb_windshaft.js | 8 ++++---- lib/cartodb/controllers/template_maps.js | 20 ++++++++++---------- lib/cartodb/monitoring/health_check.js | 4 ++-- lib/cartodb/server_options.js | 18 +++++++++--------- lib/cartodb/template_maps.js | 18 +++++++++--------- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.jshintrc b/.jshintrc index 4f460e41..30101b4c 100644 --- a/.jshintrc +++ b/.jshintrc @@ -14,7 +14,7 @@ "immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` // "indent" : 4, // {int} Number of spaces to use for indentation // "latedef" : false, // true: Require variables/functions to be defined before being used -// "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` + "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` // "noempty" : true, // true: Prohibit use of empty blocks "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. diff --git a/lib/cartodb/api/query_tables_api.js b/lib/cartodb/api/query_tables_api.js index 57a3172e..1db18489 100644 --- a/lib/cartodb/api/query_tables_api.js +++ b/lib/cartodb/api/query_tables_api.js @@ -1,6 +1,6 @@ var sqlApi = require('../sql/sql_api'); var PSQL = require('cartodb-psql'); -var Step = require('step'); +var step = require('step'); function QueryTablesApi(pgConnection, metadataBackend) { this.pgConnection = pgConnection; @@ -78,7 +78,7 @@ QueryTablesApi.prototype.runQuery = function(username, query, queryHandler, call var params = {}; - Step( + step( function setAuth() { self.pgConnection.setDBAuth(username, params, this); }, @@ -109,7 +109,7 @@ QueryTablesApi.prototype.runQuery = function(username, query, queryHandler, call } else { - Step( + step( function getApiKey() { self.metadataBackend.getUserMapKey(username, this); }, diff --git a/lib/cartodb/backends/pg_connection.js b/lib/cartodb/backends/pg_connection.js index 6688e00c..7e4aad15 100644 --- a/lib/cartodb/backends/pg_connection.js +++ b/lib/cartodb/backends/pg_connection.js @@ -1,4 +1,4 @@ -var Step = require('step'); +var step = require('step'); var _ = require('underscore'); function PgConnection(metadataBackend) { @@ -24,7 +24,7 @@ PgConnection.prototype.setDBAuth = function(username, params, callback) { var user_params = {}; var auth_user = global.environment.postgres_auth_user; var auth_pass = global.environment.postgres_auth_pass; - Step( + step( function getId() { self.metadataBackend.getUserId(username, this); }, @@ -76,7 +76,7 @@ PgConnection.prototype.setDBConn = function(dbowner, params, callback) { dbhost: global.environment.postgres.host, dbport: global.environment.postgres.port }); - Step( + step( function getConnectionParams() { self.metadataBackend.getUserDBConnectionParams(dbowner, this); }, diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 41255f9d..bc797948 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -1,5 +1,5 @@ var _ = require('underscore'); -var Step = require('step'); +var step = require('step'); var Windshaft = require('windshaft'); var Cache = require('./cache_validator'); var os = require('os'); @@ -102,7 +102,7 @@ var CartodbWindshaft = function(serverOptions) { } } var req = res.req; - Step ( + step ( function addCacheChannel() { if ( ! req ) { // having no associated request can happen when @@ -172,7 +172,7 @@ var CartodbWindshaft = function(serverOptions) { */ ws.get(serverOptions.base_url + '/infowindow', function(req, res){ ws.doCORS(res); - Step( + step( function(){ serverOptions.getInfowindow(req, this); }, @@ -193,7 +193,7 @@ var CartodbWindshaft = function(serverOptions) { */ ws.get(serverOptions.base_url + '/map_metadata', function(req, res){ ws.doCORS(res); - Step( + step( function(){ serverOptions.getMapMetadata(req, this); }, diff --git a/lib/cartodb/controllers/template_maps.js b/lib/cartodb/controllers/template_maps.js index c23d86a9..452f7225 100644 --- a/lib/cartodb/controllers/template_maps.js +++ b/lib/cartodb/controllers/template_maps.js @@ -1,4 +1,4 @@ -var Step = require('step'); +var step = require('step'); var _ = require('underscore'); function TemplateMapsController(app, serverOptions, templateMaps, metadataBackend, templateBaseUrl, surrogateKeysCache, @@ -35,7 +35,7 @@ TemplateMapsController.prototype.create = function(req, res) { var cdbuser = self.serverOptions.userByReq(req); - Step( + step( function checkPerms(){ self.serverOptions.authorizedByAPIKey(req, this); }, @@ -83,7 +83,7 @@ TemplateMapsController.prototype.update = function(req, res) { var cdbuser = this.serverOptions.userByReq(req); var template; var tpl_id; - Step( + step( function checkPerms(){ self.serverOptions.authorizedByAPIKey(req, this); }, @@ -142,7 +142,7 @@ TemplateMapsController.prototype.retrieve = function(req, res) { var cdbuser = this.serverOptions.userByReq(req); var tpl_id; - Step( + step( function checkPerms(){ self.serverOptions.authorizedByAPIKey(req, this); }, @@ -203,7 +203,7 @@ TemplateMapsController.prototype.destroy = function(req, res) { var cdbuser = this.serverOptions.userByReq(req); var tpl_id; - Step( + step( function checkPerms(){ self.serverOptions.authorizedByAPIKey(req, this); }, @@ -256,7 +256,7 @@ TemplateMapsController.prototype.list = function(req, res) { var cdbuser = this.serverOptions.userByReq(req); - Step( + step( function checkPerms(){ self.serverOptions.authorizedByAPIKey(req, this); }, @@ -296,7 +296,7 @@ TemplateMapsController.prototype.instantiate = function(req, res) { if ( req.profiler && req.profiler.statsd_client) { req.profiler.start('windshaft-cartodb.instance_template_post'); } - Step( + step( function() { if ( ! req.headers['content-type'] || req.headers['content-type'].split(';')[0] != 'application/json') { throw new Error('template POST data must be of type application/json, it is instead '); @@ -323,7 +323,7 @@ TemplateMapsController.prototype.jsonp = function(req, res) { if ( req.profiler && req.profiler.statsd_client) { req.profiler.start('windshaft-cartodb.instance_template_get'); } - Step( + step( function() { if ( req.query.callback === undefined || req.query.callback.length === 0) { throw new Error('callback parameter should be present and be a function name'); @@ -367,7 +367,7 @@ TemplateMapsController.prototype.instantiateTemplate = function(req, res, templa tpl_id = tpl_id[1]; } var auth_token = req.query.auth_token; - Step( + step( function getTemplate(){ self.templateMaps.getTemplate(cdbuser, tpl_id, this); }, @@ -460,7 +460,7 @@ TemplateMapsController.prototype.finish_instantiation = function(err, response, TemplateMapsController.prototype.setDBParams = function(cdbuser, params, callback) { var self = this; - Step( + step( function setAuth() { self.pgConnection.setDBAuth(cdbuser, params, this); }, diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index 9e239583..930f20a4 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -1,7 +1,7 @@ var dot = require('dot'); var fs = require('fs'); var path = require('path'); -var Step = require('step'); +var step = require('step'); function HealthCheck(metadataBackend, tilelive) { this.metadataBackend = metadataBackend; @@ -41,7 +41,7 @@ HealthCheck.prototype.check = function(config, callback) { }; var mapnikXmlParams = config; - Step( + step( function getDBParams() { startTime = Date.now(); self.metadataBackend.getAllUserDBParams(config.username, this); diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index cf1f383c..4daacc4b 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -1,5 +1,5 @@ var _ = require('underscore'); -var Step = require('step'); +var step = require('step'); var QueryTablesApi = require('./api/query_tables_api'); var PgConnection = require('./backends/pg_connection'); var crypto = require('crypto'); @@ -147,7 +147,7 @@ module.exports = function(redisPool) { var that = this; - Step ( + step ( function checkCached() { if ( me.channelCache.hasOwnProperty(cacheKey) ) { callback(null, me.channelCache[cacheKey]); @@ -167,7 +167,7 @@ module.exports = function(redisPool) { } var next = this; var mapStore = app.mapStore; - Step( + step( function loadFromStore() { mapStore.load(req.params.token, this); }, @@ -333,7 +333,7 @@ module.exports = function(redisPool) { var dbName = req.params.dbname; var cacheKey = dbName + ':' + token; - Step( + step( function getAffectedTablesAndLastUpdatedTime() { queryTablesApi.getAffectedTablesAndLastUpdatedTime(username, sql, this); }, @@ -444,7 +444,7 @@ module.exports = function(redisPool) { } //console.log("given ApiKey: " + givenKey); var user = me.userByReq(req); - Step( + step( function (){ cartoData.getUserMapKey(user, this); }, @@ -468,7 +468,7 @@ module.exports = function(redisPool) { var that = this; var user = me.userByReq(req); - Step( + step( function (){ that.authorizedByAPIKey(req, this); }, @@ -618,7 +618,7 @@ module.exports = function(redisPool) { if (req.profiler) req.profiler.done('req2params.setup'); - Step( + step( function getPrivacy(){ me.authorize(req, this); }, @@ -671,7 +671,7 @@ module.exports = function(redisPool) { var that = this; var user = me.userByReq(req); - Step( + step( function(){ // TODO: if this step really needed ? that.req2params(req, this); @@ -699,7 +699,7 @@ module.exports = function(redisPool) { var that = this; var user = me.userByReq(req); - Step( + step( function(){ // TODO: if this step really needed ? that.req2params(req, this); diff --git a/lib/cartodb/template_maps.js b/lib/cartodb/template_maps.js index b9b490f5..d7b7f66b 100644 --- a/lib/cartodb/template_maps.js +++ b/lib/cartodb/template_maps.js @@ -1,7 +1,7 @@ -var crypto = require('crypto'), - Step = require('step'), - _ = require('underscore'), - dot = require('dot'); +var crypto = require('crypto'); +var step = require('step'); +var _ = require('underscore'); +var dot = require('dot'); var EventEmitter = require('events').EventEmitter; @@ -71,7 +71,7 @@ o._redisCmd = function(redisFunc, redisArgs, callback) { var that = this; var db = that.db_signatures; - Step( + step( function getRedisClient() { that.redis_pool.acquire(db, this); }, @@ -204,7 +204,7 @@ o.addTemplate = function(owner, template, callback) { var userTemplatesKey = this.key_usr_tpl({ owner:owner }); var limit = this._userTemplateLimit(); - Step( + step( function checkLimit() { if ( ! limit ) { return 0; @@ -252,7 +252,7 @@ o.addTemplate = function(owner, template, callback) { // o.delTemplate = function(owner, tpl_id, callback) { var self = this; - Step( + step( function deleteTemplate() { self._redisCmd('HDEL', [ self.key_usr_tpl({ owner:owner }), tpl_id ], this); }, @@ -310,7 +310,7 @@ o.updTemplate = function(owner, tpl_id, template, callback) { var userTemplatesKey = this.key_usr_tpl({ owner:owner }); - Step( + step( function getExistingTemplate() { self._redisCmd('HGET', [ userTemplatesKey, tpl_id ], this); }, @@ -365,7 +365,7 @@ o.listTemplates = function(owner, callback) { // o.getTemplate = function(owner, tpl_id, callback) { var self = this; - Step( + step( function getTemplate() { self._redisCmd('HGET', [ self.key_usr_tpl({owner:owner}), tpl_id ], this); }, From 645a2cd4420c0f44da92fb08f5304ee1f70b73ad Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:27:14 +0100 Subject: [PATCH 41/52] 120 chars lines --- .jshintrc | 4 ++-- lib/cartodb/cartodb_windshaft.js | 11 ++++++++--- lib/cartodb/server_options.js | 29 +++++++++++++++++++---------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.jshintrc b/.jshintrc index 30101b4c..74f558f1 100644 --- a/.jshintrc +++ b/.jshintrc @@ -31,8 +31,8 @@ // "maxparams" : false, // {int} Max number of formal params allowed per function // "maxdepth" : false, // {int} Max depth of nested blocks (within functions) // "maxstatements" : false, // {int} Max number statements per function -// "maxcomplexity" : 8, // {int} Max cyclomatic complexity per function -// "maxlen" : 120, // {int} Max number of characters per line +// "maxcomplexity" : 6, // {int} Max cyclomatic complexity per function + "maxlen" : 120, // {int} Max number of characters per line // // // Relaxing // "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index bc797948..28e5c40d 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -26,7 +26,8 @@ var CartodbWindshaft = function(serverOptions) { var templateMaps = serverOptions.templateMaps; if(serverOptions.cache_enabled) { - console.log("cache invalidation enabled, varnish on ", serverOptions.varnish_host, ' ', serverOptions.varnish_port); + console.log("cache invalidation enabled, varnish on ", serverOptions.varnish_host, ' ', + serverOptions.varnish_port); Cache.init(serverOptions.varnish_host, serverOptions.varnish_port, serverOptions.varnish_secret); serverOptions.afterStateChange = function(req, data, callback) { Cache.invalidate_db(req.params.dbname, req.params.table); @@ -51,7 +52,10 @@ var CartodbWindshaft = function(serverOptions) { var SurrogateKeysCache = require('./cache/surrogate_keys_cache'), NamedMapsCacheEntry = require('./cache/model/named_maps_entry'), VarnishHttpCacheBackend = require('./cache/backend/varnish_http'), - varnishHttpCacheBackend = new VarnishHttpCacheBackend(serverOptions.varnish_host, serverOptions.varnish_http_port), + varnishHttpCacheBackend = new VarnishHttpCacheBackend( + serverOptions.varnish_host, + serverOptions.varnish_http_port + ), surrogateKeysCache = new SurrogateKeysCache(varnishHttpCacheBackend); function invalidateNamedMap (owner, templateName) { @@ -124,7 +128,8 @@ var CartodbWindshaft = function(serverOptions) { //console.log("Skipping cache channel in route:\n" + req.route.path); return false; } -//console.log("Adding cache channel to route\n" + req.route.path + " not matching any in:\n" + mapCreateRoutes.join("\n")); +//console.log("Adding cache channel to route\n" + req.route.path + " not matching any in:\n" + +// mapCreateRoutes.join("\n")); serverOptions.addCacheChannel(that, req, this); }, function sendResponse(err/*, added*/) { diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 4daacc4b..92e04f4a 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -281,14 +281,16 @@ module.exports = function(redisPool) { }; me.beforeLayergroupCreate = function(req, requestMapConfig, callback) { - mapConfigNamedLayersAdapter.getLayers(this.userByReq(req), requestMapConfig.layers, pgConnection, function(err, layers, datasource) { - if (err) { - return callback(err); - } + mapConfigNamedLayersAdapter.getLayers(this.userByReq(req), requestMapConfig.layers, pgConnection, + function(err, layers, datasource) { + if (err) { + return callback(err); + } - requestMapConfig.layers = layers; - return callback(null, requestMapConfig, datasource); - }); + requestMapConfig.layers = layers; + return callback(null, requestMapConfig, datasource); + } + ); }; me.afterLayergroupCreate = function(req, mapconfig, response, callback) { @@ -408,7 +410,8 @@ module.exports = function(redisPool) { var layergroup_id = req.params.token; var auth_token = req.params.auth_token; - //console.log("Checking authorization from signer " + signer + " for resource " + layergroup_id + " with auth_token " + auth_token); + //console.log("Checking authorization from signer " + signer + " for resource " + layergroup_id + + // " with auth_token " + auth_token); var mapStore = req.app.mapStore; if (!mapStore) { throw new Error('Unable to retrieve map configuration token'); @@ -558,7 +561,12 @@ module.exports = function(redisPool) { //console.log("type of req.query.lzma is " + typeof(req.query.lzma)); // Decode (from base64) - var lzma = (new Buffer(req.query.lzma, 'base64').toString('binary')).split('').map(function(c) { return c.charCodeAt(0) - 128; }); + var lzma = new Buffer(req.query.lzma, 'base64') + .toString('binary') + .split('') + .map(function(c) { + return c.charCodeAt(0) - 128; + }); // Decompress lzmaWorker.decompress( @@ -597,7 +605,8 @@ module.exports = function(redisPool) { req.params.signer = tksplit.shift(); if ( ! req.params.signer ) req.params.signer = user; else if ( req.params.signer !== user ) { - var err = new Error('Cannot use map signature of user "' + req.params.signer + '" on database of user "' + user + '"'); + var err = new Error('Cannot use map signature of user "' + req.params.signer + '" on database of user "' + + user + '"'); err.http_status = 403; callback(err); return; From b6d3785599b6fe7404213fca7561598c4ca29c41 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:36:38 +0100 Subject: [PATCH 42/52] Fix Max cyclomatic complexity value --- .jshintrc | 2 +- lib/cartodb/server_options.js | 1 + lib/cartodb/template_maps.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 74f558f1..e8d605fc 100644 --- a/.jshintrc +++ b/.jshintrc @@ -31,7 +31,7 @@ // "maxparams" : false, // {int} Max number of formal params allowed per function // "maxdepth" : false, // {int} Max depth of nested blocks (within functions) // "maxstatements" : false, // {int} Max number statements per function -// "maxcomplexity" : 6, // {int} Max cyclomatic complexity per function + "maxcomplexity" : 8, // {int} Max cyclomatic complexity per function "maxlen" : 120, // {int} Max number of characters per line // // // Relaxing diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 92e04f4a..ff052586 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -547,6 +547,7 @@ module.exports = function(redisPool) { ); }; + // jshint maxcomplexity:10 /** * Whitelist input and get database name & default geometry type from * subdomain/user metadata held in CartoDB Redis diff --git a/lib/cartodb/template_maps.js b/lib/cartodb/template_maps.js index d7b7f66b..c10bf0f6 100644 --- a/lib/cartodb/template_maps.js +++ b/lib/cartodb/template_maps.js @@ -89,6 +89,7 @@ o._redisCmd = function(redisFunc, redisArgs, callback) { }; var _reValidIdentifier = /^[a-zA-Z][0-9a-zA-Z_]*$/; +// jshint maxcomplexity:15 o._checkInvalidTemplate = function(template) { if ( template.version != '0.0.1' ) { return new Error("Unsupported template version " + template.version); From 87782b400d2c6a086988b23db61a12145e91df43 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 16 Mar 2015 00:38:29 +0100 Subject: [PATCH 43/52] jshint to be tested by default --- Makefile | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c1c5a4ac..1d3c1cdd 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,8 @@ jshint: @echo "***jshint***" @./node_modules/.bin/jshint lib/ +test-all: jshint test + check: test .PHONY: pre-install test diff --git a/package.json b/package.json index af48512b..44a6e6f4 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ }, "scripts": { "preinstall": "make pre-install", - "test": "make test" + "test": "make test-all" }, "engines": { "node": ">=0.8 <0.11", From 7c35d5cd3274d612b1ea74a4a1d00ec8a7ba58f9 Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 16 Mar 2015 12:26:28 +0100 Subject: [PATCH 44/52] Switching to HTTPS https://github.com/CartoDB/docs/issues/182 --- docs/Map-API.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/Map-API.md b/docs/Map-API.md index 2fe76644..c3a9a762 100644 --- a/docs/Map-API.md +++ b/docs/Map-API.md @@ -34,10 +34,10 @@ $.ajax({ type: 'POST', dataType: 'json', contentType: 'application/json', - url: 'http://documentation.cartodb.com/api/v1/map', + url: 'https://documentation.cartodb.com/api/v1/map', data: JSON.stringify(mapconfig), success: function(data) { - var templateUrl = 'http://documentation.cartodb.com/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png' + var templateUrl = 'https://documentation.cartodb.com/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png' console.log(templateUrl); } }) @@ -79,7 +79,7 @@ To get the `URL` to fetch the tiles you need to instantiate the map, where `temp
```bash -curl -X POST 'http://{account}.cartodb.com/api/v1/map/named/:template_id' -H 'Content-Type: application/json' +curl -X POST 'https://{account}.cartodb.com/api/v1/map/named/:template_id' -H 'Content-Type: application/json' ``` The response will return JSON with properties for the `layergroupid` and the timestamp (`last_updated`) of the last data modification. @@ -96,7 +96,7 @@ Here is an example response: You can use the `layergroupid` to instantiate a URL template for accessing tiles on the client. Here we use the `layergroupid` from the example response above in this URL template: ```bash -http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/{z}/{x}/{y}.png +https://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/{z}/{x}/{y}.png ``` ## General Concepts @@ -107,7 +107,7 @@ The following concepts are the same for every endpoint in the API except when it By default, users do not have access to private tables in CartoDB. In order to instantiate a map from private table data an API Key is required. Additionally, to include some endpoints, an API Key must be included (e.g. creating a named map). -To execute an authorized request, api_key=YOURAPIKEY should be added to the request URL. The param can be also passed as POST param. We **strongly advise** using HTTPS when you are performing requests that include your `api_key`. +To execute an authorized request, `api_key=YOURAPIKEY` should be added to the request URL. The param can be also passed as POST param. Using HTTPS is mandatory when you are performing requests that include your `api_key`. ### Errors @@ -167,7 +167,7 @@ The response includes: The ID for that map, used to compose the URL for the tiles. The final URL is: ```html - http://{account}.cartodb.com/api/v1/map/:layergroupid/{z}/{x}/{y}.png + https://{account}.cartodb.com/api/v1/map/:layergroupid/{z}/{x}/{y}.png ``` - **updated_at** @@ -183,7 +183,7 @@ The response includes:
REQUEST
```bash -curl 'http://documentation.cartodb.com/api/v1/map' -H 'Content-Type: application/json' -d @mapconfig.json +curl 'https://documentation.cartodb.com/api/v1/map' -H 'Content-Type: application/json' -d @mapconfig.json ```
RESPONSE
@@ -201,19 +201,19 @@ curl 'http://documentation.cartodb.com/api/v1/map' -H 'Content-Type: application The tiles can be accessed using: ```bash -http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/{z}/{x}/{y}.png +https://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/{z}/{x}/{y}.png ``` For UTF grid tiles: ```bash -http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/:layer/{z}/{x}/{y}.grid.json +https://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/:layer/{z}/{x}/{y}.grid.json ``` For attributes defined in `attributes` section: ```bash -http://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/:layer/attributes/:feature_id +https://documentation.cartodb.com/api/v1/map/c01a54877c62831bb51720263f91fb33:0/:layer/attributes/:feature_id ``` Which returns JSON with the attributes defined, like: From c1c6d493b728484c82e963df335d224e1ff80657 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 15:54:05 +0100 Subject: [PATCH 45/52] allow urls like /u/:user/ --- config/environments/development.js.example | 4 ++-- config/environments/production.js.example | 4 ++-- config/environments/staging.js.example | 4 ++-- lib/cartodb/server_options.js | 3 +++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 1c036f67..4757f7d8 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 28f2ee95..2aaf6d60 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 88a0d8e7..77da9151 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/maps/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/maps/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "/api/v1/maps" is the the new API, // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/maps|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index ff052586..951f2d7f 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -377,6 +377,9 @@ module.exports = function(redisPool) { me.userByReq = function(req) { var host = req.headers.host; + if (req.params.user) { + return req.params.user; + } var mat = host.match(this.re_userFromHost); if ( ! mat ) { console.error("ERROR: user pattern '" + this.re_userFromHost + "' does not match hostname '" + host + "'"); From 5af09fc2bff7ce6bf29d3269c64c99a7fe64fb1d Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 17:04:25 +0100 Subject: [PATCH 46/52] small refactor in tests --- test/acceptance/multilayer.js | 68 ++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index 84b1e220..650272fc 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -22,6 +22,7 @@ serverOptions = ServerOptions(); var server = new CartodbWindshaft(serverOptions); server.setMaxListeners(0); +['/tiles/layergroup'].forEach(function(layergroup_url) { [true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) { suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() { @@ -66,7 +67,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -94,7 +95,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -135,7 +136,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/localhost@' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + '/localhost@' + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -152,7 +153,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/0/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -170,7 +171,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/1/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -222,7 +223,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res, err) { next(err, res); }); @@ -255,7 +256,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res, err) { next(err, res); }); @@ -299,7 +300,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res) { @@ -321,7 +322,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify(layergroup)), + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify(layergroup)), method: 'GET', headers: {host: 'localhost'} }, {}, function(res) { @@ -352,7 +353,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -379,7 +380,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb10/1/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb10/1/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -418,7 +419,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb11/4/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb11/4/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -457,7 +458,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/0/1/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -475,7 +476,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + "/" + expected_token + '/0/4/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -539,7 +540,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -561,7 +562,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( + statskey + ":stat_tag:" + layergroup.stat_tag + " to be 1, got " + val); var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -620,7 +621,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -648,7 +649,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( ] }; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -716,7 +717,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -737,7 +738,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/0/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -751,7 +752,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/1/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -766,7 +767,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -782,7 +783,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/0/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -798,7 +799,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + url: layergroup_url + expected_token + '/1/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -878,7 +879,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -908,7 +909,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1044,7 +1045,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1068,7 +1069,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1146,7 +1147,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: '/tiles/layergroup/' + expected_token + ':cb0/0/0/0.png?api_key=1234', + url: layergroup_url + expected_token + ':cb0/0/0/0.png?api_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1211,7 +1212,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( assert.ok(data.length > 1024*64); var next = this; assert.response(server, { - url: '/tiles/layergroup?api_key=1234', + url: layergroup_url + '?api_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: data @@ -1268,7 +1269,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1310,7 +1311,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup', + url: layergroup_url, method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1334,7 +1335,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( } var layergroupTtlRequest = { - url: '/tiles/layergroup?config=' + encodeURIComponent(JSON.stringify({ + url: layergroup_url + '?config=' + encodeURIComponent(JSON.stringify({ version: '1.0.0', layers: [ { options: { @@ -1442,3 +1443,4 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( }); }); +}); From 72294fbd25e86fe28626a36870e87780594c4a7b Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 17:26:33 +0100 Subject: [PATCH 47/52] refined tests --- test/acceptance/multilayer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index 650272fc..ac380ac1 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -689,7 +689,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?map_key=1234', + url: layergroup_url + '?map_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -850,7 +850,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?map_key=1234', + url: layergroup_url + '?map_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1069,7 +1069,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -1121,7 +1121,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( { var next = this; assert.response(server, { - url: '/tiles/layergroup?api_key=1234', + url: layergroup_url + '?api_key=1234', method: 'POST', headers: {host: 'localhost', 'Content-Type': 'application/json' }, data: JSON.stringify(layergroup) @@ -1147,7 +1147,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?api_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?api_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' From 00cf83dc454a598b1c0e1bec7a2e7dc46e2a95cd Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 17:53:49 +0100 Subject: [PATCH 48/52] try to fix test, take 3 --- test/acceptance/multilayer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index ac380ac1..6de5520b 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -717,7 +717,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -738,7 +738,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/0/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -752,7 +752,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/1/0/0/0.grid.json?map_key=1234', headers: {host: 'localhost' }, method: 'GET' @@ -767,7 +767,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -783,7 +783,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/0/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -799,7 +799,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + url: layergroup_url + "/" + expected_token + '/1/0/0/0.grid.json', headers: {host: 'localhost' }, method: 'GET' @@ -879,7 +879,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' @@ -909,7 +909,7 @@ suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function( if ( err ) throw err; var next = this; assert.response(server, { - url: layergroup_url + expected_token + ':cb0/0/0/0.png?map_key=1234', + url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png?map_key=1234', method: 'GET', headers: {host: 'localhost' }, encoding: 'binary' From b891ae19f450e47dae49ec717660c02fe61576d5 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 18:15:26 +0100 Subject: [PATCH 49/52] adding a bunch of test for layer group url --- test/acceptance/multilayer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index 6de5520b..ad92a583 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -22,10 +22,10 @@ serverOptions = ServerOptions(); var server = new CartodbWindshaft(serverOptions); server.setMaxListeners(0); -['/tiles/layergroup'].forEach(function(layergroup_url) { +['/tiles/layergroup', '/u/rambo/tiles/layergroup'].forEach(function(layergroup_url) { [true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) { -suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() { +suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue + "layergroup_url=" + layergroup_url, function() { var redis_client = redis.createClient(global.environment.redis.port); var sqlapi_server; From 2f44dfe1dadc5feb6ee76463699d77801bb3b4f2 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 18 Mar 2015 18:36:44 +0100 Subject: [PATCH 50/52] updated test config --- config/environments/test.js.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 066bf1d0..056e8394 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' From 9ba53dc4cf8670a6cb78db69a11d0d468e2ce187 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Fri, 20 Mar 2015 00:30:56 +0100 Subject: [PATCH 51/52] Adds user param to params whitelist and uses localhost user for tests --- lib/cartodb/server_options.js | 1 + test/acceptance/multilayer.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 951f2d7f..5863f211 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -18,6 +18,7 @@ if ( _.isUndefined(global.environment.sqlapi.domain) ) { // Whitelist query parameters and attach format var REQUEST_QUERY_PARAMS_WHITELIST = [ + 'user', 'sql', 'geom_type', 'cache_buster', diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index ad92a583..3af4d95a 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -22,10 +22,11 @@ serverOptions = ServerOptions(); var server = new CartodbWindshaft(serverOptions); server.setMaxListeners(0); -['/tiles/layergroup', '/u/rambo/tiles/layergroup'].forEach(function(layergroup_url) { +['/tiles/layergroup', '/u/localhost/tiles/layergroup'].forEach(function(layergroup_url) { [true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) { -suite('multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue + "layergroup_url=" + layergroup_url, function() { +var suiteName = 'multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue + ";layergroup_url=" + layergroup_url; +suite(suiteName, function() { var redis_client = redis.createClient(global.environment.redis.port); var sqlapi_server; From 9b4acf99d5d42c4777e986cafea34a9e27ff40aa Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Fri, 20 Mar 2015 00:34:30 +0100 Subject: [PATCH 52/52] Adds example configuration to accept user param in /tiles/layergroup That is used in testing. Tests should start moving to /api/v1/map. --- config/environments/development.js.example | 4 ++-- config/environments/production.js.example | 4 ++-- config/environments/staging.js.example | 4 ++-- config/environments/test.js.example | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 4757f7d8..d6bfba7f 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 2aaf6d60..e58aea66 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 77da9151..8f4b0941 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/maps/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "/api/v1/maps" is the the new API, // "/tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table' diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 056e8394..64c40ffd 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -14,11 +14,11 @@ var config = { // Base url for the Templated Maps API // "/api/v1/map/named" is the new API, // "/tiles/template" is for compatibility with versions up to 1.6.x - ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named)' + ,base_url_templated: '(?:/api/v1/map/named|/tiles/template|/u/:user/api/v1/map/named|/u/:user/tiles/template)' // Base url for the Detached Maps API // "maps" is the the new API, // "tiles/layergroup" is for compatibility with versions up to 1.6.x - ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map)' + ,base_url_detached: '(?:/api/v1/map|/tiles/layergroup|/u/:user/api/v1/map|/u/:user/tiles/layergroup)' // Base url for the Inline Maps and Table Maps API ,base_url_legacy: '/tiles/:table'