jishushell 0.6.18 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/anythingllm-container.yaml +1 -0
- package/apps/browserless-chromium-container.yaml +1 -0
- package/apps/filebrowser-container.yaml +1 -0
- package/apps/hermes-container.yaml +1 -7
- package/apps/immich-container-lite.yaml +337 -0
- package/apps/immich-container.yaml +371 -0
- package/apps/jishu-kb-container.yaml +26 -21
- package/apps/ollama-binary.yaml +1 -0
- package/apps/ollama-cpu-container.yaml +1 -0
- package/apps/ollama-with-hollama-binary.yaml +2 -0
- package/apps/openclaw-binary.yaml +4 -8
- package/apps/openclaw-container.yaml +1 -7
- package/apps/openclaw-with-ollama-container.yaml +1 -0
- package/apps/openclaw-with-searxng-container.yaml +20 -0
- package/apps/searxng-container.yaml +20 -0
- package/apps/weknora-container.yaml +5 -0
- package/dependencies/jishushell-panel-0.7.3.tgz +0 -0
- package/dist/cli/core.js +1 -1
- package/dist/cli/core.js.map +1 -1
- package/dist/cli/doctor.js +96 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/config.d.ts +9 -1
- package/dist/config.js +72 -2
- package/dist/config.js.map +1 -1
- package/dist/install.js +60 -19
- package/dist/install.js.map +1 -1
- package/dist/routes/admin.d.ts +2 -0
- package/dist/routes/admin.js +72 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/docker.d.ts +2 -0
- package/dist/routes/docker.js +58 -0
- package/dist/routes/docker.js.map +1 -0
- package/dist/routes/file-mounts.js +5 -8
- package/dist/routes/file-mounts.js.map +1 -1
- package/dist/routes/instances.d.ts +0 -14
- package/dist/routes/instances.js +44 -1184
- package/dist/routes/instances.js.map +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.js +53 -20
- package/dist/server.js.map +1 -1
- package/dist/services/app-common/catalog-service.js +15 -5
- package/dist/services/app-common/catalog-service.js.map +1 -1
- package/dist/services/app-common/delete-service.js +5 -0
- package/dist/services/app-common/delete-service.js.map +1 -1
- package/dist/services/app-common/instance-store.js +3 -0
- package/dist/services/app-common/instance-store.js.map +1 -1
- package/dist/services/app-common/lifecycle-service.js +12 -4
- package/dist/services/app-common/lifecycle-service.js.map +1 -1
- package/dist/services/app-common/ownership.d.ts +3 -0
- package/dist/services/app-common/ownership.js +11 -0
- package/dist/services/app-common/ownership.js.map +1 -0
- package/dist/services/app-common/runtime-facts.js +2 -0
- package/dist/services/app-common/runtime-facts.js.map +1 -1
- package/dist/services/app-common/spec-materializer.d.ts +0 -1
- package/dist/services/app-common/spec-materializer.js +21 -87
- package/dist/services/app-common/spec-materializer.js.map +1 -1
- package/dist/services/app-common/status-refresh.js +25 -13
- package/dist/services/app-common/status-refresh.js.map +1 -1
- package/dist/services/app-modules/browserless/routes.js +5 -3
- package/dist/services/app-modules/browserless/routes.js.map +1 -1
- package/dist/services/capabilities/contract.d.ts +1 -2
- package/dist/services/capabilities/contract.js +0 -10
- package/dist/services/capabilities/contract.js.map +1 -1
- package/dist/services/capabilities/endpoint-validator.js +0 -1
- package/dist/services/capabilities/endpoint-validator.js.map +1 -1
- package/dist/services/capabilities/health.js +1 -1
- package/dist/services/capabilities/health.js.map +1 -1
- package/dist/services/capability-proxy/http.d.ts +7 -0
- package/dist/services/capability-proxy/http.js +555 -0
- package/dist/services/capability-proxy/http.js.map +1 -0
- package/dist/services/capability-proxy/terminal.d.ts +4 -0
- package/dist/services/capability-proxy/terminal.js +179 -0
- package/dist/services/capability-proxy/terminal.js.map +1 -0
- package/dist/services/connections/admin.js +19 -9
- package/dist/services/connections/admin.js.map +1 -1
- package/dist/services/connections/apply.d.ts +3 -9
- package/dist/services/connections/apply.js +0 -29
- package/dist/services/connections/apply.js.map +1 -1
- package/dist/services/connections/transactor.js +2 -2
- package/dist/services/connections/transactor.js.map +1 -1
- package/dist/services/files/bootstrap.d.ts +7 -0
- package/dist/services/files/bootstrap.js +16 -0
- package/dist/services/files/bootstrap.js.map +1 -0
- package/dist/services/files/photos/upload-page.d.ts +2 -0
- package/dist/services/files/photos/upload-page.js +248 -0
- package/dist/services/files/photos/upload-page.js.map +1 -0
- package/dist/services/files/photos/upload-store.d.ts +74 -0
- package/dist/services/files/photos/upload-store.js +432 -0
- package/dist/services/files/photos/upload-store.js.map +1 -0
- package/dist/services/http/proxy-utils.d.ts +7 -0
- package/dist/services/http/proxy-utils.js +29 -0
- package/dist/services/http/proxy-utils.js.map +1 -0
- package/dist/services/http/request-utils.d.ts +3 -0
- package/dist/services/http/request-utils.js +23 -0
- package/dist/services/http/request-utils.js.map +1 -0
- package/dist/services/instances/manager.d.ts +6 -5
- package/dist/services/instances/manager.js +45 -51
- package/dist/services/instances/manager.js.map +1 -1
- package/dist/services/instances/pairing.d.ts +17 -0
- package/dist/services/instances/pairing.js +53 -0
- package/dist/services/instances/pairing.js.map +1 -0
- package/dist/services/instances/status.d.ts +2 -0
- package/dist/services/instances/status.js +11 -0
- package/dist/services/instances/status.js.map +1 -0
- package/dist/services/integrations/hermes/integration.d.ts +1 -1
- package/dist/services/integrations/hermes/integration.js +7 -8
- package/dist/services/integrations/hermes/integration.js.map +1 -1
- package/dist/services/integrations/immich/client.d.ts +93 -0
- package/dist/services/integrations/immich/client.js +458 -0
- package/dist/services/integrations/immich/client.js.map +1 -0
- package/dist/services/integrations/immich/config.d.ts +15 -0
- package/dist/services/integrations/immich/config.js +178 -0
- package/dist/services/integrations/immich/config.js.map +1 -0
- package/dist/services/integrations/immich/discovery.d.ts +9 -0
- package/dist/services/integrations/immich/discovery.js +101 -0
- package/dist/services/integrations/immich/discovery.js.map +1 -0
- package/dist/services/integrations/immich/gallery-renderer.d.ts +5 -0
- package/dist/services/integrations/immich/gallery-renderer.js +150 -0
- package/dist/services/integrations/immich/gallery-renderer.js.map +1 -0
- package/dist/services/integrations/immich/immich-shim.d.ts +11 -0
- package/dist/services/integrations/immich/immich-shim.js +439 -0
- package/dist/services/integrations/immich/immich-shim.js.map +1 -0
- package/dist/services/integrations/immich/integration.d.ts +18 -0
- package/dist/services/integrations/immich/integration.js +64 -0
- package/dist/services/integrations/immich/integration.js.map +1 -0
- package/dist/services/integrations/immich/photo-library.d.ts +4 -0
- package/dist/services/integrations/immich/photo-library.js +63 -0
- package/dist/services/integrations/immich/photo-library.js.map +1 -0
- package/dist/services/integrations/immich/review-executor.d.ts +3 -0
- package/dist/services/integrations/immich/review-executor.js +41 -0
- package/dist/services/integrations/immich/review-executor.js.map +1 -0
- package/dist/services/integrations/immich/review-session-service.d.ts +27 -0
- package/dist/services/integrations/immich/review-session-service.js +206 -0
- package/dist/services/integrations/immich/review-session-service.js.map +1 -0
- package/dist/services/integrations/immich/review-store.d.ts +47 -0
- package/dist/services/integrations/immich/review-store.js +347 -0
- package/dist/services/integrations/immich/review-store.js.map +1 -0
- package/dist/services/integrations/immich/routes.d.ts +7 -0
- package/dist/services/integrations/immich/routes.js +363 -0
- package/dist/services/integrations/immich/routes.js.map +1 -0
- package/dist/services/integrations/immich/types.d.ts +186 -0
- package/dist/services/integrations/immich/types.js +2 -0
- package/dist/services/integrations/immich/types.js.map +1 -0
- package/dist/services/integrations/index.d.ts +1 -0
- package/dist/services/integrations/index.js +1 -0
- package/dist/services/integrations/index.js.map +1 -1
- package/dist/services/integrations/installable/installers/integration.js +113 -7
- package/dist/services/integrations/installable/installers/integration.js.map +1 -1
- package/dist/services/integrations/jishukb/integration.d.ts +3 -1
- package/dist/services/integrations/jishukb/integration.js +121 -10
- package/dist/services/integrations/jishukb/integration.js.map +1 -1
- package/dist/services/integrations/openclaw/integration.d.ts +21 -7
- package/dist/services/integrations/openclaw/integration.js +385 -158
- package/dist/services/integrations/openclaw/integration.js.map +1 -1
- package/dist/services/integrations/openclaw/jishukb-native-mcp.d.ts +58 -0
- package/dist/services/integrations/openclaw/jishukb-native-mcp.js +373 -0
- package/dist/services/integrations/openclaw/jishukb-native-mcp.js.map +1 -0
- package/dist/services/integrations/openclaw/jishukb-shim.d.ts +8 -4
- package/dist/services/integrations/openclaw/jishukb-shim.js +624 -17
- package/dist/services/integrations/openclaw/jishukb-shim.js.map +1 -1
- package/dist/services/integrations/openclaw/mcporter.d.ts +13 -0
- package/dist/services/integrations/openclaw/mcporter.js +31 -0
- package/dist/services/integrations/openclaw/mcporter.js.map +1 -1
- package/dist/services/integrations/openclaw/native-mcp.d.ts +48 -0
- package/dist/services/integrations/openclaw/native-mcp.js +125 -0
- package/dist/services/integrations/openclaw/native-mcp.js.map +1 -0
- package/dist/services/integrations/openclaw/routes.js +4 -1
- package/dist/services/integrations/openclaw/routes.js.map +1 -1
- package/dist/services/integrations/types.d.ts +5 -17
- package/dist/services/repair/runtime-repair.js +68 -1
- package/dist/services/repair/runtime-repair.js.map +1 -1
- package/dist/services/runtime/docker-network.d.ts +8 -0
- package/dist/services/runtime/docker-network.js +123 -0
- package/dist/services/runtime/docker-network.js.map +1 -0
- package/dist/services/runtime/driver-registry.d.ts +4 -0
- package/dist/services/runtime/driver-registry.js.map +1 -1
- package/dist/services/runtime/drivers/nomad.d.ts +1 -0
- package/dist/services/runtime/drivers/nomad.js +35 -5
- package/dist/services/runtime/drivers/nomad.js.map +1 -1
- package/dist/services/runtime/service-manager.d.ts +2 -0
- package/dist/services/runtime/service-manager.js +18 -0
- package/dist/services/runtime/service-manager.js.map +1 -0
- package/dist/services/runtime/types.d.ts +1 -0
- package/dist/services/runtime/workload-compiler.js +29 -4
- package/dist/services/runtime/workload-compiler.js.map +1 -1
- package/dist/services/setup/setup-manager.js +29 -73
- package/dist/services/setup/setup-manager.js.map +1 -1
- package/dist/services/system/runtime-ownership.d.ts +36 -0
- package/dist/services/system/runtime-ownership.js +250 -0
- package/dist/services/system/runtime-ownership.js.map +1 -0
- package/dist/services/system/system-reconciler.js +53 -0
- package/dist/services/system/system-reconciler.js.map +1 -1
- package/dist/types.d.ts +19 -3
- package/dist/utils/path-safety.js +1 -1
- package/dist/utils/service-user.d.ts +13 -0
- package/dist/utils/service-user.js +129 -0
- package/dist/utils/service-user.js.map +1 -0
- package/install/jishu-install.sh +0 -1
- package/node_modules/brace-expansion/dist/commonjs/index.js +24 -14
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js +24 -14
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
- package/node_modules/brace-expansion/package.json +2 -2
- package/node_modules/fast-uri/index.js +1 -1
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +28 -0
- package/node_modules/fastify/SECURITY.md +1 -1
- package/node_modules/fastify/SPONSORS.md +6 -4
- package/node_modules/fastify/docs/Guides/Database.md +0 -28
- package/node_modules/fastify/docs/Guides/Ecosystem.md +13 -2
- package/node_modules/fastify/docs/Guides/Serverless.md +2 -2
- package/node_modules/fastify/docs/Guides/Write-Plugin.md +1 -1
- package/node_modules/fastify/docs/Reference/Encapsulation.md +27 -26
- package/node_modules/fastify/docs/Reference/Errors.md +10 -4
- package/node_modules/fastify/docs/Reference/HTTP2.md +10 -10
- package/node_modules/fastify/docs/Reference/Hooks.md +4 -4
- package/node_modules/fastify/docs/Reference/Index.md +14 -16
- package/node_modules/fastify/docs/Reference/LTS.md +12 -13
- package/node_modules/fastify/docs/Reference/Lifecycle.md +9 -8
- package/node_modules/fastify/docs/Reference/Logging.md +44 -39
- package/node_modules/fastify/docs/Reference/Middleware.md +21 -25
- package/node_modules/fastify/docs/Reference/Principles.md +2 -2
- package/node_modules/fastify/docs/Reference/Reply.md +6 -1
- package/node_modules/fastify/docs/Reference/Request.md +27 -16
- package/node_modules/fastify/docs/Reference/Routes.md +5 -2
- package/node_modules/fastify/docs/Reference/Server.md +31 -3
- package/node_modules/fastify/docs/Reference/Type-Providers.md +29 -5
- package/node_modules/fastify/docs/Reference/Validation-and-Serialization.md +15 -2
- package/node_modules/fastify/docs/Reference/Warnings.md +7 -6
- package/node_modules/fastify/eslint.config.js +7 -2
- package/node_modules/fastify/fastify.d.ts +8 -3
- package/node_modules/fastify/fastify.js +43 -14
- package/node_modules/fastify/lib/content-type-parser.js +13 -1
- package/node_modules/fastify/lib/decorate.js +11 -3
- package/node_modules/fastify/lib/error-handler.js +4 -3
- package/node_modules/fastify/lib/error-serializer.js +59 -59
- package/node_modules/fastify/lib/errors.js +16 -1
- package/node_modules/fastify/lib/four-oh-four.js +14 -9
- package/node_modules/fastify/lib/handle-request.js +11 -5
- package/node_modules/fastify/lib/plugin-override.js +2 -1
- package/node_modules/fastify/lib/plugin-utils.js +5 -5
- package/node_modules/fastify/lib/reply.js +63 -8
- package/node_modules/fastify/lib/request.js +14 -4
- package/node_modules/fastify/lib/route.js +20 -6
- package/node_modules/fastify/lib/schema-controller.js +1 -1
- package/node_modules/fastify/lib/schemas.js +37 -30
- package/node_modules/fastify/lib/symbols.js +3 -1
- package/node_modules/fastify/lib/validation.js +1 -13
- package/node_modules/fastify/lib/warnings.js +3 -3
- package/node_modules/fastify/package.json +13 -15
- package/node_modules/fastify/scripts/validate-ecosystem-links.js +1 -0
- package/node_modules/fastify/test/bundler/esbuild/package.json +1 -1
- package/node_modules/fastify/test/close-pipelining.test.js +1 -2
- package/node_modules/fastify/test/custom-http-server.test.js +38 -0
- package/node_modules/fastify/test/decorator-instance-properties.test.js +63 -0
- package/node_modules/fastify/test/diagnostics-channel/async-error-handler.test.js +74 -0
- package/node_modules/fastify/test/hooks.test.js +23 -0
- package/node_modules/fastify/test/http-methods/get.test.js +1 -1
- package/node_modules/fastify/test/http2/plain.test.js +135 -0
- package/node_modules/fastify/test/http2/secure-with-fallback.test.js +1 -1
- package/node_modules/fastify/test/https/https.test.js +1 -2
- package/node_modules/fastify/test/internals/errors.test.js +31 -1
- package/node_modules/fastify/test/internals/plugin.test.js +3 -1
- package/node_modules/fastify/test/internals/request.test.js +27 -3
- package/node_modules/fastify/test/internals/schema-controller-perf.test.js +33 -0
- package/node_modules/fastify/test/logger/logging.test.js +18 -1
- package/node_modules/fastify/test/logger/options.test.js +38 -1
- package/node_modules/fastify/test/reply-error.test.js +1 -1
- package/node_modules/fastify/test/reply-trailers.test.js +70 -0
- package/node_modules/fastify/test/request-media-type.test.js +105 -0
- package/node_modules/fastify/test/route-prefix.test.js +34 -0
- package/node_modules/fastify/test/router-options.test.js +222 -11
- package/node_modules/fastify/test/schema-serialization.test.js +108 -0
- package/node_modules/fastify/test/schema-validation.test.js +24 -0
- package/node_modules/fastify/test/scripts/validate-ecosystem-links.test.js +40 -57
- package/node_modules/fastify/test/throw.test.js +14 -0
- package/node_modules/fastify/test/trust-proxy.test.js +21 -0
- package/node_modules/fastify/test/types/content-type-parser.tst.ts +70 -0
- package/node_modules/fastify/test/types/{decorate-request-reply.test-d.ts → decorate-request-reply.tst.ts} +4 -4
- package/node_modules/fastify/test/types/{dummy-plugin.ts → dummy-plugin.mts} +1 -1
- package/node_modules/fastify/test/types/errors.tst.ts +91 -0
- package/node_modules/fastify/test/types/fastify.tst.ts +351 -0
- package/node_modules/fastify/test/types/hooks.tst.ts +578 -0
- package/node_modules/fastify/test/types/instance.tst.ts +597 -0
- package/node_modules/fastify/test/types/{logger.test-d.ts → logger.tst.ts} +61 -62
- package/node_modules/fastify/test/types/plugin.tst.ts +96 -0
- package/node_modules/fastify/test/types/register.tst.ts +245 -0
- package/node_modules/fastify/test/types/reply.tst.ts +297 -0
- package/node_modules/fastify/test/types/request.tst.ts +199 -0
- package/node_modules/fastify/test/types/route.tst.ts +576 -0
- package/node_modules/fastify/test/types/{schema.test-d.ts → schema.tst.ts} +22 -22
- package/node_modules/fastify/test/types/{serverFactory.test-d.ts → serverFactory.tst.ts} +4 -4
- package/node_modules/fastify/test/types/tsconfig.json +9 -0
- package/node_modules/fastify/test/types/{type-provider.test-d.ts → type-provider.tst.ts} +256 -250
- package/node_modules/fastify/test/types/using.tst.ts +14 -0
- package/node_modules/fastify/types/errors.d.ts +3 -0
- package/node_modules/fastify/types/request.d.ts +23 -2
- package/node_modules/jishushell-panel/output/public/assets/{ApiKeyField-NKcbHjNz.js → ApiKeyField-Ce5d1xna.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{Dashboard-Da1fL38t.js → Dashboard-BXame3yg.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{HermesChatPanel-DZvmYsoh.js → HermesChatPanel-BHZtPCJd.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{HermesConfigForm-BLUWlKwm.js → HermesConfigForm-CB3GbNX9.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{InitPassword-BAKsshzk.js → InitPassword-Boab9F6g.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/InstanceDetail-DrIWCqo-.js +14 -0
- package/node_modules/jishushell-panel/output/public/assets/{Login-DHeOmwI8.js → Login-CzpOkNau.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/NewInstance-CANXyCcL.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{ProviderRecommendations-H0ByEYF0.js → ProviderRecommendations-BABo9VOC.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/Settings-CKp5XxFh.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/Setup-C7xVDPow.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{WeixinLoginPanel-D-T6BxkQ.js → WeixinLoginPanel-B765Xz4C.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{index-ERt6_ngA.js → index-Bs6DSbiR.js} +6 -6
- package/node_modules/jishushell-panel/output/public/assets/{registry-DF93EzIb.js → registry-sWIZsIEF.js} +2 -2
- package/node_modules/jishushell-panel/output/public/assets/{usePolling-DeoThIQn.js → usePolling-D4IDOQd_.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/vendor-i18n-Df8aUdv8.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{vendor-react-Cc84NArf.js → vendor-react-0L0rjmYG.js} +3 -3
- package/node_modules/jishushell-panel/output/public/index.html +3 -3
- package/node_modules/jishushell-panel/package.json +1 -1
- package/node_modules/semver/classes/range.js +6 -2
- package/node_modules/semver/package.json +1 -1
- package/package.json +4 -4
- package/scripts/check-app-spec.mjs +4 -12
- package/scripts/check-architecture-boundaries.mjs +178 -0
- package/scripts/pack-gui-and-send-pi.sh +5 -3
- package/dependencies/jishushell-panel-0.6.18.tgz +0 -0
- package/dist/services/connections/suggestions.d.ts +0 -27
- package/dist/services/connections/suggestions.js +0 -124
- package/dist/services/connections/suggestions.js.map +0 -1
- package/node_modules/fastify/test/types/content-type-parser.test-d.ts +0 -72
- package/node_modules/fastify/test/types/errors.test-d.ts +0 -90
- package/node_modules/fastify/test/types/fastify.test-d.ts +0 -352
- package/node_modules/fastify/test/types/hooks.test-d.ts +0 -550
- package/node_modules/fastify/test/types/import.ts +0 -2
- package/node_modules/fastify/test/types/instance.test-d.ts +0 -588
- package/node_modules/fastify/test/types/plugin.test-d.ts +0 -97
- package/node_modules/fastify/test/types/register.test-d.ts +0 -237
- package/node_modules/fastify/test/types/reply.test-d.ts +0 -254
- package/node_modules/fastify/test/types/request.test-d.ts +0 -188
- package/node_modules/fastify/test/types/route.test-d.ts +0 -553
- package/node_modules/fastify/test/types/using.test-d.ts +0 -17
- package/node_modules/jishushell-panel/output/public/assets/InstanceDetail-Dgyc_TX5.js +0 -14
- package/node_modules/jishushell-panel/output/public/assets/NewInstance-CIy0cYtp.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/Settings-DAT-UMfP.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/Setup-g3uckFYR.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/vendor-i18n-CS8DFbkQ.js +0 -1
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
import { AddressInfo } from 'node:net'
|
|
2
|
+
import { ConstraintStrategy, Config as FindMyWayConfig } from 'find-my-way'
|
|
3
|
+
import { expect } from 'tstyche'
|
|
4
|
+
import fastify, {
|
|
5
|
+
FastifyBaseLogger,
|
|
6
|
+
FastifyBodyParser,
|
|
7
|
+
FastifyError,
|
|
8
|
+
FastifyInstance,
|
|
9
|
+
FastifyListenOptions,
|
|
10
|
+
FastifyRouterOptions,
|
|
11
|
+
RawReplyDefaultExpression,
|
|
12
|
+
RawRequestDefaultExpression,
|
|
13
|
+
RawServerDefault,
|
|
14
|
+
RouteGenericInterface
|
|
15
|
+
} from '../../fastify.js'
|
|
16
|
+
import { HookHandlerDoneFunction } from '../../types/hooks.js'
|
|
17
|
+
import { FindMyWayVersion } from '../../types/instance.js'
|
|
18
|
+
import { Bindings, ChildLoggerOptions } from '../../types/logger.js'
|
|
19
|
+
import { FastifyReply } from '../../types/reply.js'
|
|
20
|
+
import { FastifyRequest } from '../../types/request.js'
|
|
21
|
+
import { FastifySchemaCompiler, FastifySchemaControllerOptions, FastifySerializerCompiler } from '../../types/schema.js'
|
|
22
|
+
|
|
23
|
+
const server = fastify()
|
|
24
|
+
|
|
25
|
+
expect(server.addSchema({ type: 'null' })).type.toBe<FastifyInstance>()
|
|
26
|
+
expect(server.addSchema({ schemaId: 'id' })).type.toBe<FastifyInstance>()
|
|
27
|
+
expect(server.addSchema({ schemas: [] })).type.toBe<FastifyInstance>()
|
|
28
|
+
|
|
29
|
+
expect(server.pluginName).type.toBe<string>()
|
|
30
|
+
|
|
31
|
+
expect(server.getSchemas()).type.toBe<Record<string, unknown>>()
|
|
32
|
+
expect(server.addresses()).type.toBe<AddressInfo[]>()
|
|
33
|
+
expect(server.getSchema('SchemaId')).type.toBe<unknown>()
|
|
34
|
+
expect(server.printRoutes()).type.toBe<string>()
|
|
35
|
+
expect(server.printPlugins()).type.toBe<string>()
|
|
36
|
+
expect(server.listeningOrigin).type.toBe<string>()
|
|
37
|
+
expect(server.supportedMethods).type.toBe<string[]>()
|
|
38
|
+
|
|
39
|
+
expect(
|
|
40
|
+
server.setErrorHandler(function (error, request, reply) {
|
|
41
|
+
expect(error).type.toBe<unknown>()
|
|
42
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
43
|
+
})
|
|
44
|
+
).type.toBe<FastifyInstance>()
|
|
45
|
+
|
|
46
|
+
expect(
|
|
47
|
+
server.setErrorHandler<FastifyError>(function (error, request, reply) {
|
|
48
|
+
expect(error).type.toBe<FastifyError>()
|
|
49
|
+
})
|
|
50
|
+
).type.toBe<FastifyInstance>()
|
|
51
|
+
|
|
52
|
+
expect(
|
|
53
|
+
server.setGenReqId(function (req) {
|
|
54
|
+
expect(req).type.toBe<RawRequestDefaultExpression>()
|
|
55
|
+
return 'foo'
|
|
56
|
+
})
|
|
57
|
+
).type.toBe<FastifyInstance>()
|
|
58
|
+
|
|
59
|
+
function fastifySetGenReqId (req: RawRequestDefaultExpression) {
|
|
60
|
+
return 'foo'
|
|
61
|
+
}
|
|
62
|
+
server.setGenReqId(fastifySetGenReqId)
|
|
63
|
+
|
|
64
|
+
function fastifyErrorHandler (this: FastifyInstance, error: FastifyError) { }
|
|
65
|
+
server.setErrorHandler(fastifyErrorHandler)
|
|
66
|
+
|
|
67
|
+
async function asyncFastifyErrorHandler (this: FastifyInstance, error: FastifyError) { }
|
|
68
|
+
server.setErrorHandler(asyncFastifyErrorHandler)
|
|
69
|
+
|
|
70
|
+
function nodeJSErrorHandler (error: NodeJS.ErrnoException) {
|
|
71
|
+
if (error) { throw error }
|
|
72
|
+
}
|
|
73
|
+
server.setErrorHandler(nodeJSErrorHandler)
|
|
74
|
+
|
|
75
|
+
function asyncNodeJSErrorHandler (error: NodeJS.ErrnoException) {
|
|
76
|
+
if (error) { throw error }
|
|
77
|
+
}
|
|
78
|
+
server.setErrorHandler(asyncNodeJSErrorHandler)
|
|
79
|
+
|
|
80
|
+
class CustomError extends Error {
|
|
81
|
+
private __brand: any
|
|
82
|
+
}
|
|
83
|
+
interface ReplyPayload {
|
|
84
|
+
Reply: {
|
|
85
|
+
test: boolean;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// typed sync error handler
|
|
89
|
+
server.setErrorHandler<CustomError, ReplyPayload>((error, request, reply) => {
|
|
90
|
+
expect(error).type.toBe<CustomError>()
|
|
91
|
+
expect(reply.send).type.toBe<((...args: [payload: ReplyPayload['Reply']]) => FastifyReply<ReplyPayload, RawServerDefault, RawRequestDefaultExpression<RawServerDefault>, RawReplyDefaultExpression<RawServerDefault>>)>()
|
|
92
|
+
})
|
|
93
|
+
// typed async error handler send
|
|
94
|
+
server.setErrorHandler<CustomError, ReplyPayload>(async (error, request, reply) => {
|
|
95
|
+
expect(error).type.toBe<CustomError>()
|
|
96
|
+
expect(reply.send).type.toBe<((...args: [payload: ReplyPayload['Reply']]) => FastifyReply<ReplyPayload, RawServerDefault, RawRequestDefaultExpression<RawServerDefault>, RawReplyDefaultExpression<RawServerDefault>>)>()
|
|
97
|
+
})
|
|
98
|
+
// typed async error handler return
|
|
99
|
+
server.setErrorHandler<CustomError, ReplyPayload>(async (error, request, reply) => {
|
|
100
|
+
expect(error).type.toBe<CustomError>()
|
|
101
|
+
return { test: true }
|
|
102
|
+
})
|
|
103
|
+
// typed sync error handler send error
|
|
104
|
+
server.setErrorHandler<CustomError, ReplyPayload>((error, request, reply) => {
|
|
105
|
+
expect(error).type.toBe<CustomError>()
|
|
106
|
+
// @ts-expect-error Type 'string' is not assignable to type 'boolean'.
|
|
107
|
+
reply.send({ test: 'foo' })
|
|
108
|
+
})
|
|
109
|
+
// typed sync error handler return error
|
|
110
|
+
server.setErrorHandler<CustomError, ReplyPayload>((error, request, reply) => {
|
|
111
|
+
expect(error).type.toBe<CustomError>()
|
|
112
|
+
return { test: 'foo' }
|
|
113
|
+
})
|
|
114
|
+
// typed async error handler send error
|
|
115
|
+
server.setErrorHandler<CustomError, ReplyPayload>(async (error, request, reply) => {
|
|
116
|
+
expect(error).type.toBe<CustomError>()
|
|
117
|
+
// @ts-expect-error Type 'string' is not assignable to type 'boolean'.
|
|
118
|
+
reply.send({ test: 'foo' })
|
|
119
|
+
})
|
|
120
|
+
// typed async error handler return error
|
|
121
|
+
server.setErrorHandler<CustomError, ReplyPayload>(async (error, request, reply) => {
|
|
122
|
+
expect(error).type.toBe<CustomError>()
|
|
123
|
+
return { test: 'foo' }
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
function notFoundHandler (request: FastifyRequest, reply: FastifyReply) { }
|
|
127
|
+
async function notFoundAsyncHandler (request: FastifyRequest, reply: FastifyReply) { }
|
|
128
|
+
function notFoundpreHandlerHandler (
|
|
129
|
+
request: FastifyRequest,
|
|
130
|
+
reply: FastifyReply,
|
|
131
|
+
done: HookHandlerDoneFunction
|
|
132
|
+
) { done() }
|
|
133
|
+
async function notFoundpreHandlerAsyncHandler (
|
|
134
|
+
request: FastifyRequest,
|
|
135
|
+
reply: FastifyReply
|
|
136
|
+
) { }
|
|
137
|
+
function notFoundpreValidationHandler (
|
|
138
|
+
request: FastifyRequest,
|
|
139
|
+
reply: FastifyReply,
|
|
140
|
+
done: HookHandlerDoneFunction
|
|
141
|
+
) { done() }
|
|
142
|
+
async function notFoundpreValidationAsyncHandler (
|
|
143
|
+
request: FastifyRequest,
|
|
144
|
+
reply: FastifyReply
|
|
145
|
+
) { }
|
|
146
|
+
|
|
147
|
+
server.setNotFoundHandler(notFoundHandler)
|
|
148
|
+
server.setNotFoundHandler({ preHandler: notFoundpreHandlerHandler }, notFoundHandler)
|
|
149
|
+
server.setNotFoundHandler({ preHandler: notFoundpreHandlerAsyncHandler }, notFoundHandler)
|
|
150
|
+
server.setNotFoundHandler({ preValidation: notFoundpreValidationHandler }, notFoundHandler)
|
|
151
|
+
server.setNotFoundHandler({ preValidation: notFoundpreValidationAsyncHandler }, notFoundHandler)
|
|
152
|
+
server.setNotFoundHandler(
|
|
153
|
+
{ preHandler: notFoundpreHandlerHandler, preValidation: notFoundpreValidationHandler },
|
|
154
|
+
notFoundHandler
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
server.setNotFoundHandler(notFoundAsyncHandler)
|
|
158
|
+
server.setNotFoundHandler({ preHandler: notFoundpreHandlerHandler }, notFoundAsyncHandler)
|
|
159
|
+
server.setNotFoundHandler({ preHandler: notFoundpreHandlerAsyncHandler }, notFoundAsyncHandler)
|
|
160
|
+
server.setNotFoundHandler({ preValidation: notFoundpreValidationHandler }, notFoundAsyncHandler)
|
|
161
|
+
server.setNotFoundHandler({ preValidation: notFoundpreValidationAsyncHandler }, notFoundAsyncHandler)
|
|
162
|
+
server.setNotFoundHandler(
|
|
163
|
+
{ preHandler: notFoundpreHandlerHandler, preValidation: notFoundpreValidationHandler },
|
|
164
|
+
notFoundAsyncHandler
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
server.setNotFoundHandler(function (_, reply) {
|
|
168
|
+
return reply.send('')
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
server.setSchemaController({
|
|
172
|
+
bucket: (parentSchemas) => {
|
|
173
|
+
expect(parentSchemas).type.toBe<unknown>()
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
add (schema) {
|
|
177
|
+
expect(schema).type.toBe<unknown>()
|
|
178
|
+
expect(server.addSchema({ type: 'null' })).type.toBe<FastifyInstance>()
|
|
179
|
+
return server.addSchema({ type: 'null' })
|
|
180
|
+
},
|
|
181
|
+
getSchema (schemaId) {
|
|
182
|
+
expect(schemaId).type.toBe<string>()
|
|
183
|
+
return server.getSchema('SchemaId')
|
|
184
|
+
},
|
|
185
|
+
getSchemas () {
|
|
186
|
+
expect(server.getSchemas()).type.toBe<Record<string, unknown>>()
|
|
187
|
+
return server.getSchemas()
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
function invalidSchemaController (schemaControllerOptions: FastifySchemaControllerOptions) { }
|
|
194
|
+
// @ts-expect-error Type '(schemaControllerOptions: FastifySchemaControllerOptions) => void' has no properties in common with type 'FastifySchemaControllerOptions'.
|
|
195
|
+
server.setSchemaController(invalidSchemaController)
|
|
196
|
+
|
|
197
|
+
server.setReplySerializer(function (payload, statusCode) {
|
|
198
|
+
expect(payload).type.toBe<unknown>()
|
|
199
|
+
expect(statusCode).type.toBe<number>()
|
|
200
|
+
return 'serialized'
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
function invalidReplySerializer (payload: number, statusCode: string) { }
|
|
204
|
+
// @ts-expect-error Argument of type '(payload: number, statusCode: string) => void' is not assignable to parameter of type '(payload: unknown, statusCode: number) => string'.
|
|
205
|
+
server.setReplySerializer(invalidReplySerializer)
|
|
206
|
+
|
|
207
|
+
function serializerWithInvalidReturn (payload: unknown, statusCode: number) { }
|
|
208
|
+
// @ts-expect-error Argument of type '(payload: unknown, statusCode: number) => void' is not assignable to parameter of type '(payload: unknown, statusCode: number) => string'.
|
|
209
|
+
server.setReplySerializer(serializerWithInvalidReturn)
|
|
210
|
+
|
|
211
|
+
function invalidSchemaErrorFormatter (err: Error) {
|
|
212
|
+
if (err) { throw err }
|
|
213
|
+
}
|
|
214
|
+
// @ts-expect-error Argument of type '(err: Error) => void' is not assignable to parameter of type 'SchemaErrorFormatter'.
|
|
215
|
+
server.setSchemaErrorFormatter(invalidSchemaErrorFormatter)
|
|
216
|
+
|
|
217
|
+
expect(server.addHttpMethod('SEARCH', { hasBody: true })).type.toBe<FastifyInstance>()
|
|
218
|
+
|
|
219
|
+
// test listen opts objects
|
|
220
|
+
const options: FastifyListenOptions = {}
|
|
221
|
+
|
|
222
|
+
expect(server.listen()).type.toBe<Promise<string>>()
|
|
223
|
+
expect(server.listen(options)).type.toBe<Promise<string>>()
|
|
224
|
+
expect(server.listen({ port: 3000 })).type.toBe<Promise<string>>()
|
|
225
|
+
expect(server.listen({ port: 3000, listenTextResolver: (address) => { return `address: ${address}` } })).type.toBe<Promise<string>>()
|
|
226
|
+
expect(server.listen({ port: 3000, host: '0.0.0.0' })).type.toBe<Promise<string>>()
|
|
227
|
+
expect(server.listen({ port: 3000, host: '0.0.0.0', backlog: 42 })).type.toBe<Promise<string>>()
|
|
228
|
+
expect(server.listen({ port: 3000, host: '0.0.0.0', backlog: 42, exclusive: true })).type.toBe<Promise<string>>()
|
|
229
|
+
expect(server.listen({ port: 3000, host: '::/0', ipv6Only: true })).type.toBe<Promise<string>>()
|
|
230
|
+
|
|
231
|
+
expect(server.listen(() => { })).type.toBe<void>()
|
|
232
|
+
expect(server.listen({ port: 3000 }, () => { })).type.toBe<void>()
|
|
233
|
+
expect(server.listen({ port: 3000, listenTextResolver: (address) => { return `address: ${address}` } }, () => { })).type.toBe<void>()
|
|
234
|
+
expect(server.listen({ port: 3000, host: '0.0.0.0' }, () => { })).type.toBe<void>()
|
|
235
|
+
expect(server.listen({ port: 3000, host: '0.0.0.0', backlog: 42 }, () => { })).type.toBe<void>()
|
|
236
|
+
expect(server.listen({ port: 3000, host: '0.0.0.0', backlog: 42, exclusive: true }, () => { })).type.toBe<void>()
|
|
237
|
+
expect(server.listen({ port: 3000, host: '::/0', ipv6Only: true }, () => { })).type.toBe<void>()
|
|
238
|
+
|
|
239
|
+
// test after method
|
|
240
|
+
expect(server.after()).type.toBeAssignableTo<FastifyInstance>()
|
|
241
|
+
expect(server.after((err) => {
|
|
242
|
+
expect(err).type.toBe<Error | null>()
|
|
243
|
+
})).type.toBeAssignableTo<FastifyInstance>()
|
|
244
|
+
|
|
245
|
+
// test ready method
|
|
246
|
+
expect(server.ready()).type.toBeAssignableTo<FastifyInstance>()
|
|
247
|
+
expect(server.ready((err) => {
|
|
248
|
+
expect(err).type.toBe<Error | null>()
|
|
249
|
+
})).type.toBeAssignableTo<FastifyInstance>()
|
|
250
|
+
expect(server.ready(async (err) => {
|
|
251
|
+
expect(err).type.toBe<Error | null>()
|
|
252
|
+
})).type.toBeAssignableTo<FastifyInstance>()
|
|
253
|
+
|
|
254
|
+
expect(server.routing({} as RawRequestDefaultExpression, {} as RawReplyDefaultExpression)).type.toBe<void>()
|
|
255
|
+
|
|
256
|
+
expect(fastify().get<RouteGenericInterface, { contextKey: string }>('/', {
|
|
257
|
+
handler: () => { },
|
|
258
|
+
errorHandler: (error, request, reply) => {
|
|
259
|
+
expect(error).type.toBe<FastifyError>()
|
|
260
|
+
expect(request).type.toBeAssignableTo<FastifyRequest>()
|
|
261
|
+
expect(request.routeOptions.config).type.toBeAssignableTo<{ contextKey: string }>()
|
|
262
|
+
expect(reply).type.toBeAssignableTo<FastifyReply>()
|
|
263
|
+
expect(server.errorHandler(error, request, reply)).type.toBe<void>()
|
|
264
|
+
}
|
|
265
|
+
})).type.toBe<FastifyInstance>()
|
|
266
|
+
|
|
267
|
+
expect(fastify().get('/', {
|
|
268
|
+
handler: () => { },
|
|
269
|
+
childLoggerFactory: (logger, bindings, opts, req) => {
|
|
270
|
+
expect(server.childLoggerFactory(logger, bindings, opts, req)).type.toBe<FastifyBaseLogger>()
|
|
271
|
+
return server.childLoggerFactory(logger, bindings, opts, req)
|
|
272
|
+
}
|
|
273
|
+
})).type.toBe<FastifyInstance>()
|
|
274
|
+
|
|
275
|
+
expect(
|
|
276
|
+
server.setChildLoggerFactory(function (logger, bindings, opts, req) {
|
|
277
|
+
expect(logger).type.toBe<FastifyBaseLogger>()
|
|
278
|
+
expect(bindings).type.toBe<Bindings>()
|
|
279
|
+
expect(opts).type.toBe<ChildLoggerOptions>()
|
|
280
|
+
expect(req).type.toBe<RawRequestDefaultExpression>()
|
|
281
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
282
|
+
return logger.child(bindings, opts)
|
|
283
|
+
})
|
|
284
|
+
).type.toBe<FastifyInstance>()
|
|
285
|
+
|
|
286
|
+
expect(
|
|
287
|
+
server.setErrorHandler<FastifyError>(function (error, request, reply) {
|
|
288
|
+
expect(error).type.toBe<FastifyError>()
|
|
289
|
+
})
|
|
290
|
+
).type.toBe<FastifyInstance>()
|
|
291
|
+
|
|
292
|
+
function childLoggerFactory (
|
|
293
|
+
this: FastifyInstance,
|
|
294
|
+
logger: FastifyBaseLogger,
|
|
295
|
+
bindings: Bindings,
|
|
296
|
+
opts: ChildLoggerOptions,
|
|
297
|
+
req: RawRequestDefaultExpression
|
|
298
|
+
) {
|
|
299
|
+
return logger.child(bindings, opts)
|
|
300
|
+
}
|
|
301
|
+
server.setChildLoggerFactory(childLoggerFactory)
|
|
302
|
+
server.setChildLoggerFactory(server.childLoggerFactory)
|
|
303
|
+
|
|
304
|
+
type InitialConfig = Readonly<{
|
|
305
|
+
connectionTimeout?: number,
|
|
306
|
+
keepAliveTimeout?: number,
|
|
307
|
+
bodyLimit?: number,
|
|
308
|
+
caseSensitive?: boolean,
|
|
309
|
+
allowUnsafeRegex?: boolean,
|
|
310
|
+
forceCloseConnections?: boolean,
|
|
311
|
+
http2?: boolean,
|
|
312
|
+
https?: boolean | Readonly<{ allowHTTP1: boolean }>,
|
|
313
|
+
ignoreTrailingSlash?: boolean,
|
|
314
|
+
ignoreDuplicateSlashes?: boolean,
|
|
315
|
+
disableRequestLogging?: boolean | ((req: FastifyRequest) => boolean),
|
|
316
|
+
maxParamLength?: number,
|
|
317
|
+
onProtoPoisoning?: 'error' | 'remove' | 'ignore',
|
|
318
|
+
onConstructorPoisoning?: 'error' | 'remove' | 'ignore',
|
|
319
|
+
pluginTimeout?: number,
|
|
320
|
+
requestIdHeader?: string | false,
|
|
321
|
+
requestIdLogLabel?: string,
|
|
322
|
+
http2SessionTimeout?: number,
|
|
323
|
+
useSemicolonDelimiter?: boolean,
|
|
324
|
+
routerOptions?: FastifyRouterOptions<RawServerDefault>
|
|
325
|
+
}>
|
|
326
|
+
|
|
327
|
+
expect(fastify().initialConfig).type.toBe<InitialConfig>()
|
|
328
|
+
|
|
329
|
+
expect<FastifyRouterOptions<RawServerDefault>>().type.toBeAssignableTo<
|
|
330
|
+
FindMyWayConfig<FindMyWayVersion<RawServerDefault>>
|
|
331
|
+
>()
|
|
332
|
+
|
|
333
|
+
fastify({
|
|
334
|
+
routerOptions: {
|
|
335
|
+
defaultRoute: (req, res) => {
|
|
336
|
+
expect(req).type.toBe<RawRequestDefaultExpression<RawServerDefault>>()
|
|
337
|
+
expect(res).type.toBe<RawReplyDefaultExpression<RawServerDefault>>()
|
|
338
|
+
expect(res).type.not.toBeAssignableTo<FastifyReply>()
|
|
339
|
+
res.end('foo')
|
|
340
|
+
},
|
|
341
|
+
onBadUrl: (path, req, res) => {
|
|
342
|
+
expect(path).type.toBe<string>()
|
|
343
|
+
expect(req).type.toBe<RawRequestDefaultExpression<RawServerDefault>>()
|
|
344
|
+
expect(res).type.toBe<RawReplyDefaultExpression<RawServerDefault>>()
|
|
345
|
+
expect(res).type.not.toBeAssignableTo<FastifyReply>()
|
|
346
|
+
res.end('foo')
|
|
347
|
+
},
|
|
348
|
+
onMaxParamLength (path, req, res) {
|
|
349
|
+
expect(path).type.toBe<string>()
|
|
350
|
+
expect(req).type.toBe<RawRequestDefaultExpression<RawServerDefault>>()
|
|
351
|
+
expect(res).type.toBe<RawReplyDefaultExpression<RawServerDefault>>()
|
|
352
|
+
expect(res).type.not.toBeAssignableTo<FastifyReply>()
|
|
353
|
+
res.end('foo')
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
expect(server.defaultTextParser).type.toBe<FastifyBodyParser<string>>()
|
|
359
|
+
|
|
360
|
+
expect(server.getDefaultJsonParser('ignore', 'error')).type.toBe<FastifyBodyParser<string>>()
|
|
361
|
+
|
|
362
|
+
expect(server.printRoutes({ includeHooks: true, commonPrefix: false, includeMeta: true })).type.toBe<string>()
|
|
363
|
+
|
|
364
|
+
expect(server.printRoutes({ includeMeta: ['key1', Symbol('key2')] })).type.toBe<string>()
|
|
365
|
+
|
|
366
|
+
expect(server.printRoutes({ method: 'GET' })).type.toBe<string>()
|
|
367
|
+
|
|
368
|
+
expect(server.printRoutes()).type.toBe<string>()
|
|
369
|
+
|
|
370
|
+
server.decorate<(x: string) => void>('test', function (x: string): void {
|
|
371
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
372
|
+
})
|
|
373
|
+
server.decorate('test', function (x: string): void {
|
|
374
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
375
|
+
})
|
|
376
|
+
server.decorate<string>('test', {
|
|
377
|
+
getter () {
|
|
378
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
379
|
+
return 'foo'
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
server.decorate<string>('test', {
|
|
383
|
+
getter () {
|
|
384
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
385
|
+
return 'foo'
|
|
386
|
+
},
|
|
387
|
+
setter (x) {
|
|
388
|
+
expect(x).type.toBe<string>()
|
|
389
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
server.decorate('test')
|
|
393
|
+
server.decorate('test', null, ['foo'])
|
|
394
|
+
|
|
395
|
+
server.decorateRequest<(x: string, y: number) => void>('test', function (x: string, y: number): void {
|
|
396
|
+
expect(this).type.toBe<FastifyRequest>()
|
|
397
|
+
})
|
|
398
|
+
server.decorateRequest('test', function (x: string, y: number): void {
|
|
399
|
+
expect(this).type.toBe<FastifyRequest>()
|
|
400
|
+
})
|
|
401
|
+
server.decorateRequest('test')
|
|
402
|
+
server.decorateRequest('test', null, ['foo'])
|
|
403
|
+
|
|
404
|
+
server.decorateReply<(x: string) => void>('test', function (x: string): void {
|
|
405
|
+
expect(this).type.toBe<FastifyReply>()
|
|
406
|
+
})
|
|
407
|
+
server.decorateReply('test', function (x: string): void {
|
|
408
|
+
expect(this).type.toBe<FastifyReply>()
|
|
409
|
+
})
|
|
410
|
+
server.decorateReply('test')
|
|
411
|
+
server.decorateReply('test', null, ['foo'])
|
|
412
|
+
|
|
413
|
+
// @ts-expect-error Argument of type 'boolean' is not assignable to parameter of type 'GetterSetter...'.
|
|
414
|
+
server.decorate<string>('test', true)
|
|
415
|
+
// @ts-expect-error Type 'string' is not assignable to type 'number'.
|
|
416
|
+
server.decorate<(myNumber: number) => number>('test', function (myNumber: number): string {
|
|
417
|
+
return ''
|
|
418
|
+
})
|
|
419
|
+
server.decorate<string>('test', {
|
|
420
|
+
// @ts-expect-error Type 'boolean' is not assignable to type 'string'.
|
|
421
|
+
getter () {
|
|
422
|
+
return true
|
|
423
|
+
}
|
|
424
|
+
})
|
|
425
|
+
// @ts-expect-error Property 'getter' is missing in type
|
|
426
|
+
server.decorate<string>('test', {
|
|
427
|
+
setter (x) { }
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
declare module '../../fastify' {
|
|
431
|
+
interface FastifyInstance {
|
|
432
|
+
typedTestProperty: boolean
|
|
433
|
+
typedTestPropertyGetterSetter: string
|
|
434
|
+
typedTestMethod(x: string): string
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
interface FastifyRequest {
|
|
438
|
+
typedTestRequestProperty: boolean
|
|
439
|
+
typedTestRequestPropertyGetterSetter: string
|
|
440
|
+
typedTestRequestMethod(x: string): string
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
interface FastifyReply {
|
|
444
|
+
typedTestReplyProperty: boolean
|
|
445
|
+
typedTestReplyPropertyGetterSetter: string
|
|
446
|
+
typedTestReplyMethod(x: string): string
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
server.decorate('typedTestProperty', false)
|
|
451
|
+
server.decorate('typedTestProperty', {
|
|
452
|
+
getter () {
|
|
453
|
+
return false
|
|
454
|
+
}
|
|
455
|
+
})
|
|
456
|
+
server.decorate('typedTestProperty', {
|
|
457
|
+
getter (): boolean {
|
|
458
|
+
return true
|
|
459
|
+
},
|
|
460
|
+
setter (x) {
|
|
461
|
+
expect(x).type.toBe<boolean>()
|
|
462
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
463
|
+
}
|
|
464
|
+
})
|
|
465
|
+
server.decorate('typedTestProperty')
|
|
466
|
+
server.decorate('typedTestProperty', null, ['foo'])
|
|
467
|
+
expect(server.decorate).type.not.toBeCallableWith('typedTestProperty', null)
|
|
468
|
+
expect(server.decorate).type.not.toBeCallableWith('typedTestProperty', 'foo')
|
|
469
|
+
expect(server.decorate).type.not.toBeCallableWith('typedTestProperty', {
|
|
470
|
+
getter () {
|
|
471
|
+
return 'foo'
|
|
472
|
+
}
|
|
473
|
+
})
|
|
474
|
+
server.decorate('typedTestMethod', function (x) {
|
|
475
|
+
expect(x).type.toBe<string>()
|
|
476
|
+
expect(this).type.toBe<FastifyInstance>()
|
|
477
|
+
return 'foo'
|
|
478
|
+
})
|
|
479
|
+
server.decorate('typedTestMethod', x => x)
|
|
480
|
+
// @ts-expect-error Type 'string' is not assignable to type 'boolean'.
|
|
481
|
+
server.decorate('typedTestMethod', function (x: boolean) {
|
|
482
|
+
return 'foo'
|
|
483
|
+
})
|
|
484
|
+
// @ts-expect-error Type 'boolean' is not assignable to type 'string'.
|
|
485
|
+
server.decorate('typedTestMethod', function () {
|
|
486
|
+
return true
|
|
487
|
+
})
|
|
488
|
+
// @ts-expect-error Type 'Promise<string>' is not assignable to type 'string'.
|
|
489
|
+
server.decorate('typedTestMethod', async function () {
|
|
490
|
+
return 'foo'
|
|
491
|
+
})
|
|
492
|
+
|
|
493
|
+
server.decorateRequest('typedTestRequestProperty', false)
|
|
494
|
+
server.decorateRequest('typedTestRequestProperty', {
|
|
495
|
+
getter () {
|
|
496
|
+
return false
|
|
497
|
+
}
|
|
498
|
+
})
|
|
499
|
+
server.decorateRequest('typedTestRequestProperty', {
|
|
500
|
+
getter (): boolean {
|
|
501
|
+
return true
|
|
502
|
+
},
|
|
503
|
+
setter (x) {
|
|
504
|
+
expect(x).type.toBe<boolean>()
|
|
505
|
+
expect(this).type.toBe<FastifyRequest>()
|
|
506
|
+
}
|
|
507
|
+
})
|
|
508
|
+
server.decorateRequest('typedTestRequestProperty')
|
|
509
|
+
server.decorateRequest('typedTestRequestProperty', null, ['foo'])
|
|
510
|
+
expect(server.decorateRequest).type.not.toBeCallableWith('typedTestRequestProperty', null)
|
|
511
|
+
expect(server.decorateRequest).type.not.toBeCallableWith('typedTestRequestProperty', 'foo')
|
|
512
|
+
expect(server.decorateRequest).type.not.toBeCallableWith('typedTestRequestProperty', {
|
|
513
|
+
getter () {
|
|
514
|
+
return 'foo'
|
|
515
|
+
}
|
|
516
|
+
})
|
|
517
|
+
server.decorateRequest('typedTestRequestMethod', function (x) {
|
|
518
|
+
expect(x).type.toBe<string>()
|
|
519
|
+
expect(this).type.toBe<FastifyRequest>()
|
|
520
|
+
return 'foo'
|
|
521
|
+
})
|
|
522
|
+
server.decorateRequest('typedTestRequestMethod', x => x)
|
|
523
|
+
// @ts-expect-error Type 'string' is not assignable to type 'boolean'.
|
|
524
|
+
server.decorateRequest('typedTestRequestMethod', function (x: boolean) {
|
|
525
|
+
return 'foo'
|
|
526
|
+
})
|
|
527
|
+
// @ts-expect-error Type 'boolean' is not assignable to type 'string'.
|
|
528
|
+
server.decorateRequest('typedTestRequestMethod', function () {
|
|
529
|
+
return true
|
|
530
|
+
})
|
|
531
|
+
// @ts-expect-error Type 'Promise<string>' is not assignable to type 'string'.
|
|
532
|
+
server.decorateRequest('typedTestRequestMethod', async function () {
|
|
533
|
+
return 'foo'
|
|
534
|
+
})
|
|
535
|
+
|
|
536
|
+
server.decorateReply('typedTestReplyProperty', false)
|
|
537
|
+
server.decorateReply('typedTestReplyProperty', {
|
|
538
|
+
getter () {
|
|
539
|
+
return false
|
|
540
|
+
}
|
|
541
|
+
})
|
|
542
|
+
server.decorateReply('typedTestReplyProperty', {
|
|
543
|
+
getter (): boolean {
|
|
544
|
+
return true
|
|
545
|
+
},
|
|
546
|
+
setter (x) {
|
|
547
|
+
expect(x).type.toBe<boolean>()
|
|
548
|
+
expect(this).type.toBe<FastifyReply>()
|
|
549
|
+
}
|
|
550
|
+
})
|
|
551
|
+
server.decorateReply('typedTestReplyProperty')
|
|
552
|
+
server.decorateReply('typedTestReplyProperty', null, ['foo'])
|
|
553
|
+
expect(server.decorateReply).type.not.toBeCallableWith('typedTestReplyProperty', null)
|
|
554
|
+
expect(server.decorateReply).type.not.toBeCallableWith('typedTestReplyProperty', 'foo')
|
|
555
|
+
expect(server.decorateReply).type.not.toBeCallableWith('typedTestReplyProperty', {
|
|
556
|
+
getter () {
|
|
557
|
+
return 'foo'
|
|
558
|
+
}
|
|
559
|
+
})
|
|
560
|
+
server.decorateReply('typedTestReplyMethod', function (x) {
|
|
561
|
+
expect(x).type.toBe<string>()
|
|
562
|
+
expect(this).type.toBe<FastifyReply>()
|
|
563
|
+
return 'foo'
|
|
564
|
+
})
|
|
565
|
+
server.decorateReply('typedTestReplyMethod', x => x)
|
|
566
|
+
// @ts-expect-error Type 'string' is not assignable to type 'boolean'
|
|
567
|
+
server.decorateReply('typedTestReplyMethod', function (x: boolean) {
|
|
568
|
+
return 'foo'
|
|
569
|
+
})
|
|
570
|
+
// @ts-expect-error Type 'boolean' is not assignable to type 'string'
|
|
571
|
+
server.decorateReply('typedTestReplyMethod', function (x) {
|
|
572
|
+
return true
|
|
573
|
+
})
|
|
574
|
+
// @ts-expect-error Type 'Promise<string>' is not assignable to type 'string'.
|
|
575
|
+
server.decorateReply('typedTestReplyMethod', async function () {
|
|
576
|
+
return 'foo'
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
const foo = server.getDecorator<string>('foo')
|
|
580
|
+
expect(foo).type.toBe<string>()
|
|
581
|
+
|
|
582
|
+
const versionConstraintStrategy: ConstraintStrategy<FindMyWayVersion<RawServerDefault>> = {
|
|
583
|
+
name: 'version',
|
|
584
|
+
storage: () => ({
|
|
585
|
+
get: () => () => { },
|
|
586
|
+
set: () => { },
|
|
587
|
+
del: () => { },
|
|
588
|
+
empty: () => { }
|
|
589
|
+
}),
|
|
590
|
+
validate () { },
|
|
591
|
+
deriveConstraint: () => 'foo'
|
|
592
|
+
}
|
|
593
|
+
expect(server.addConstraintStrategy(versionConstraintStrategy)).type.toBe<void>()
|
|
594
|
+
expect(server.hasConstraintStrategy(versionConstraintStrategy.name)).type.toBe<boolean>()
|
|
595
|
+
|
|
596
|
+
expect(server.validatorCompiler).type.toBe<FastifySchemaCompiler<any> | undefined>()
|
|
597
|
+
expect(server.serializerCompiler).type.toBe<FastifySerializerCompiler<any> | undefined>()
|