Browse Source

Revert "Merge branch 'rename-doc-to-place'"

This reverts commit 472c8a4a05, reversing
changes made to 776b0ce1e1.
__BETA__
Julian Simioni 9 years ago
parent
commit
d5421089c6
  1. 9
      DOCS.md
  2. 8
      app.js
  3. 6
      controller/doc.js
  4. 1
      sanitiser/doc.js
  5. 4
      test/ciao/doc/msuccess.coffee
  6. 4
      test/ciao/doc/success.coffee
  7. 5
      test/unit/controller/doc.js
  8. 4
      test/unit/run.js
  9. 8
      test/unit/sanitiser/doc.js

9
DOCS.md

@ -100,15 +100,14 @@ The reverse geocoding endpoint; matches a point on the planet to the name of tha
* `details` (default: `true`) * `details` (default: `true`)
## /place ## /doc
The endpoint for retrieving one or more places with specific ids. These correspond The endpoint for retrieving one or more elasticsearch documents with specific ids.
directly with Elasticsearch documents.
#### Required Parameters #### Required Parameters
* one of `id` or `ids` * one of `id` or `ids`
* `id`: * `id`:
* unique id of the places to be retrieved * unique id of the document to be retrieved
* should be in the form of type:id, for example: `geoname:4163334` * should be in the form of type:id, for example: `geoname:4163334`
* `ids`: * `ids`:
* if multiple places are to be fetched in bulk, an array of ids * if multiple docs are to be fetched in bulk, an array of ids

8
app.js

@ -15,7 +15,7 @@ app.use( require('./middleware/jsonp') );
/** ----------------------- sanitisers ----------------------- **/ /** ----------------------- sanitisers ----------------------- **/
var sanitisers = {}; var sanitisers = {};
sanitisers.place = require('./sanitiser/place'); sanitisers.doc = require('./sanitiser/doc');
sanitisers.suggest = require('./sanitiser/suggest'); sanitisers.suggest = require('./sanitiser/suggest');
sanitisers.search = require('./sanitiser/search'); sanitisers.search = require('./sanitiser/search');
sanitisers.coarse = require('./sanitiser/coarse'); sanitisers.coarse = require('./sanitiser/coarse');
@ -25,7 +25,7 @@ sanitisers.reverse = require('./sanitiser/reverse');
var controllers = {}; var controllers = {};
controllers.index = require('./controller/index'); controllers.index = require('./controller/index');
controllers.place = require('./controller/place'); controllers.doc = require('./controller/doc');
controllers.search = require('./controller/search'); controllers.search = require('./controller/search');
/** ----------------------- routes ----------------------- **/ /** ----------------------- routes ----------------------- **/
@ -33,8 +33,8 @@ controllers.search = require('./controller/search');
// api root // api root
app.get( '/', controllers.index() ); app.get( '/', controllers.index() );
// place API // doc API
app.get( '/place', sanitisers.place.middleware, controllers.place() ); app.get( '/doc', sanitisers.doc.middleware, controllers.doc() );
// suggest APIs // suggest APIs
app.get( '/suggest', sanitisers.search.middleware, controllers.search() ); app.get( '/suggest', sanitisers.search.middleware, controllers.search() );

6
controller/place.js → controller/doc.js

@ -1,11 +1,14 @@
var service = { mget: require('../service/mget') }; var service = { mget: require('../service/mget') };
var geojsonify = require('../helper/geojsonify').search; var geojsonify = require('../helper/geojsonify').search;
function setup( backend ){ function setup( backend ){
// allow overriding of dependencies // allow overriding of dependencies
backend = backend || require('../src/backend'); backend = backend || require('../src/backend');
function controller( req, res, next ){ function controller( req, res, next ){
var query = req.clean.ids.map( function(id) { var query = req.clean.ids.map( function(id) {
return { return {
_index: 'pelias', _index: 'pelias',
@ -15,6 +18,7 @@ function setup( backend ){
}); });
service.mget( backend, query, function( err, docs ){ service.mget( backend, query, function( err, docs ){
// error handler // error handler
if( err ){ return next( err ); } if( err ){ return next( err ); }
@ -26,7 +30,9 @@ function setup( backend ){
// respond // respond
return res.status(200).json( geojson ); return res.status(200).json( geojson );
}); });
} }
return controller; return controller;

1
sanitiser/place.js → sanitiser/doc.js

@ -1,3 +1,4 @@
var _sanitize = require('../sanitiser/_sanitize'), var _sanitize = require('../sanitiser/_sanitize'),
sanitizers = { sanitizers = {
id: require('../sanitiser/_id'), id: require('../sanitiser/_id'),

4
test/ciao/place/msuccess.coffee → test/ciao/doc/msuccess.coffee

@ -1,6 +1,6 @@
#> valid place query #> valid doc query
path: '/place?id=geoname:4221195&id=geoname:4193595' path: '/doc?id=geoname:4221195&id=geoname:4193595'
#? 200 ok #? 200 ok
response.statusCode.should.equal 200 response.statusCode.should.equal 200

4
test/ciao/place/success.coffee → test/ciao/doc/success.coffee

@ -1,6 +1,6 @@
#> valid place query #> valid doc query
path: '/place?id=geoname:4221195' path: '/doc?id=geoname:4221195'
#? 200 ok #? 200 ok
response.statusCode.should.equal 200 response.statusCode.should.equal 200

5
test/unit/controller/place.js → test/unit/controller/doc.js

@ -1,4 +1,5 @@
var setup = require('../../../controller/place'),
var setup = require('../../../controller/doc'),
mockBackend = require('../mock/backend'); mockBackend = require('../mock/backend');
module.exports.tests = {}; module.exports.tests = {};
@ -14,7 +15,7 @@ module.exports.tests.interface = function(test, common) {
// functionally test controller (backend success) // functionally test controller (backend success)
module.exports.tests.functional_success = function(test, common) { module.exports.tests.functional_success = function(test, common) {
// expected geojson features for 'client/place/ok/1' fixture // expected geojson features for 'client/doc/ok/1' fixture
var expected = [{ var expected = [{
type: 'Feature', type: 'Feature',
geometry: { geometry: {

4
test/unit/run.js

@ -4,14 +4,14 @@ var common = {};
var tests = [ var tests = [
require('./controller/index'), require('./controller/index'),
require('./controller/place'), require('./controller/doc'),
require('./controller/search'), require('./controller/search'),
require('./service/mget'), require('./service/mget'),
require('./service/search'), require('./service/search'),
require('./sanitiser/suggest'), require('./sanitiser/suggest'),
require('./sanitiser/search'), require('./sanitiser/search'),
require('./sanitiser/reverse'), require('./sanitiser/reverse'),
require('./sanitiser/place'), require('./sanitiser/doc'),
require('./sanitiser/coarse'), require('./sanitiser/coarse'),
require('./query/indeces'), require('./query/indeces'),
require('./query/sort'), require('./query/sort'),

8
test/unit/sanitiser/place.js → test/unit/sanitiser/doc.js

@ -1,7 +1,7 @@
var place = require('../../../sanitiser/place'), var doc = require('../../../sanitiser/doc'),
_sanitize = place.sanitize, _sanitize = doc.sanitize,
middleware = place.middleware, middleware = doc.middleware,
indeces = require('../../../query/indeces'), indeces = require('../../../query/indeces'),
delimiter = ':', delimiter = ':',
defaultLengthError = function(input) { return 'invalid param \''+ input + '\': text length, must be >0'; }, defaultLengthError = function(input) { return 'invalid param \''+ input + '\': text length, must be >0'; },
@ -190,7 +190,7 @@ module.exports.tests.middleware_success = function(test, common) {
module.exports.all = function (tape, common) { module.exports.all = function (tape, common) {
function test(name, testFunction) { function test(name, testFunction) {
return tape('SANTIZE /place ' + name, testFunction); return tape('SANTIZE /doc ' + name, testFunction);
} }
for( var testCase in module.exports.tests ){ for( var testCase in module.exports.tests ){
Loading…
Cancel
Save