{"size": 526, "ext": "js", "max_stars_repo_path": "src/server/api/yelp/handlers/query.js", "max_stars_repo_name": "aarmour/my-denver", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/server/api/yelp/handlers/query.js", "max_issues_repo_name": "aarmour/my-denver", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/server/api/yelp/handlers/query.js", "max_forks_repo_name": "aarmour/my-denver", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.9166666667, "max_line_length": 58, "alphanum_fraction": 0.6711026616}
'use strict';

const Boom = require('boom');

const DEFAULT_LOCATION = '39.7392,-104.9848';

exports.view = function (request, reply) {
  const params = {
    term: request.params.query,
    limit: request.plugins.pagination.limit,
    offset: request.plugins.pagination.offset
  };

  if (request.params.bbox) {
    params.bounds = request.params.bbox;
  } else {
    params.ll = DEFAULT_LOCATION;
  }

  this.client.search(params)
    .then(body => reply(body))
    .catch(error => reply(Boom.badImplementation(error)));
};
