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 a0a44cc..2628fff 100644 --- a/.taprc +++ b/.taprc @@ -1,7 +1,4 @@ -jsx: false -ts: false -flow: false -coverage: false +disable-coverage: true jobs: 1 files: - - 'test/**/*.test.js' + - "test/**/*.test.js" diff --git a/index.js b/index.js index a604efa..8162dba 100644 --- a/index.js +++ b/index.js @@ -221,7 +221,7 @@ async function fastifyUnderPressure (fastify, opts) { } function onRequest (req, reply, next) { - const _pressureHandler = req.context.config.pressureHandler || pressureHandler + const _pressureHandler = req.routeOptions.config.pressureHandler || pressureHandler if (checkMaxEventLoopDelay && eventLoopDelay > maxEventLoopDelay) { handlePressure(_pressureHandler, req, reply, next, TYPE_EVENT_LOOP_DELAY, eventLoopDelay) return @@ -310,7 +310,8 @@ function now () { } module.exports = fp(fastifyUnderPressure, { - fastify: '4.x', + // DISABLED UNTIL FINAL fastify@5 RELEASE: + // fastify: '5.x', name: '@fastify/under-pressure' }) module.exports.default = fastifyUnderPressure diff --git a/package.json b/package.json index 71a74fa..e681cfb 100644 --- a/package.json +++ b/package.json @@ -28,19 +28,19 @@ "author": "Tomas Della Vedova - @delvedor (http://delved.org)", "license": "MIT", "dependencies": { - "@fastify/error": "^3.0.0", - "fastify-plugin": "^4.0.0" + "@fastify/error": "^3.4.1", + "fastify-plugin": "^4.5.1" }, "devDependencies": { - "@fastify/pre-commit": "^2.0.2", - "@types/node": "^20.1.0", - "fastify": "^4.0.0-rc.2", - "semver": "^7.3.2", - "simple-get": "^4.0.0", + "@fastify/pre-commit": "^2.1.0", + "@types/node": "^20.12.7", + "fastify": "^5.0.0-alpha.1", + "semver": "^7.6.0", + "simple-get": "^4.0.1", "sinon": "^18.0.0", "snazzy": "^9.0.0", - "standard": "^17.0.0", - "tap": "^16.2.0", + "standard": "^17.1.0", + "tap": "^18.7.2", "tsd": "^0.31.0" }, "publishConfig": { diff --git a/test/pressurehandler.test.js b/test/pressurehandler.test.js index 5fb1390..3956347 100644 --- a/test/pressurehandler.test.js +++ b/test/pressurehandler.test.js @@ -268,7 +268,7 @@ test('event loop utilization', { skip: !isSupportedVersion }, t => { test('event loop delay (NaN)', { skip: !isSupportedVersion }, t => { t.plan(5) - const mockedUnderPressure = t.mock('../index', { + const mockedUnderPressure = t.mockRequire('../index', { perf_hooks: { monitorEventLoopDelay: () => ({ enable: () => { },