From 1e00a13ff2e7646da40c5968b691bff655075557 Mon Sep 17 00:00:00 2001 From: Kristiyan Tachev Date: Thu, 7 Mar 2024 15:36:38 +0200 Subject: [PATCH] feature(fastify): added decoupling between fastify versions and we let the user decide which version to use --- package.json | 4 +-- packages/fastify/package.json | 7 ++--- packages/fastify/src/fastify.module.ts | 3 ++- yarn.lock | 37 +++++++++++--------------- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 8131a29..062294a 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,6 @@ "module": "./dist/index.js", "typings": "./dist/index.d.ts", "dependencies": { - "fastify": "^4.25.1" + "fastify": "^4.26.2" } -} +} \ No newline at end of file diff --git a/packages/fastify/package.json b/packages/fastify/package.json index 64fd808..aeaa447 100644 --- a/packages/fastify/package.json +++ b/packages/fastify/package.json @@ -17,9 +17,10 @@ "type": "git", "url": "git@github.com:r-html/rhtml.git" }, - "dependencies": { - "fastify": "^4.25.1" + "peerDependencies": { + "fastify": "^4.26.2" }, + "dependencies": {}, "devDependencies": { "@types/jest": "^24.0.18", "jest": "^24.9.0", @@ -39,4 +40,4 @@ "types": "./dist/index.d.ts", "module": "./dist/index.js", "typings": "./dist/index.d.ts" -} +} \ No newline at end of file diff --git a/packages/fastify/src/fastify.module.ts b/packages/fastify/src/fastify.module.ts index c918e6a..2e224a9 100644 --- a/packages/fastify/src/fastify.module.ts +++ b/packages/fastify/src/fastify.module.ts @@ -6,6 +6,7 @@ import { Fastify, FastifyModuleOptions } from './fastify.tokens'; @Module() export class FastifyModule { public static forRoot( + fastifyInstance: typeof fastify, options: Partial ): ModuleWithProviders { return { @@ -14,7 +15,7 @@ export class FastifyModule { { provide: Fastify, useFactory: async () => { - const instance = fastify(options); + const instance = fastifyInstance(options); const plugins = options.plugins || []; const schemas = options.schemas || []; diff --git a/yarn.lock b/yarn.lock index e0e00db..443e895 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1595,10 +1595,10 @@ convert-source-map@^1.4.0, convert-source-map@^1.7.0: dependencies: safe-buffer "~5.1.1" -cookie@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" - integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== +cookie@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051" + integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw== copy-descriptor@^0.1.0: version "0.1.1" @@ -2285,10 +2285,10 @@ fast-uri@^2.0.0, fast-uri@^2.1.0: resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-2.3.0.tgz#bdae493942483d299e7285dcb4627767d42e2793" integrity sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw== -fastify@^4.25.1: - version "4.26.1" - resolved "https://registry.yarnpkg.com/fastify/-/fastify-4.26.1.tgz#91b11565d2533b7e83d267ad8998c39d263e0279" - integrity sha512-tznA/G55dsxzM5XChBfcvVSloG2ejeeotfPPJSFaWmHyCDVGMpvf3nRNbsCb/JTBF9RmQFBfuujWt3Nphjesng== +fastify@^4.26.2: + version "4.26.2" + resolved "https://registry.yarnpkg.com/fastify/-/fastify-4.26.2.tgz#9389595c46e9f4648de5bf8175e750bf32fed5a1" + integrity sha512-90pjTuPGrfVKtdpLeLzND5nyC4woXZN5VadiNQCicj/iJU4viNHKhsAnb7jmv1vu2IzkLXyBiCzdWuzeXgQ5Ug== dependencies: "@fastify/ajv-compiler" "^3.5.0" "@fastify/error" "^3.4.0" @@ -3713,12 +3713,12 @@ levn@~0.3.0: type-check "~0.3.2" light-my-request@^5.11.0: - version "5.11.0" - resolved "https://registry.yarnpkg.com/light-my-request/-/light-my-request-5.11.0.tgz#90e446c303b3a47b59df38406d5f5c2cf224f2d1" - integrity sha512-qkFCeloXCOMpmEdZ/MV91P8AT4fjwFXWaAFz3lUeStM8RcoM1ks4J/F8r1b3r6y/H4u3ACEJ1T+Gv5bopj7oDA== + version "5.12.0" + resolved "https://registry.yarnpkg.com/light-my-request/-/light-my-request-5.12.0.tgz#e42ed02ddbfa587f82031b21459c6841a6948dfa" + integrity sha512-P526OX6E7aeCIfw/9UyJNsAISfcFETghysaWHQAlQYayynShT08MOj4c6fBCvTWBrHXSvqBAKDp3amUPSCQI4w== dependencies: - cookie "^0.5.0" - process-warning "^2.0.0" + cookie "^0.6.0" + process-warning "^3.0.0" set-cookie-parser "^2.4.1" lines-and-columns@^1.1.6: @@ -4458,9 +4458,9 @@ pino-std-serializers@^6.0.0: integrity sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA== pino@^8.17.0: - version "8.18.0" - resolved "https://registry.yarnpkg.com/pino/-/pino-8.18.0.tgz#f2bfbb4e827ed2049ee1e88372268efdcd1505f6" - integrity sha512-Mz/gKiRyuXu4HnpHgi1YWdHQCoWMufapzooisvFn78zl4dZciAxS+YeRkUxXl1ee/SzU80YCz1zpECCh4oC6Aw== + version "8.19.0" + resolved "https://registry.yarnpkg.com/pino/-/pino-8.19.0.tgz#ccc15ef736f103ec02cfbead0912bc436dc92ce4" + integrity sha512-oswmokxkav9bADfJ2ifrvfHUwad6MLp73Uat0IkQWY3iAw5xTRoznXbXksZs8oaOUMpmhVWD+PZogNzllWpJaA== dependencies: atomic-sleep "^1.0.0" fast-redact "^3.1.1" @@ -4556,11 +4556,6 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== -process-warning@^2.0.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-2.3.2.tgz#70d8a3251aab0eafe3a595d8ae2c5d2277f096a5" - integrity sha512-n9wh8tvBe5sFmsqlg+XQhaQLumwpqoAUruLwjCopgTmUBjJ/fjtBsJzKleCaIGBOMXYEhp1YfKl4d7rJ5ZKJGA== - process-warning@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-3.0.0.tgz#96e5b88884187a1dce6f5c3166d611132058710b"