diff --git a/routes/v1.js b/routes/v1.js index 5c8c82be..6ad31202 100644 --- a/routes/v1.js +++ b/routes/v1.js @@ -28,6 +28,7 @@ var middleware = { var controllers = { coarse_reverse: require('../controller/coarse_reverse'), mdToHTML: require('../controller/markdownToHtml'), + libpostal: require('../controller/libpostal'), place: require('../controller/place'), placeholder: require('../controller/placeholder'), search: require('../controller/search'), @@ -116,6 +117,11 @@ function addRoutes(app, peliasConfig) { isPipServiceEnabled, not(hasRequestErrors), not(hasResponseData) ); + const libpostalShouldExecute = all( + not(hasRequestErrors), + not(isRequestSourcesOnlyWhosOnFirst) + ); + // execute placeholder if libpostal only parsed as admin-only and needs to // be geodisambiguated const placeholderGeodisambiguationShouldExecute = all( @@ -220,6 +226,7 @@ function addRoutes(app, peliasConfig) { sanitizers.search.middleware(peliasConfig.api), middleware.requestLanguage, middleware.calcSize(), + controllers.libpostal(libpostalShouldExecute), controllers.placeholder(placeholderService, geometricFiltersApply, placeholderGeodisambiguationShouldExecute), controllers.placeholder(placeholderService, geometricFiltersDontApply, placeholderIdsLookupShouldExecute), controllers.search_with_ids(peliasConfig.api, esclient, queries.address_using_ids, searchWithIdsShouldExecute),