Browse Source

moved helper functions outside of setup scope

pull/782/head
Stephen Hess 8 years ago
parent
commit
73ef71d863
  1. 10
      controller/place.js
  2. 14
      controller/search.js

10
controller/place.js

@ -6,15 +6,15 @@ const retry = require('retry');
const mgetService = require('../service/mget');
const logger = require('pelias-logger').get('api');
function setup( apiConfig, esclient ){
function requestHasErrors(request) {
function requestHasErrors(request) {
return _.get(request, 'errors', []).length > 0;
}
}
function isRequestTimeout(err) {
function isRequestTimeout(err) {
return _.get(err, 'status') === 408;
}
}
function setup( apiConfig, esclient ){
function controller( req, res, next ){
// do not run controller when a request validation error has occurred.
if (requestHasErrors(req)){

14
controller/search.js

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

Loading…
Cancel
Save