diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b00276..5395d92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: jobs: test: - uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3 + uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.1.0 with: license-check: true lint: true diff --git a/.taprc b/.taprc index eb6eb3e..d36888a 100644 --- a/.taprc +++ b/.taprc @@ -1,2 +1,3 @@ +show-full-coverage: true files: - test/**/*.test.js diff --git a/index.js b/index.js index e049d9a..c96340c 100644 --- a/index.js +++ b/index.js @@ -35,18 +35,11 @@ async function fastifyRoutesStats (fastify, opts) { clearPerformance() }) - // Node 14 does not have clearMeasures but Node 16 and above need it to avoid - // a memory leak. - /* istanbul ignore next */ - const clearPerformance = performance.clearMeasures - ? () => { - performance.clearMarks() - performance.clearMeasures() - } - : () => { - /* istanbul ignore next */ - performance.clearMarks() - } + /* c8 ignore next */ + const clearPerformance = () => { + performance.clearMarks() + performance.clearMeasures() + } obs.observe({ entryTypes: ['measure'], buffered: true }) fastify.decorateRequest(decoratorName, false) @@ -59,7 +52,7 @@ async function fastifyRoutesStats (fastify, opts) { fastify.addHook('onSend', function (request, reply, _, next) { if (request[decoratorName]) { - const routeId = reply.context.config.statsId || request.raw.url + const routeId = request.routeOptions.config.statsId || request.raw.url const id = request.id const key = `${ROUTES}${request.raw.method}|${routeId}` diff --git a/package.json b/package.json index bd887fb..daf11e3 100644 --- a/package.json +++ b/package.json @@ -33,16 +33,16 @@ "homepage": "https://github.com/fastify/fastify-routes-stats#readme", "devDependencies": { "@fastify/pre-commit": "2.1.0", - "@sinonjs/fake-timers": "^11.0.0", - "@types/node": "^20.1.0", - "fastify": "^4.2.1", + "@sinonjs/fake-timers": "^11.2.2", + "@types/node": "^20.12.7", + "fastify": "^4.26.2", "snazzy": "^9.0.0", - "standard": "^17.0.0", - "tap": "^16.2.0", + "standard": "^17.1.0", + "tap": "^18.7.2", "tsd": "^0.31.0" }, "dependencies": { - "fastify-plugin": "^4.0.0" + "fastify-plugin": "^4.5.1" }, "pre-commit": [ "lint",