From ebf6e6eecdb269989b7b0e578a0c844ef1ecc259 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 25 Sep 2014 19:25:32 +0100 Subject: [PATCH] docs --- docs/404.md | 22 ++-- docs/cors.md | 4 +- docs/index.md | 26 ++-- docs/jsonp.md | 4 +- docs/reverse/success.md | 41 ++++-- docs/search/success.md | 277 +++++----------------------------------- docs/suggest/success.md | 216 +++++++++++++++++++++---------- 7 files changed, 238 insertions(+), 352 deletions(-) diff --git a/docs/404.md b/docs/404.md index 0a07b211..79c6241a 100644 --- a/docs/404.md +++ b/docs/404.md @@ -1,6 +1,6 @@ # invalid path -*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)* +*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* ## Request ```javascript { @@ -27,7 +27,7 @@ Status: 404 "content-type": "application/json; charset=utf-8", "content-length": "35", "etag": "W/\"23-dfdfa185\"", - "date": "Fri, 19 Sep 2014 13:38:01 GMT", + "date": "Thu, 25 Sep 2014 18:25:20 GMT", "connection": "close" } ``` @@ -39,19 +39,14 @@ Status: 404 ## Tests -### ✓ cache-control header correctly set -```javascript -response.should.have.header 'Cache-Control','public,max-age=300' -``` - -### ✓ content-type header correctly set +### ✓ not found ```javascript -response.should.have.header 'Content-Type','application/json; charset=utf-8' +response.statusCode.should.equal 404 ``` -### ✓ not found +### ✓ cache-control header correctly set ```javascript -response.statusCode.should.equal 404 +response.should.have.header 'Cache-Control','public,max-age=300' ``` ### ✓ should respond in json with server info @@ -61,3 +56,8 @@ should.exist json.error json.error.should.equal 'not found: invalid path' ``` +### ✓ content-type header correctly set +```javascript +response.should.have.header 'Content-Type','application/json; charset=utf-8' +``` + diff --git a/docs/cors.md b/docs/cors.md index fb1f209f..a186bc55 100644 --- a/docs/cors.md +++ b/docs/cors.md @@ -1,6 +1,6 @@ # cross-origin resource sharing -*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)* +*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* ## Request ```javascript { @@ -27,7 +27,7 @@ Status: 200 "content-type": "application/json; charset=utf-8", "content-length": "50", "etag": "W/\"32-85536434\"", - "date": "Fri, 19 Sep 2014 13:38:01 GMT", + "date": "Thu, 25 Sep 2014 18:25:20 GMT", "connection": "close" } ``` diff --git a/docs/index.md b/docs/index.md index da891651..485f343b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ # api root -*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)* +*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* ## Request ```javascript { @@ -27,7 +27,7 @@ Status: 200 "content-type": "application/json; charset=utf-8", "content-length": "50", "etag": "W/\"32-85536434\"", - "date": "Fri, 19 Sep 2014 13:38:01 GMT", + "date": "Thu, 25 Sep 2014 18:25:20 GMT", "connection": "close" } ``` @@ -42,14 +42,15 @@ Status: 200 ## Tests -### ✓ endpoint available +### ✓ vanity header correctly set ```javascript -response.statusCode.should.equal 200 +response.should.have.header 'X-Powered-By','mapzen' ``` -### ✓ cache-control header correctly set +### ✓ server header correctly set ```javascript -response.should.have.header 'Cache-Control','public,max-age=60' +response.should.have.header 'Server' +response.headers.server.should.match /Pelias\/\d{1,2}\.\d{1,2}\.\d{1,2}/ ``` ### ✓ content-type header correctly set @@ -57,9 +58,9 @@ response.should.have.header 'Cache-Control','public,max-age=60' response.should.have.header 'Content-Type','application/json; charset=utf-8' ``` -### ✓ charset header correctly set +### ✓ cache-control header correctly set ```javascript -response.should.have.header 'Charset','utf8' +response.should.have.header 'Cache-Control','public,max-age=60' ``` ### ✓ should respond in json with server info @@ -69,14 +70,13 @@ should.exist json.name should.exist json.version ``` -### ✓ vanity header correctly set +### ✓ endpoint available ```javascript -response.should.have.header 'X-Powered-By','mapzen' +response.statusCode.should.equal 200 ``` -### ✓ server header correctly set +### ✓ charset header correctly set ```javascript -response.should.have.header 'Server' -response.headers.server.should.match /Pelias\/\d{1,2}\.\d{1,2}\.\d{1,2}/ +response.should.have.header 'Charset','utf8' ``` diff --git a/docs/jsonp.md b/docs/jsonp.md index dc969008..8526fd96 100644 --- a/docs/jsonp.md +++ b/docs/jsonp.md @@ -1,6 +1,6 @@ # jsonp -*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)* +*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* ## Request ```javascript { @@ -27,7 +27,7 @@ Status: 200 "content-type": "application/javascript; charset=utf-8", "content-length": "57", "etag": "W/\"39-b8a2aba1\"", - "date": "Fri, 19 Sep 2014 13:38:01 GMT", + "date": "Thu, 25 Sep 2014 18:25:20 GMT", "connection": "close" } ``` diff --git a/docs/reverse/success.md b/docs/reverse/success.md index 77730291..52fa3afb 100644 --- a/docs/reverse/success.md +++ b/docs/reverse/success.md @@ -1,6 +1,6 @@ # valid reverse query -*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)* +*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* ## Request ```javascript { @@ -25,16 +25,34 @@ Status: 200 "access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-credentials": "true", "content-type": "application/json; charset=utf-8", - "content-length": "32", - "etag": "W/\"20-a1afccd5\"", - "date": "Fri, 19 Sep 2014 13:38:01 GMT", + "content-length": "263", + "etag": "W/\"107-75b55c25\"", + "date": "Thu, 25 Sep 2014 18:25:20 GMT", "connection": "close" } ``` ```javascript { - "date": 1411133881593, - "body": [] + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -82.506198, + 29.542519 + ] + }, + "properties": { + "name": "Archer", + "admin0": "United States", + "admin1": "*florida", + "text": "Archer, *florida, United States" + } + } + ], + "date": 1411669520735 } ``` @@ -50,9 +68,12 @@ response.statusCode.should.equal 200 now = new Date().getTime() should.exist json should.not.exist json.error -should.exist json.date -json.date.should.be.within now-2000, now+2000 -should.exist json.body -json.body.should.be.instanceof Array +json.date.should.be.within now-5000, now+5000 +``` + +### ✓ valid geojson +```javascript +json.type.should.equal 'FeatureCollection' +json.features.should.be.instanceof Array ``` diff --git a/docs/search/success.md b/docs/search/success.md index cc32df38..5e6159e1 100644 --- a/docs/search/success.md +++ b/docs/search/success.md @@ -1,6 +1,6 @@ # valid search query -*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)* +*Generated: Thu Sep 25 2014 19:25:21 GMT+0100 (BST)* ## Request ```javascript { @@ -25,257 +25,35 @@ Status: 200 "access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-credentials": "true", "content-type": "application/json; charset=utf-8", - "content-length": "3549", - "etag": "W/\"Koi2nJQQ+otDRPmBy8JU7g==\"", - "date": "Fri, 19 Sep 2014 13:38:01 GMT", + "content-length": "289", + "etag": "W/\"121-69343a38\"", + "date": "Thu, 25 Sep 2014 18:25:20 GMT", "connection": "close" } ``` ```javascript { - "date": 1411133881591, - "body": [ + "type": "FeatureCollection", + "features": [ { - "admin2": "Alachua", - "admin1": "Florida", - "admin0": "United States", - "name": { - "default": "Hidden Lake" - }, - "gn_id": 0, - "suggest": { - "input": [ - "hidden lake" - ], - "payload": { - "id": "neighborhood/29372:_:_:_:hidden_lake", - "geo": "-82.357442,29.720890" - }, - "output": "Hidden Lake, Alachua, United States" - }, - "woe_id": 0, - "center_point": { - "lon": "-82.357442", - "lat": "29.720890" - } - }, - { - "admin0": "United States", - "name": { - "default": "Lake Butler", - "alt": "Lake Butler city" - }, - "gn_id": "4161171", - "suggest": { - "input": [ - "lake butler", - "lake butler city" - ], - "payload": { - "id": "locality/4387:locality:u:us:lake_butler", - "geo": "-82.339724,30.015529" - }, - "output": "Lake Butler, United States" - }, - "woe_id": null, - "center_point": { - "lon": "-82.339724", - "lat": "30.015529" - } - }, - { - "admin0": "United States", - "name": { - "default": "Lake City", - "alt": "Lake City city" - }, - "gn_id": "4161187", - "suggest": { - "input": [ - "lake city", - "lake city city" - ], - "payload": { - "id": "locality/4346:locality:u:us:lake_city", - "geo": "-82.659959,30.201687" - }, - "output": "Lake City, United States" - }, - "woe_id": null, - "center_point": { - "lon": "-82.659959", - "lat": "30.201687" - } - }, - { - "admin2": "Lake", - "admin1": "Florida", - "admin0": "United States", - "name": { - "default": "Villages Of Lady Lake" - }, - "gn_id": 0, - "suggest": { - "input": [ - "villages of lady lake" - ], - "payload": { - "id": "neighborhood/34180:_:_:_:villages_of_lady_lake", - "geo": "-81.952515,28.916553" - }, - "output": "Villages Of Lady Lake, Lake, United States" - }, - "woe_id": 0, - "center_point": { - "lon": "-81.952515", - "lat": "28.916553" - } - }, - { - "admin0": "United States", - "name": { - "default": "Lady Lake", - "alt": "Lady Lake town" - }, - "gn_id": "4161118", - "suggest": { - "input": [ - "lady lake", - "lady lake town" - ], - "payload": { - "id": "locality/4478:locality:u:us:lady_lake", - "geo": "-81.922691,28.921806" - }, - "output": "Lady Lake, United States" - }, - "woe_id": null, - "center_point": { - "lon": "-81.922691", - "lat": "28.921806" - } - }, - { - "admin0": "United States", - "name": { - "default": "Lake Panasoffkee", - "alt": "Lake Panasoffkee CDP" - }, - "gn_id": "4161327", - "suggest": { - "input": [ - "lake panasoffkee", - "lake panasoffkee cdp" - ], - "payload": { - "id": "locality/4888:locality:u:us:lake_panasoffkee", - "geo": "-82.125431,28.785189" - }, - "output": "Lake Panasoffkee, United States" - }, - "woe_id": null, - "center_point": { - "lon": "-82.125431", - "lat": "28.785189" - } - }, - { - "admin0": "United States", - "name": { - "default": "Asbury Lake", - "alt": "Asbury Lake CDP" - }, - "gn_id": "4146302", - "suggest": { - "input": [ - "asbury lake", - "asbury lake cdp" - ], - "payload": { - "id": "locality/4797:locality:u:us:asbury_lake", - "geo": "-81.780018,30.050684" - }, - "output": "Asbury Lake, United States" - }, - "woe_id": null, - "center_point": { - "lon": "-81.780018", - "lat": "30.050684" - } - }, - { - "admin0": "United States", - "name": { - "default": "Silver Lake", - "alt": "Silver Lake CDP" - }, - "gn_id": "4172971", - "suggest": { - "input": [ - "silver lake", - "silver lake cdp" - ], - "payload": { - "id": "locality/4992:locality:u:us:silver_lake", - "geo": "-81.804157,28.846269" - }, - "output": "Silver Lake, United States" - }, - "woe_id": null, - "center_point": { - "lon": "-81.804157", - "lat": "28.846269" - } - }, - { - "admin2": "Lake", - "admin1": "Florida", - "admin0": "United States", - "name": { - "default": "Oaks At Lake Dorr" - }, - "gn_id": 0, - "suggest": { - "input": [ - "oaks at lake dorr" - ], - "payload": { - "id": "neighborhood/33992:_:_:_:oaks_at_lake_dorr", - "geo": "-81.639404,28.993127" - }, - "output": "Oaks At Lake Dorr, Lake, United States" - }, - "woe_id": 0, - "center_point": { - "lon": "-81.639404", - "lat": "28.993127" - } - }, - { - "admin2": "Lake", - "admin1": "Florida", - "admin0": "United States", - "name": { - "default": "Lake South" - }, - "gn_id": 0, - "suggest": { - "input": [ - "lake south" - ], - "payload": { - "id": "neighborhood/34534:_:_:_:lake_south", - "geo": "-81.742766,28.797112" - }, - "output": "Lake South, Lake, United States" - }, - "woe_id": 0, - "center_point": { - "lon": "-81.742766", - "lat": "28.797112" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -82.357442, + 29.72089 + ] + }, + "properties": { + "name": "Hidden Lake", + "admin0": "United States", + "admin1": "Florida", + "admin2": "Alachua", + "text": "Hidden Lake, Alachua, United States" } } - ] + ], + "date": 1411669520989 } ``` @@ -286,10 +64,13 @@ Status: 200 now = new Date().getTime() should.exist json should.not.exist json.error -should.exist json.date -json.date.should.be.within now-2000, now+2000 -should.exist json.body -json.body.should.be.instanceof Array +json.date.should.be.within now-5000, now+5000 +``` + +### ✓ valid geojson +```javascript +json.type.should.equal 'FeatureCollection' +json.features.should.be.instanceof Array ``` ### ✓ 200 ok diff --git a/docs/suggest/success.md b/docs/suggest/success.md index ef5720c1..6798f863 100644 --- a/docs/suggest/success.md +++ b/docs/suggest/success.md @@ -1,6 +1,6 @@ # valid suggest query -*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)* +*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* ## Request ```javascript { @@ -25,115 +25,199 @@ Status: 200 "access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-credentials": "true", "content-type": "application/json; charset=utf-8", - "content-length": "1248", - "etag": "W/\"l7SMjqn0lVxkVsxRTJizhA==\"", - "date": "Fri, 19 Sep 2014 13:38:01 GMT", + "content-length": "1933", + "etag": "W/\"I89q+0HZNmXyHsTfLSP5Ww==\"", + "date": "Thu, 25 Sep 2014 18:25:20 GMT", "connection": "close" } ``` ```javascript { - "date": 1411133881441, - "body": [ + "type": "FeatureCollection", + "features": [ { - "text": "ACRELÂNDIA, Brazil", - "score": 1, - "payload": { - "id": "admin2/708:adm2:br:bra:acrel__ndia", - "geo": "-66.908143,-9.954353" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 7.56019, + 5.419786 + ] + }, + "properties": { + "text": "Abia, Nigeria", + "score": 1, + "type": "admin1", + "id": "1775:adm1:ng:nga:abia" } }, { - "text": "ALTA FLORESTA, Brazil", - "score": 1, - "payload": { - "id": "admin2/2986:adm2:br:bra:alta_floresta", - "geo": "-56.404593,-10.042071" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -66.908143, + -9.954353 + ] + }, + "properties": { + "text": "Acrelândia, Brazil", + "score": 1, + "type": "admin2", + "id": "708:adm2:br:bra:acrel_ndia" } }, { - "text": "ALTO ALEGRE, Brazil", - "score": 1, - "payload": { - "id": "admin2/4611:adm2:br:bra:alto_alegre", - "geo": "-62.627879,3.103540" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -60.005461, + -3.099378 + ] + }, + "properties": { + "text": "Adrianópolis, Manaus, Brasil", + "score": 1, + "type": "neighborhood", + "id": "799:_:_:_:adrian_polis" } }, { - "text": "ALTO PARAÍSO, Brazil", - "score": 1, - "payload": { - "id": "admin2/4584:adm2:br:bra:alto_para__so", - "geo": "-63.418743,-9.697774" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 7.909644, + 5.013733 + ] + }, + "properties": { + "text": "Akwa Ibom, Nigeria", + "score": 1, + "type": "admin1", + "id": "1776:adm1:ng:nga:akwa_ibom" } }, { - "text": "ALVARÃES, Brazil", - "score": 1, - "payload": { - "id": "admin2/832:adm2:br:bra:alvar__es", - "geo": "-65.296384,-3.674615" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 9.691808, + 4.050576 + ] + }, + "properties": { + "text": "Akwa, Littoral, Cameroun", + "score": 1, + "type": "neighborhood", + "id": "1863:_:_:_:akwa" } }, { - "text": "AMAJARI, Brazil", - "score": 1, - "payload": { - "id": "admin2/4610:adm2:br:bra:amajari", - "geo": "-62.710104,3.724864" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -56.404593, + -10.042071 + ] + }, + "properties": { + "text": "Alta Floresta, Brazil", + "score": 1, + "type": "admin2", + "id": "2986:adm2:br:bra:alta_floresta" } }, { - "text": "AMAZONAS, Brazil", - "score": 1, - "payload": { - "id": "admin1/3232:adm1:br:bra:amazonas", - "geo": "-64.949558,-3.785708" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -62.627879, + 3.10354 + ] + }, + "properties": { + "text": "Alto Alegre, Brazil", + "score": 1, + "type": "admin2", + "id": "4611:adm2:br:bra:alto_alegre" } }, { - "text": "ANAMÃ, Brazil", - "score": 1, - "payload": { - "id": "admin2/834:adm2:br:bra:anam__", - "geo": "-61.683670,-3.473836" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -63.418743, + -9.697774 + ] + }, + "properties": { + "text": "Alto Paraíso, Brazil", + "score": 1, + "type": "admin2", + "id": "4584:adm2:br:bra:alto_para_so" } }, { - "text": "ANORI, Brazil", - "score": 1, - "payload": { - "id": "admin2/835:adm2:br:bra:anori", - "geo": "-62.182138,-4.154809" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -65.296384, + -3.674615 + ] + }, + "properties": { + "text": "Alvarães, Brazil", + "score": 1, + "type": "admin2", + "id": "832:adm2:br:bra:alvar_es" } }, { - "text": "APIACÁS, Brazil", - "score": 1, - "payload": { - "id": "admin2/2992:adm2:br:bra:apiac__s", - "geo": "-57.803447,-8.583036" + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -62.710104, + 3.724864 + ] + }, + "properties": { + "text": "Amajari, Brazil", + "score": 1, + "type": "admin2", + "id": "4610:adm2:br:bra:amajari" } } - ] + ], + "date": 1411669520909 } ``` ## Tests +### ✓ 200 ok +```javascript +response.statusCode.should.equal 200 +``` + +### ✓ valid geojson +```javascript +json.type.should.equal 'FeatureCollection' +json.features.should.be.instanceof Array +``` + ### ✓ valid response ```javascript now = new Date().getTime() should.exist json should.not.exist json.error -should.exist json.date -json.date.should.be.within now-2000, now+2000 -should.exist json.body -json.body.should.be.instanceof Array -``` - -### ✓ 200 ok -```javascript -response.statusCode.should.equal 200 +json.date.should.be.within now-5000, now+5000 ```