{"size": 504, "ext": "js", "max_stars_repo_path": "controllers/routeStats.js", "max_stars_repo_name": "ufvteam/smalltalks-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "controllers/routeStats.js", "max_issues_repo_name": "ufvteam/smalltalks-server", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "controllers/routeStats.js", "max_forks_repo_name": "ufvteam/smalltalks-server", "max_forks_repo_forks_event_min_datetime": "2021-10-04T21:53:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-04T21:53:41.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 28.0, "max_line_length": 67, "alphanum_fraction": 0.6567460317}
const RouteStats = require('../models/RouteStat');
const ThrowError = require('../utils/throwError');
const asyncHandler = require('../middleware/async');

exports.getRouteStats = asyncHandler(async (req, res, next) => {
  const routesData = await RouteStats.getAll();

  if (routesData.length > 0) {
    res.status(200).json({
      success: true,
      data: routesData,
      msg: 'Show route statistics',
    });
  } else {
    return next(new ThrowError('No route information found', 404));
  }
});
