Skip to content

Commit

Permalink
Merge pull request #619 from immobiliare/617-fastify-5-support
Browse files Browse the repository at this point in the history
feat: switch to fastify v5
  • Loading branch information
dnlup authored Nov 29, 2024
2 parents 1ac576b + bdfbf60 commit 86949f6
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/fixtures/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ service.get(
}
);

service.listen(3000, (error) => {
service.listen({ port: 3000 }, (error) => {
if (error) {
service.log.error(error);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/fixtures/withDynamicModeMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ service.get(
}
);

service.listen(3002, (error) => {
service.listen({ port: 3002 }, (error) => {
if (error) {
service.log.error(error);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/fixtures/withStaticModeMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ service.get(
}
);

service.listen(3001, (error) => {
service.listen({ port: 3001 }, (error) => {
if (error) {
service.log.error(error);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,6 @@ module.exports = fp(
},
{
name: '@immobiliarelabs/fastify-metrics',
fastify: '>=4.x',
fastify: '^5.0.0',
}
);
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { FastifyRouteConfig } from 'fastify/types/route';

function getFastify(options?: MetricsPluginOptions) {
const instance = Fastify();
return instance.register(plugin, options);
return instance.register(plugin, options || {});
}

expectType<FastifyPluginCallback<MetricsPluginOptions>>(plugin);
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports.onRequest = function (request, reply, next) {
};

exports.onResponse = function (request, reply, next) {
reply.sendTimingMetric('response_time', reply.getResponseTime());
reply.sendTimingMetric('response_time', reply.elapsedTime);
next();
};

Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"license": "MIT",
"engines": {
"node": ">=18"
"node": ">=20"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
Expand All @@ -66,7 +66,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"fastify": "^4.25.1",
"fastify": "^5.1.0",
"husky": "^8.0.0",
"is-ci": "^3.0.0",
"lint-staged": "^15.2.0",
Expand All @@ -81,10 +81,9 @@
"@dnlup/doc": "^5.0.3",
"@dnlup/hrtime-utils": "^1.0.1",
"@immobiliarelabs/dats": "^5.1.0",
"fastify-plugin": "^4.0.0"
"fastify-plugin": "^5.0.1"
},
"volta": {
"node": "18.15.0",
"npm": "9.6.2"
"node": "20.18.1"
}
}

0 comments on commit 86949f6

Please sign in to comment.