|
|
@ -7,19 +7,19 @@ const logger = require('pelias-logger').get('api'); |
|
|
|
const logging = require( '../helper/logging' ); |
|
|
|
const logging = require( '../helper/logging' ); |
|
|
|
const retry = require('retry'); |
|
|
|
const retry = require('retry'); |
|
|
|
|
|
|
|
|
|
|
|
function setup( apiConfig, esclient, query ){ |
|
|
|
function requestHasErrors(request) { |
|
|
|
function requestHasErrors(request) { |
|
|
|
return _.get(request, 'errors', []).length > 0; |
|
|
|
return _.get(request, 'errors', []).length > 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function responseHasData(response) { |
|
|
|
function responseHasData(response) { |
|
|
|
return _.get(response, 'data', []).length > 0; |
|
|
|
return _.get(response, 'data', []).length > 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isRequestTimeout(err) { |
|
|
|
function isRequestTimeout(err) { |
|
|
|
return _.get(err, 'status') === 408; |
|
|
|
return _.get(err, 'status') === 408; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setup( apiConfig, esclient, query ){ |
|
|
|
function controller( req, res, next ){ |
|
|
|
function controller( req, res, next ){ |
|
|
|
// do not run controller when a request
|
|
|
|
// do not run controller when a request
|
|
|
|
// validation error has occurred.
|
|
|
|
// validation error has occurred.
|
|
|
|