{"size": 698, "ext": "js", "max_stars_repo_path": "node_modules/@newrelic/koa/lib/route-instrumentation.js", "max_stars_repo_name": "isaachhm/cis411_lab5_Monitoring", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/@newrelic/koa/lib/route-instrumentation.js", "max_issues_repo_name": "isaachhm/cis411_lab5_Monitoring", "max_issues_repo_issues_event_min_datetime": "2021-10-06T21:58:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-19T06:38:42.000Z", "max_forks_repo_path": "node_modules/@newrelic/koa/lib/route-instrumentation.js", "max_forks_repo_name": "isaachhm/cis411_lab5_Monitoring", "max_forks_repo_forks_event_min_datetime": "2018-06-01T16:46:52.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-01T16:46:52.000Z"}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": 1, "avg_line_length": 26.8461538462, "max_line_length": 66, "alphanum_fraction": 0.5988538682}
'use strict'

var methods = require('methods')

module.exports = function instrumentRoute(shim, route) {
  shim.setFramework(shim.KOA)

  methods.forEach(function wrap(method) {
    shim.wrap(route, method, function wrapMethod(shim, methodFn) {
      return function wrappedMethod() {
        var middleware = methodFn.apply(route, arguments)
        return shim.recordMiddleware(middleware, {
          type: shim.MIDDLEWARE,
          route: arguments[0],
          next: shim.LAST,
          name: shim.getName(arguments[1]),
          promise: true,
          req: function getReq(shim, fn, fnName, args) {
            return args[0] && args[0].req
          }
        })
      }
    })
  })
}
