{"size": 2198, "ext": "js", "max_stars_repo_path": "app/data/fruits.js", "max_stars_repo_name": "nbcp/enterprise", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/data/fruits.js", "max_issues_repo_name": "nbcp/enterprise", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/data/fruits.js", "max_forks_repo_name": "nbcp/enterprise", "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": 33.8153846154, "max_line_length": 78, "alphanum_fraction": 0.4458598726}

module.exports = (req, res, next) => {
  let resData;
  const fruits = {
    main: '' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Apples</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#" data-category-id="grapes"><span>Grapes</span></a>' +
          '</div>' +
          '<div class="accordion-pane"></div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Oranges</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#" data-category-id="Kiwi"><span>Kiwi</span></a>' +
          '</div>' +
          '<div class="accordion-pane"></div>',

    grapes: '' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Concord</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>John Viola</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Merlot</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Cabernet</span></a>' +
          '</div>',

    Kiwi: '' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Berries</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Blueberries</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Strawberries</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Blackberries</span></a>' +
          '</div>' +
          '<div class="accordion-header">' +
            '<a href="#"><span>Raspberries</span></a>' +
          '</div>'
  };

  resData = req.query.categoryId ? fruits[req.query.categoryId] : fruits.main;
  if (!resData) {
    resData = '' +
        '<div class="accordion-content" style="color: red;">' +
          '<p>Error: Couldn\'t find any fruits...</p>' +
        '</div>';
  }

  res.setHeader('Content-Type', 'application/json');
  res.end(JSON.stringify(resData));
  next();
};
