diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index d72444c..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,12 +0,0 @@ -# These are supported funding model platforms - -github: [dnlup] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: [] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 52bdde2..bf82858 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - node-version: [14.x, 16.x] + node-version: [20.x, 22.x] runs-on: ${{ matrix.os }} @@ -37,5 +37,8 @@ jobs: - name: Run tests run: npm run test:ci + - name: Run tests on fastify 4 + run: npm i fastify@4 && npm run test:ci + - name: Coverage report uses: codecov/codecov-action@v3.1.4 diff --git a/README.md b/README.md index 5b3fe8a..8546129 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,6 @@ $ npm i @dnlup/fastify-traps ``` -If you are using fastify 3, use the version `1` of the plugin: - -```bash -$ npm i @dnlup/fastify-traps@1 -``` - ## Usage #### Default diff --git a/index.js b/index.js index 36e2d16..acf4e7b 100644 --- a/index.js +++ b/index.js @@ -79,6 +79,6 @@ function plugin (fastify, opts, next) { } module.exports = fp(plugin, { - fastify: '^4.0.0', + fastify: '>=4.0.0', name: '@dnlup/fastify-traps' }) diff --git a/package.json b/package.json index 4258c5e..2b8cdfa 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ }, "homepage": "https://github.com/dnlup/fastify-traps#readme", "devDependencies": { - "@types/node": "^20.1.2", - "fastify": "^4.1.0", + "@types/node": "^22.10.1", + "fastify": "^5.1.0", "husky": "^8.0.3", "lint-staged": "^15.2.0", "markdown-toc": "^1.2.0", @@ -59,6 +59,6 @@ "typescript": "^5.0.4" }, "dependencies": { - "fastify-plugin": "^4.0.0" + "fastify-plugin": "^5.0.1" } } diff --git a/test/fixtures/close.js b/test/fixtures/close.js index 8cd2f0f..678b1f4 100644 --- a/test/fixtures/close.js +++ b/test/fixtures/close.js @@ -8,7 +8,4 @@ const fastify = Fastify(fastifyOptions) fastify.register(plugin, { strict: false }) -fastify.listen(0, (err) => { - const payload = err ? 'error' : 'listening' - send(payload) -}) +fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error')) diff --git a/test/fixtures/closeError.js b/test/fixtures/closeError.js index d78b14e..e0a8816 100644 --- a/test/fixtures/closeError.js +++ b/test/fixtures/closeError.js @@ -17,6 +17,4 @@ fastify.register(plugin, { strict: false }) -fastify.listen(0, err => { - send(err ? 'error' : 'listening') -}) +fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error')) diff --git a/test/fixtures/closeTimeout.js b/test/fixtures/closeTimeout.js index e98bc0c..b959885 100644 --- a/test/fixtures/closeTimeout.js +++ b/test/fixtures/closeTimeout.js @@ -18,6 +18,4 @@ fastify.register(plugin, { strict: false }) -fastify.listen(0, err => { - send(err ? 'error' : 'listening') -}) +fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error')) diff --git a/test/fixtures/customCloseHooks.js b/test/fixtures/customCloseHooks.js index 199334e..03db6d6 100644 --- a/test/fixtures/customCloseHooks.js +++ b/test/fixtures/customCloseHooks.js @@ -12,6 +12,4 @@ fastify.register(plugin, { strict: false }) -fastify.listen(0, err => { - send(err ? 'error' : 'listening') -}) +fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error')) diff --git a/test/fixtures/customErrorHook.js b/test/fixtures/customErrorHook.js index 4bf6e7c..8407228 100644 --- a/test/fixtures/customErrorHook.js +++ b/test/fixtures/customErrorHook.js @@ -18,6 +18,4 @@ fastify.register(plugin, { strict: false }) -fastify.listen(0, err => { - send(err ? 'error' : 'listening') -}) +fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error')) diff --git a/test/fixtures/customTimeoutHook.js b/test/fixtures/customTimeoutHook.js index 4329e25..cd2fb88 100644 --- a/test/fixtures/customTimeoutHook.js +++ b/test/fixtures/customTimeoutHook.js @@ -19,6 +19,4 @@ fastify.register(plugin, { strict: false }) -fastify.listen(0, err => { - send(err ? 'error' : 'listening') -}) +fastify.listen({ port: 0 }).then(() => send('listening')).catch(e => send('error'))