Skip to content

Commit

Permalink
Updating for v5 (#119)
Browse files Browse the repository at this point in the history
* chore: update tap configuration and NPM deps

* fix: update code to be compliant with node>=16 and fastify>=5

* chore: update plugin-ci to v4.1

* chore: use c8 comment instead of istanbul

Latest version of `tap` uses `c8` instead of `istanbul`

* fix: add missing patch in plugin version
  • Loading branch information
Gesma94 authored May 4, 2024
1 parent ddc9d1e commit 77096cd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
show-full-coverage: true
files:
- test/**/*.test.js
19 changes: 6 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}`

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 77096cd

Please sign in to comment.