Skip to content

Commit

Permalink
Merge next into master (#221)
Browse files Browse the repository at this point in the history
* Update for Fastify v5 (#215)

* update npm

* update ci

* make tests pass

* fix deprecation warning

---------

Co-authored-by: Gürgün Dayıoğlu <hey@gurgun.day>
  • Loading branch information
jsumners and gurgunday authored Jun 18, 2024
1 parent 37b2d15 commit a650100
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 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
7 changes: 2 additions & 5 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
jsx: false
ts: false
flow: false
coverage: false
disable-coverage: true
jobs: 1
files:
- 'test/**/*.test.js'
- "test/**/*.test.js"
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion test/pressurehandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => { },
Expand Down

0 comments on commit a650100

Please sign in to comment.