From 59713d625de24abc1de16fc74782389531c1ad28 Mon Sep 17 00:00:00 2001 From: gkampitakis Date: Wed, 18 Dec 2024 23:06:31 +0200 Subject: [PATCH] feat: update deps and support fastify v5 --- .github/workflows/ci.yml | 10 +++++----- example/server.js | 10 +++++----- lib/index.d.ts | 6 +++--- lib/src/customHealthCheck.d.ts | 12 ++++++++---- package.json | 12 ++++++------ 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d519bb3..e728f59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,20 +3,20 @@ name: CI on: pull_request: paths-ignore: - - 'docs/**' - - '*.md' + - "docs/**" + - "*.md" jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [14, 16, 18] + node-version: [20, 22, 24] os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v2.1.5 + uses: actions/setup-node@@v4 with: node-version: ${{ matrix.node-version }} - name: Install Dependencies diff --git a/example/server.js b/example/server.js index ed217bb..9cd257b 100644 --- a/example/server.js +++ b/example/server.js @@ -27,12 +27,12 @@ fastify.register(customHealthCheck, { return new Promise((resolve) => setTimeout(resolve, 2000)); }); - fastify.addHealthCheck('mongo', async () => { - const client = await MongoClient.connect(url); - client.db('example'); + // fastify.addHealthCheck('mongo', async () => { + // const client = await MongoClient.connect(url); + // client.db('example'); - client.close(); - }); + // client.close(); + // }); fastify.addHealthCheck('sync', () => true); diff --git a/lib/index.d.ts b/lib/index.d.ts index eed7ec1..44af77c 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,4 +1,4 @@ -import { FastifyPlugin } from 'fastify'; +import { FastifyPluginCallback } from 'fastify'; import { addHealthCheck } from './src/customHealthCheck'; export interface CustomHealthCheckOptions { @@ -9,7 +9,7 @@ export interface CustomHealthCheckOptions { /** Flag that enables additional information to be presented in health check object when a check fails. */ exposeFailure?: boolean; /** If set to true, default schema is used for the route definition, if to false - no schema. If object is passed, it will be used as a schema. Default value is "true" */ - schema?: boolean | Record + schema?: boolean | Record; } declare module 'fastify' { @@ -18,5 +18,5 @@ declare module 'fastify' { } } -declare const customHealthCheck: FastifyPlugin; +declare const customHealthCheck: FastifyPluginCallback; export default customHealthCheck; diff --git a/lib/src/customHealthCheck.d.ts b/lib/src/customHealthCheck.d.ts index 4072635..08b7709 100644 --- a/lib/src/customHealthCheck.d.ts +++ b/lib/src/customHealthCheck.d.ts @@ -3,11 +3,15 @@ export interface addHealthCheck { * @param label string for registering checks, must be unique * @param fn callback function supports Promises * @param evaluation object containing a value to compare with healthcheck fn return value - */ - (label: string, fn: (...args: any) => Promise | unknown, evaluation?: evaluation): void; + */ + ( + label: string, + fn: (...args: any) => Promise | unknown, + evaluation?: evaluation + ): void; } interface evaluation { /** object or value to compare with healthcheck fn */ - value: unknown -} \ No newline at end of file + value: unknown; +} diff --git a/package.json b/package.json index f956f81..7047f15 100644 --- a/package.json +++ b/package.json @@ -29,16 +29,16 @@ }, "dependencies": { "fast-deep-equal": "^3.1.3", - "fastify-plugin": "^4.0.0" + "fastify-plugin": "^5.0.1" }, "devDependencies": { - "fastify": "^4.0.0", - "fastify-type-provider-zod": "^1.1.7", - "jest": "^29.0.1", + "fastify": "^5.2.0", + "fastify-type-provider-zod": "^4.0.2", + "jest": "^29.7.0", "mongodb": "^4.7.0", - "semistandard": "^16.0.1", + "semistandard": "^17.0.0", "snazzy": "^9.0.0", - "zod": "^3.19.1" + "zod": "^3.24.1" }, "jest": { "collectCoverage": true,