Skip to content

Commit 0bffa37

Browse files
authored
feat: support fastify 5 (#346)
Add support for fastify 5 and remove old Node.js versions in ci tests.
1 parent 6bf2574 commit 0bffa37

11 files changed

+14
-42
lines changed

.github/FUNDING.yml

-12
This file was deleted.

.github/workflows/tests.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [ubuntu-latest, macos-latest]
19-
node-version: [14.x, 16.x]
19+
node-version: [20.x, 22.x]
2020

2121
runs-on: ${{ matrix.os }}
2222

@@ -37,5 +37,8 @@ jobs:
3737
- name: Run tests
3838
run: npm run test:ci
3939

40+
- name: Run tests on fastify 4
41+
run: npm i fastify@4 && npm run test:ci
42+
4043
- name: Coverage report
4144
uses: codecov/[email protected]

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@
2929
$ npm i @dnlup/fastify-traps
3030
```
3131

32-
If you are using fastify 3, use the version `1` of the plugin:
33-
34-
```bash
35-
$ npm i @dnlup/fastify-traps@1
36-
```
37-
3832
## Usage
3933

4034
#### Default

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ function plugin (fastify, opts, next) {
7979
}
8080

8181
module.exports = fp(plugin, {
82-
fastify: '^4.0.0',
82+
fastify: '>=4.0.0',
8383
name: '@dnlup/fastify-traps'
8484
})

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
},
4747
"homepage": "https://github.com/dnlup/fastify-traps#readme",
4848
"devDependencies": {
49-
"@types/node": "^20.1.2",
50-
"fastify": "^4.1.0",
49+
"@types/node": "^22.10.1",
50+
"fastify": "^5.1.0",
5151
"husky": "^8.0.3",
5252
"lint-staged": "^15.2.0",
5353
"markdown-toc": "^1.2.0",
@@ -59,6 +59,6 @@
5959
"typescript": "^5.0.4"
6060
},
6161
"dependencies": {
62-
"fastify-plugin": "^4.0.0"
62+
"fastify-plugin": "^5.0.1"
6363
}
6464
}

test/fixtures/close.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@ const fastify = Fastify(fastifyOptions)
88

99
fastify.register(plugin, { strict: false })
1010

11-
fastify.listen(0, (err) => {
12-
const payload = err ? 'error' : 'listening'
13-
send(payload)
14-
})
11+
fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error'))

test/fixtures/closeError.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ fastify.register(plugin, {
1717
strict: false
1818
})
1919

20-
fastify.listen(0, err => {
21-
send(err ? 'error' : 'listening')
22-
})
20+
fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error'))

test/fixtures/closeTimeout.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ fastify.register(plugin, {
1818
strict: false
1919
})
2020

21-
fastify.listen(0, err => {
22-
send(err ? 'error' : 'listening')
23-
})
21+
fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error'))

test/fixtures/customCloseHooks.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ fastify.register(plugin, {
1212
strict: false
1313
})
1414

15-
fastify.listen(0, err => {
16-
send(err ? 'error' : 'listening')
17-
})
15+
fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error'))

test/fixtures/customErrorHook.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ fastify.register(plugin, {
1818
strict: false
1919
})
2020

21-
fastify.listen(0, err => {
22-
send(err ? 'error' : 'listening')
23-
})
21+
fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error'))

test/fixtures/customTimeoutHook.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,4 @@ fastify.register(plugin, {
1919
strict: false
2020
})
2121

22-
fastify.listen(0, err => {
23-
send(err ? 'error' : 'listening')
24-
})
22+
fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error'))

0 commit comments

Comments
 (0)