Browse Source

Merge branch 'master' into multiple_suggesters

msv2
Harish Krishna 10 years ago
parent
commit
e92433c6ab
  1. 22
      docs/404.md
  2. 4
      docs/cors.md
  3. 28
      docs/doc/msuccess.md
  4. 32
      docs/doc/success.md
  5. 16
      docs/index.md
  6. 4
      docs/jsonp.md
  7. 33
      docs/reverse/success.md
  8. 173
      docs/search/success.md
  9. 173
      docs/suggest/success.md
  10. 6
      sanitiser/_id.js

22
docs/404.md

@ -1,6 +1,6 @@
# invalid path # invalid path
*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* *Generated: Thu Oct 23 2014 11:58:14 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -27,7 +27,7 @@ Status: 404
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "35", "content-length": "35",
"etag": "W/\"23-dfdfa185\"", "etag": "W/\"23-dfdfa185\"",
"date": "Thu, 25 Sep 2014 18:25:20 GMT", "date": "Thu, 23 Oct 2014 15:58:14 GMT",
"connection": "close" "connection": "close"
} }
``` ```
@ -39,14 +39,19 @@ Status: 404
## Tests ## Tests
### ✓ not found ### ✓ cache-control header correctly set
```javascript ```javascript
response.statusCode.should.equal 404 response.should.have.header 'Cache-Control','public,max-age=300'
``` ```
### ✓ cache-control header correctly set ### ✓ content-type header correctly set
```javascript ```javascript
response.should.have.header 'Cache-Control','public,max-age=300' response.should.have.header 'Content-Type','application/json; charset=utf-8'
```
### ✓ not found
```javascript
response.statusCode.should.equal 404
``` ```
### ✓ should respond in json with server info ### ✓ should respond in json with server info
@ -56,8 +61,3 @@ should.exist json.error
json.error.should.equal 'not found: invalid path' 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'
```

4
docs/cors.md

@ -1,6 +1,6 @@
# cross-origin resource sharing # cross-origin resource sharing
*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* *Generated: Thu Oct 23 2014 11:58:14 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -27,7 +27,7 @@ Status: 200
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "50", "content-length": "50",
"etag": "W/\"32-85536434\"", "etag": "W/\"32-85536434\"",
"date": "Thu, 25 Sep 2014 18:25:20 GMT", "date": "Thu, 23 Oct 2014 15:58:14 GMT",
"connection": "close" "connection": "close"
} }
``` ```

28
docs/get/mget.md → docs/doc/msuccess.md

@ -1,6 +1,6 @@
# valid get query # valid doc query
*Generated: Thu Oct 16 2014 17:02:52 GMT-0400 (EDT)* *Generated: Thu Oct 23 2014 11:58:14 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -8,7 +8,7 @@
"host": "localhost", "host": "localhost",
"method": "GET", "method": "GET",
"port": 3100, "port": 3100,
"path": "/get?id=geoname:4221195&id=geoname:4193595" "path": "/doc?id=geoname:4221195&id=geoname:4193595"
} }
``` ```
@ -25,9 +25,9 @@ Status: 200
"access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true", "access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "567", "content-length": "555",
"etag": "W/\"237-e0425e36\"", "etag": "W/\"22b-6aa14642\"",
"date": "Thu, 16 Oct 2014 21:02:52 GMT", "date": "Thu, 23 Oct 2014 15:58:14 GMT",
"connection": "close" "connection": "close"
} }
``` ```
@ -49,7 +49,7 @@ Status: 200
"admin0": "United States", "admin0": "United States",
"admin1": "Georgia", "admin1": "Georgia",
"admin2": "Hart County", "admin2": "Hart County",
"text": "Sanders Grove Cemetery, Hart County, United States" "text": "Sanders Grove Cemetery, Hart County, Georgia"
} }
}, },
{ {
@ -66,16 +66,21 @@ Status: 200
"admin0": "United States", "admin0": "United States",
"admin1": "Georgia", "admin1": "Georgia",
"admin2": "Butts County", "admin2": "Butts County",
"text": "Etheredge Cemetery, Butts County, United States" "text": "Etheredge Cemetery, Butts County, Georgia"
} }
} }
], ],
"date": 1413493372681 "date": 1414079894512
} }
``` ```
## Tests ## Tests
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```
### ✓ valid response ### ✓ valid response
```javascript ```javascript
now = new Date().getTime() now = new Date().getTime()
@ -90,8 +95,3 @@ json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array json.features.should.be.instanceof Array
``` ```
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```

32
docs/get/success.md → docs/doc/success.md

@ -1,6 +1,6 @@
# valid get query # valid doc query
*Generated: Thu Oct 16 2014 17:02:52 GMT-0400 (EDT)* *Generated: Thu Oct 23 2014 11:58:14 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -8,7 +8,7 @@
"host": "localhost", "host": "localhost",
"method": "GET", "method": "GET",
"port": 3100, "port": 3100,
"path": "/get?id=geoname:4221195" "path": "/doc?id=geoname:4221195"
} }
``` ```
@ -25,9 +25,9 @@ Status: 200
"access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true", "access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "317", "content-length": "311",
"etag": "W/\"13d-bc388729\"", "etag": "W/\"137-ab9138f7\"",
"date": "Thu, 16 Oct 2014 21:02:52 GMT", "date": "Thu, 23 Oct 2014 15:58:14 GMT",
"connection": "close" "connection": "close"
} }
``` ```
@ -49,20 +49,22 @@ Status: 200
"admin0": "United States", "admin0": "United States",
"admin1": "Georgia", "admin1": "Georgia",
"admin2": "Hart County", "admin2": "Hart County",
"text": "Sanders Grove Cemetery, Hart County, United States" "text": "Sanders Grove Cemetery, Hart County, Georgia"
} }
} }
], ],
"date": 1413493372842 "date": 1414079894512
} }
``` ```
## Tests ## Tests
### ✓ valid geojson ### ✓ valid response
```javascript ```javascript
json.type.should.equal 'FeatureCollection' now = new Date().getTime()
json.features.should.be.instanceof Array should.exist json
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
``` ```
### ✓ 200 ok ### ✓ 200 ok
@ -70,11 +72,9 @@ json.features.should.be.instanceof Array
response.statusCode.should.equal 200 response.statusCode.should.equal 200
``` ```
### ✓ valid response ### ✓ valid geojson
```javascript ```javascript
now = new Date().getTime() json.type.should.equal 'FeatureCollection'
should.exist json json.features.should.be.instanceof Array
should.not.exist json.error
json.date.should.be.within now-5000, now+5000
``` ```

16
docs/index.md

@ -1,6 +1,6 @@
# api root # api root
*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* *Generated: Thu Oct 23 2014 11:58:14 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -27,7 +27,7 @@ Status: 200
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "50", "content-length": "50",
"etag": "W/\"32-85536434\"", "etag": "W/\"32-85536434\"",
"date": "Thu, 25 Sep 2014 18:25:20 GMT", "date": "Thu, 23 Oct 2014 15:58:14 GMT",
"connection": "close" "connection": "close"
} }
``` ```
@ -42,9 +42,9 @@ Status: 200
## Tests ## Tests
### ✓ vanity header correctly set ### ✓ endpoint available
```javascript ```javascript
response.should.have.header 'X-Powered-By','mapzen' response.statusCode.should.equal 200
``` ```
### ✓ server header correctly set ### ✓ server header correctly set
@ -53,9 +53,9 @@ response.should.have.header 'Server'
response.headers.server.should.match /Pelias\/\d{1,2}\.\d{1,2}\.\d{1,2}/ response.headers.server.should.match /Pelias\/\d{1,2}\.\d{1,2}\.\d{1,2}/
``` ```
### ✓ content-type header correctly set ### ✓ vanity header correctly set
```javascript ```javascript
response.should.have.header 'Content-Type','application/json; charset=utf-8' response.should.have.header 'X-Powered-By','mapzen'
``` ```
### ✓ cache-control header correctly set ### ✓ cache-control header correctly set
@ -70,9 +70,9 @@ should.exist json.name
should.exist json.version should.exist json.version
``` ```
### ✓ endpoint available ### ✓ content-type header correctly set
```javascript ```javascript
response.statusCode.should.equal 200 response.should.have.header 'Content-Type','application/json; charset=utf-8'
``` ```
### ✓ charset header correctly set ### ✓ charset header correctly set

4
docs/jsonp.md

@ -1,6 +1,6 @@
# jsonp # jsonp
*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* *Generated: Thu Oct 23 2014 11:58:14 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -27,7 +27,7 @@ Status: 200
"content-type": "application/javascript; charset=utf-8", "content-type": "application/javascript; charset=utf-8",
"content-length": "57", "content-length": "57",
"etag": "W/\"39-b8a2aba1\"", "etag": "W/\"39-b8a2aba1\"",
"date": "Thu, 25 Sep 2014 18:25:20 GMT", "date": "Thu, 23 Oct 2014 15:58:14 GMT",
"connection": "close" "connection": "close"
} }
``` ```

33
docs/reverse/success.md

@ -1,6 +1,6 @@
# valid reverse query # valid reverse query
*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* *Generated: Thu Oct 23 2014 11:58:15 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -25,9 +25,9 @@ Status: 200
"access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true", "access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "263", "content-length": "282",
"etag": "W/\"107-75b55c25\"", "etag": "W/\"11a-95fc1500\"",
"date": "Thu, 25 Sep 2014 18:25:20 GMT", "date": "Thu, 23 Oct 2014 15:58:15 GMT",
"connection": "close" "connection": "close"
} }
``` ```
@ -40,19 +40,20 @@ Status: 200
"geometry": { "geometry": {
"type": "Point", "type": "Point",
"coordinates": [ "coordinates": [
-82.506198, -82.50622,
29.542519 29.49136
] ]
}, },
"properties": { "properties": {
"name": "Archer", "name": "Adam",
"admin0": "United States", "admin0": "United States",
"admin1": "*florida", "admin1": "Florida",
"text": "Archer, *florida, United States" "admin2": "Alachua County",
"text": "Adam, Alachua County, Florida"
} }
} }
], ],
"date": 1411669520735 "date": 1414079895606
} }
``` ```
@ -63,6 +64,12 @@ Status: 200
response.statusCode.should.equal 200 response.statusCode.should.equal 200
``` ```
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```
### ✓ valid response ### ✓ valid response
```javascript ```javascript
now = new Date().getTime() now = new Date().getTime()
@ -71,9 +78,3 @@ should.not.exist json.error
json.date.should.be.within now-5000, now+5000 json.date.should.be.within now-5000, now+5000
``` ```
### ✓ valid geojson
```javascript
json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array
```

173
docs/search/success.md

@ -1,6 +1,6 @@
# valid search query # valid search query
*Generated: Thu Sep 25 2014 19:25:21 GMT+0100 (BST)* *Generated: Thu Oct 23 2014 11:58:15 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -25,9 +25,9 @@ Status: 200
"access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true", "access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "289", "content-length": "2398",
"etag": "W/\"121-69343a38\"", "etag": "W/\"0tqT2h50EMVuqDtvmB5nAQ==\"",
"date": "Thu, 25 Sep 2014 18:25:20 GMT", "date": "Thu, 23 Oct 2014 15:58:15 GMT",
"connection": "close" "connection": "close"
} }
``` ```
@ -40,20 +40,173 @@ Status: 200
"geometry": { "geometry": {
"type": "Point", "type": "Point",
"coordinates": [ "coordinates": [
-82.357442, -82.5052,
29.72089 29.50312
] ]
}, },
"properties": { "properties": {
"name": "Hidden Lake", "name": "Blue Pete Lake",
"admin0": "United States", "admin0": "United States",
"admin1": "Florida", "admin1": "Florida",
"admin2": "Alachua", "admin2": "Alachua County",
"text": "Hidden Lake, Alachua, United States" "text": "Blue Pete Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.52097,
29.47185
]
},
"properties": {
"name": "Sawgrass Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Sawgrass Lake, Levy County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.39141,
29.4468
]
},
"properties": {
"name": "Johnson Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Marion County",
"text": "Johnson Lake, Marion County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.35435,
29.49526
]
},
"properties": {
"name": "Ledwith Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Ledwith Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.35316,
29.52469
]
},
"properties": {
"name": "Levy Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Levy Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.66311,
29.54036
]
},
"properties": {
"name": "Fox Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Fox Lake, Levy County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.40502,
29.61705
]
},
"properties": {
"name": "Lake Kanapaha",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Lake Kanapaha, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.70856,
29.53293
]
},
"properties": {
"name": "Doorshutter Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Doorshutter Lake, Levy County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.30215,
29.52978
]
},
"properties": {
"name": "Wauberg Lake",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Alachua County",
"text": "Wauberg Lake, Alachua County, Florida"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-82.47914,
29.30795
]
},
"properties": {
"name": "Lake Stafford",
"admin0": "United States",
"admin1": "Florida",
"admin2": "Levy County",
"text": "Lake Stafford, Levy County, Florida"
} }
} }
], ],
"date": 1411669520989 "date": 1414079895605
} }
``` ```

173
docs/suggest/success.md

@ -1,6 +1,6 @@
# valid suggest query # valid suggest query
*Generated: Thu Sep 25 2014 19:25:20 GMT+0100 (BST)* *Generated: Thu Oct 23 2014 11:58:14 GMT-0400 (EDT)*
## Request ## Request
```javascript ```javascript
{ {
@ -25,178 +25,17 @@ Status: 200
"access-control-allow-headers": "X-Requested-With,content-type", "access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true", "access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-length": "1933", "content-length": "63",
"etag": "W/\"I89q+0HZNmXyHsTfLSP5Ww==\"", "etag": "W/\"3f-200731a6\"",
"date": "Thu, 25 Sep 2014 18:25:20 GMT", "date": "Thu, 23 Oct 2014 15:58:14 GMT",
"connection": "close" "connection": "close"
} }
``` ```
```javascript ```javascript
{ {
"type": "FeatureCollection", "type": "FeatureCollection",
"features": [ "features": [],
{ "date": 1414079894479
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
7.56019,
5.419786
]
},
"properties": {
"text": "Abia, Nigeria",
"score": 1,
"type": "admin1",
"id": "1775:adm1:ng:nga:abia"
}
},
{
"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"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-60.005461,
-3.099378
]
},
"properties": {
"text": "Adrianópolis, Manaus, Brasil",
"score": 1,
"type": "neighborhood",
"id": "799:_:_:_:adrian_polis"
}
},
{
"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"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
9.691808,
4.050576
]
},
"properties": {
"text": "Akwa, Littoral, Cameroun",
"score": 1,
"type": "neighborhood",
"id": "1863:_:_:_:akwa"
}
},
{
"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"
}
},
{
"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"
}
},
{
"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"
}
},
{
"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"
}
},
{
"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
} }
``` ```

6
sanitiser/_id.js

@ -42,9 +42,9 @@ function sanitize( req ){
return errormessage(null, 'invalid: must be of the format type:id for ex: \'geoname:4163334\''); return errormessage(null, 'invalid: must be of the format type:id for ex: \'geoname:4163334\'');
} }
var param = thisparam.split(delim); var param_index = thisparam.indexOf(delim);
var type= param[0]; var type = thisparam.substring(0, param_index );
var id = param[1]; var id = thisparam.substring(param_index + 1);
// id text // id text
if('string' !== typeof id || !id.length){ if('string' !== typeof id || !id.length){

Loading…
Cancel
Save