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
|
@@ -40,93 +40,93 @@ const asInteger = serializer.asInteger.bind(serializer)
|
|
|
40
40
|
const JSON_STR_NULL = 'null'
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const obj = (input && typeof input.toJSON === 'function')
|
|
43
|
+
// #
|
|
44
|
+
function anonymous0 (input) {
|
|
45
|
+
const obj = (input && typeof input.toJSON === 'function')
|
|
47
46
|
? input.toJSON()
|
|
48
47
|
: input
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
if (obj === null) return JSON_STR_EMPTY_OBJECT
|
|
50
|
+
let json = ''
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
let addComma = false
|
|
52
|
+
json += JSON_STR_BEGIN_OBJECT
|
|
53
|
+
let addComma_0 = false
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const value_statusCode_1 = obj["statusCode"]
|
|
56
|
+
if (value_statusCode_1 !== undefined) {
|
|
57
|
+
!addComma_0 && (addComma_0 = true) || (json += JSON_STR_COMMA)
|
|
58
|
+
json += "\"statusCode\":"
|
|
59
|
+
json += asNumber(value_statusCode_1)
|
|
60
|
+
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (typeof
|
|
69
|
-
if (
|
|
62
|
+
const value_code_2 = obj["code"]
|
|
63
|
+
if (value_code_2 !== undefined) {
|
|
64
|
+
!addComma_0 && (addComma_0 = true) || (json += JSON_STR_COMMA)
|
|
65
|
+
json += "\"code\":"
|
|
66
|
+
|
|
67
|
+
if (typeof value_code_2 !== 'string') {
|
|
68
|
+
if (value_code_2 === null) {
|
|
70
69
|
json += JSON_STR_EMPTY_STRING
|
|
71
|
-
} else if (
|
|
72
|
-
json += JSON_STR_QUOTE +
|
|
73
|
-
} else if (
|
|
74
|
-
json += asString(
|
|
70
|
+
} else if (value_code_2 instanceof Date) {
|
|
71
|
+
json += JSON_STR_QUOTE + value_code_2.toISOString() + JSON_STR_QUOTE
|
|
72
|
+
} else if (value_code_2 instanceof RegExp) {
|
|
73
|
+
json += asString(value_code_2.source)
|
|
75
74
|
} else {
|
|
76
|
-
json += asString(
|
|
75
|
+
json += asString(value_code_2.toString())
|
|
77
76
|
}
|
|
78
77
|
} else {
|
|
79
|
-
json += asString(
|
|
78
|
+
json += asString(value_code_2)
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
}
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (typeof
|
|
90
|
-
if (
|
|
83
|
+
const value_error_3 = obj["error"]
|
|
84
|
+
if (value_error_3 !== undefined) {
|
|
85
|
+
!addComma_0 && (addComma_0 = true) || (json += JSON_STR_COMMA)
|
|
86
|
+
json += "\"error\":"
|
|
87
|
+
|
|
88
|
+
if (typeof value_error_3 !== 'string') {
|
|
89
|
+
if (value_error_3 === null) {
|
|
91
90
|
json += JSON_STR_EMPTY_STRING
|
|
92
|
-
} else if (
|
|
93
|
-
json += JSON_STR_QUOTE +
|
|
94
|
-
} else if (
|
|
95
|
-
json += asString(
|
|
91
|
+
} else if (value_error_3 instanceof Date) {
|
|
92
|
+
json += JSON_STR_QUOTE + value_error_3.toISOString() + JSON_STR_QUOTE
|
|
93
|
+
} else if (value_error_3 instanceof RegExp) {
|
|
94
|
+
json += asString(value_error_3.source)
|
|
96
95
|
} else {
|
|
97
|
-
json += asString(
|
|
96
|
+
json += asString(value_error_3.toString())
|
|
98
97
|
}
|
|
99
98
|
} else {
|
|
100
|
-
json += asString(
|
|
99
|
+
json += asString(value_error_3)
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
|
|
102
|
+
}
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (typeof
|
|
111
|
-
if (
|
|
104
|
+
const value_message_4 = obj["message"]
|
|
105
|
+
if (value_message_4 !== undefined) {
|
|
106
|
+
!addComma_0 && (addComma_0 = true) || (json += JSON_STR_COMMA)
|
|
107
|
+
json += "\"message\":"
|
|
108
|
+
|
|
109
|
+
if (typeof value_message_4 !== 'string') {
|
|
110
|
+
if (value_message_4 === null) {
|
|
112
111
|
json += JSON_STR_EMPTY_STRING
|
|
113
|
-
} else if (
|
|
114
|
-
json += JSON_STR_QUOTE +
|
|
115
|
-
} else if (
|
|
116
|
-
json += asString(
|
|
112
|
+
} else if (value_message_4 instanceof Date) {
|
|
113
|
+
json += JSON_STR_QUOTE + value_message_4.toISOString() + JSON_STR_QUOTE
|
|
114
|
+
} else if (value_message_4 instanceof RegExp) {
|
|
115
|
+
json += asString(value_message_4.source)
|
|
117
116
|
} else {
|
|
118
|
-
json += asString(
|
|
117
|
+
json += asString(value_message_4.toString())
|
|
119
118
|
}
|
|
120
119
|
} else {
|
|
121
|
-
json += asString(
|
|
120
|
+
json += asString(value_message_4)
|
|
122
121
|
}
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
}
|
|
125
124
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
125
|
+
json += JSON_STR_END_OBJECT
|
|
129
126
|
|
|
127
|
+
return json
|
|
128
|
+
}
|
|
129
|
+
|
|
130
130
|
const main = anonymous0
|
|
131
131
|
return main
|
|
132
132
|
|
|
@@ -364,6 +364,12 @@ const codes = {
|
|
|
364
364
|
400,
|
|
365
365
|
URIError
|
|
366
366
|
),
|
|
367
|
+
FST_ERR_MAX_PARAM_LENGTH: createError(
|
|
368
|
+
'FST_ERR_MAX_PARAM_LENGTH',
|
|
369
|
+
"'%s' is exceeding the max param length",
|
|
370
|
+
414,
|
|
371
|
+
URIError
|
|
372
|
+
),
|
|
367
373
|
FST_ERR_ASYNC_CONSTRAINT: createError(
|
|
368
374
|
'FST_ERR_ASYNC_CONSTRAINT',
|
|
369
375
|
'Unexpected error from async constraint',
|
|
@@ -408,6 +414,12 @@ const codes = {
|
|
|
408
414
|
'%s method is not supported.',
|
|
409
415
|
500
|
|
410
416
|
),
|
|
417
|
+
FST_ERR_ROUTE_LOG_LEVEL_INVALID: createError(
|
|
418
|
+
'FST_ERR_ROUTE_LOG_LEVEL_INVALID',
|
|
419
|
+
"Log level for '%s:%s' route must be a valid logger level. Received: '%s'",
|
|
420
|
+
500,
|
|
421
|
+
TypeError
|
|
422
|
+
),
|
|
411
423
|
FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED: createError(
|
|
412
424
|
'FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED',
|
|
413
425
|
'Body validation schema for %s:%s route is not supported!',
|
|
@@ -470,7 +482,10 @@ const codes = {
|
|
|
470
482
|
500,
|
|
471
483
|
TypeError
|
|
472
484
|
),
|
|
473
|
-
|
|
485
|
+
FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED: createError(
|
|
486
|
+
'FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED',
|
|
487
|
+
"The dependency '%s' of plugin '%s' is not registered"
|
|
488
|
+
),
|
|
474
489
|
/**
|
|
475
490
|
* Avvio Errors
|
|
476
491
|
*/
|
|
@@ -32,8 +32,12 @@ function fourOhFour (options) {
|
|
|
32
32
|
const { logger, disableRequestLogging } = options
|
|
33
33
|
|
|
34
34
|
// 404 router, used for handling encapsulated 404 handlers
|
|
35
|
-
const router = FindMyWay({
|
|
36
|
-
|
|
35
|
+
const router = FindMyWay({
|
|
36
|
+
onBadUrl: createRouteEventHandler(),
|
|
37
|
+
onMaxParamLength: createRouteEventHandler(),
|
|
38
|
+
defaultRoute: fourOhFourFallBack
|
|
39
|
+
})
|
|
40
|
+
let _routeEventHandler = null
|
|
37
41
|
|
|
38
42
|
return { router, setNotFoundHandler, setContext, arrange404 }
|
|
39
43
|
|
|
@@ -43,6 +47,7 @@ function fourOhFour (options) {
|
|
|
43
47
|
instance[kCanSetNotFoundHandler] = true
|
|
44
48
|
// we need to bind instance for the context
|
|
45
49
|
router.onBadUrl = router.onBadUrl.bind(instance)
|
|
50
|
+
router.onMaxParamLength = router.onMaxParamLength.bind(instance)
|
|
46
51
|
router.defaultRoute = router.defaultRoute.bind(instance)
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -60,15 +65,15 @@ function fourOhFour (options) {
|
|
|
60
65
|
})
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
function
|
|
64
|
-
return function
|
|
68
|
+
function createRouteEventHandler () {
|
|
69
|
+
return function onRouteEvent (path, req, res) {
|
|
65
70
|
const fourOhFourContext = this[kFourOhFourLevelInstance][kFourOhFourContext]
|
|
66
71
|
const id = getGenReqId(fourOhFourContext.server, req)
|
|
67
72
|
const childLogger = createChildLogger(fourOhFourContext, logger, req, id)
|
|
68
73
|
const request = new Request(id, null, req, null, childLogger, fourOhFourContext)
|
|
69
74
|
const reply = new Reply(res, request, childLogger)
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
_routeEventHandler(request, reply)
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
79
|
|
|
@@ -121,12 +126,12 @@ function fourOhFour (options) {
|
|
|
121
126
|
if (handler) {
|
|
122
127
|
this[kFourOhFourLevelInstance][kCanSetNotFoundHandler] = false
|
|
123
128
|
handler = handler.bind(this)
|
|
124
|
-
// update
|
|
125
|
-
|
|
129
|
+
// update route event handler
|
|
130
|
+
_routeEventHandler = handler
|
|
126
131
|
} else {
|
|
127
132
|
handler = basic404
|
|
128
|
-
// update
|
|
129
|
-
|
|
133
|
+
// update route event handler
|
|
134
|
+
_routeEventHandler = basic404
|
|
130
135
|
}
|
|
131
136
|
|
|
132
137
|
this.after((notHandledErr, done) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const diagnostics = require('node:diagnostics_channel')
|
|
4
|
-
const ContentType = require('./content-type')
|
|
5
4
|
const wrapThenable = require('./wrap-thenable')
|
|
6
5
|
const { validate: validateSchema } = require('./validation')
|
|
7
6
|
const { preValidationHookRunner, preHandlerHookRunner } = require('./hooks')
|
|
@@ -11,7 +10,9 @@ const {
|
|
|
11
10
|
kReplyIsError,
|
|
12
11
|
kRouteContext,
|
|
13
12
|
kFourOhFourContext,
|
|
14
|
-
kSupportedHTTPMethods
|
|
13
|
+
kSupportedHTTPMethods,
|
|
14
|
+
kRequestContentType,
|
|
15
|
+
kDiagnosticsStore
|
|
15
16
|
} = require('./symbols')
|
|
16
17
|
|
|
17
18
|
const channels = diagnostics.tracingChannel('fastify.request.handler')
|
|
@@ -51,13 +52,17 @@ function handleRequest (err, request, reply) {
|
|
|
51
52
|
return
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
// Conditional assignment to avoid creating a new ContentType instance
|
|
56
|
+
// It can be assigned when accessing the .mediaType in hooks
|
|
57
|
+
if (!request[kRequestContentType]) {
|
|
58
|
+
request[kRequestContentType] = request[kRouteContext].contentTypeParser.getContentType(ctHeader)
|
|
59
|
+
}
|
|
60
|
+
if (request[kRequestContentType].isValid === false) {
|
|
56
61
|
reply[kReplyIsError] = true
|
|
57
62
|
reply.status(415).send(new FST_ERR_CTP_INVALID_MEDIA_TYPE())
|
|
58
63
|
return
|
|
59
64
|
}
|
|
60
|
-
request[kRouteContext].contentTypeParser.run(
|
|
65
|
+
request[kRouteContext].contentTypeParser.run(request[kRequestContentType].toString(), handler, request, reply)
|
|
61
66
|
return
|
|
62
67
|
}
|
|
63
68
|
|
|
@@ -142,6 +147,7 @@ function preHandlerCallback (err, request, reply) {
|
|
|
142
147
|
method: context.config.method
|
|
143
148
|
}
|
|
144
149
|
}
|
|
150
|
+
reply[kDiagnosticsStore] = store
|
|
145
151
|
channels.start.runStores(store, preHandlerCallbackInner, undefined, err, request, reply, store)
|
|
146
152
|
}
|
|
147
153
|
}
|
|
@@ -82,7 +82,8 @@ function buildRoutePrefix (instancePrefix, pluginPrefix) {
|
|
|
82
82
|
if (instancePrefix.endsWith('/') && pluginPrefix[0] === '/') {
|
|
83
83
|
// Remove the extra '/' to avoid: '/first//second'
|
|
84
84
|
pluginPrefix = pluginPrefix.slice(1)
|
|
85
|
-
} else if (pluginPrefix[0] !== '/') {
|
|
85
|
+
} else if (pluginPrefix[0] !== '/' && !instancePrefix.endsWith('/')) {
|
|
86
|
+
// Add the missing '/' to avoid: '/firstsecond'
|
|
86
87
|
pluginPrefix = '/' + pluginPrefix
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -10,7 +10,8 @@ const { exist, existReply, existRequest } = require('./decorate.js')
|
|
|
10
10
|
const {
|
|
11
11
|
FST_ERR_PLUGIN_VERSION_MISMATCH,
|
|
12
12
|
FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE,
|
|
13
|
-
FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER
|
|
13
|
+
FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER,
|
|
14
|
+
FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED
|
|
14
15
|
} = require('./errors.js')
|
|
15
16
|
|
|
16
17
|
const rcRegex = /-(?:rc|pre|alpha).+$/u
|
|
@@ -70,10 +71,9 @@ function checkDependencies (fn) {
|
|
|
70
71
|
assert(Array.isArray(dependencies), 'The dependencies should be an array of strings')
|
|
71
72
|
|
|
72
73
|
dependencies.forEach(dependency => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
74
|
+
if (!this[kRegisteredPlugins].includes(dependency)) {
|
|
75
|
+
throw new FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED(dependency, meta.name)
|
|
76
|
+
}
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -60,6 +60,7 @@ const {
|
|
|
60
60
|
const decorators = require('./decorate')
|
|
61
61
|
|
|
62
62
|
const toString = Object.prototype.toString
|
|
63
|
+
const HTTP2_WRITE_CHUNK_SIZE = 64 * 1024
|
|
63
64
|
|
|
64
65
|
function Reply (res, request, log) {
|
|
65
66
|
this.raw = res
|
|
@@ -75,6 +76,7 @@ function Reply (res, request, log) {
|
|
|
75
76
|
this.log = log
|
|
76
77
|
}
|
|
77
78
|
Reply.props = []
|
|
79
|
+
Reply.instanceProperties = new Set(['raw', 'request', 'log'])
|
|
78
80
|
|
|
79
81
|
Object.defineProperties(Reply.prototype, {
|
|
80
82
|
[kRouteContext]: {
|
|
@@ -167,7 +169,7 @@ Reply.prototype.send = function (payload) {
|
|
|
167
169
|
// node:stream/web
|
|
168
170
|
typeof payload.getReader === 'function' ||
|
|
169
171
|
// Response
|
|
170
|
-
toString.call(payload) === '[object Response]'
|
|
172
|
+
(typeof payload === 'object' && toString.call(payload) === '[object Response]')
|
|
171
173
|
) {
|
|
172
174
|
onSendHook(this, payload)
|
|
173
175
|
return this
|
|
@@ -593,7 +595,7 @@ function onSendEnd (reply, payload) {
|
|
|
593
595
|
// since Response contain status code, headers and body,
|
|
594
596
|
// we need to update the status, add the headers and use it's body as payload
|
|
595
597
|
// before continuing
|
|
596
|
-
if (toString.call(payload) === '[object Response]') {
|
|
598
|
+
if (payload != null && typeof payload === 'object' && toString.call(payload) === '[object Response]') {
|
|
597
599
|
// https://developer.mozilla.org/en-US/docs/Web/API/Response/status
|
|
598
600
|
if (typeof payload.status === 'number') {
|
|
599
601
|
reply.code(payload.status)
|
|
@@ -677,9 +679,52 @@ function onSendEnd (reply, payload) {
|
|
|
677
679
|
|
|
678
680
|
safeWriteHead(reply, statusCode)
|
|
679
681
|
// write payload first
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
682
|
+
writePayload(payload, res, reply)
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function isHttp2Reply (reply) {
|
|
686
|
+
return reply.request.raw?.httpVersionMajor === 2
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function writePayload (payload, res, reply) {
|
|
690
|
+
if (!isHttp2Reply(reply) || Buffer.byteLength(payload) <= HTTP2_WRITE_CHUNK_SIZE) {
|
|
691
|
+
res.write(payload)
|
|
692
|
+
// then send trailers
|
|
693
|
+
sendTrailer(payload, res, reply)
|
|
694
|
+
return
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
writeHttp2Payload(payload, res, () => {
|
|
698
|
+
// then send trailers
|
|
699
|
+
sendTrailer(payload, res, reply)
|
|
700
|
+
})
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function writeHttp2Payload (payload, res, done) {
|
|
704
|
+
const buffer = Buffer.isBuffer(payload) ? payload : Buffer.from(payload)
|
|
705
|
+
let offset = 0
|
|
706
|
+
|
|
707
|
+
function writeChunk () {
|
|
708
|
+
while (offset < buffer.length) {
|
|
709
|
+
/* c8 ignore next 3 - defensive guard for aborted responses */
|
|
710
|
+
if (res.destroyed || res.writableEnded) {
|
|
711
|
+
return
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const end = Math.min(offset + HTTP2_WRITE_CHUNK_SIZE, buffer.length)
|
|
715
|
+
const shouldContinue = res.write(buffer.subarray(offset, end))
|
|
716
|
+
offset = end
|
|
717
|
+
|
|
718
|
+
if (shouldContinue === false) {
|
|
719
|
+
res.once('drain', writeChunk)
|
|
720
|
+
return
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
done()
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
writeChunk()
|
|
683
728
|
}
|
|
684
729
|
|
|
685
730
|
function logStreamError (logger, err, res) {
|
|
@@ -830,10 +875,12 @@ function sendTrailer (payload, res, reply) {
|
|
|
830
875
|
const trailers = {}
|
|
831
876
|
let handled = 0
|
|
832
877
|
let skipped = true
|
|
878
|
+
let sent = false
|
|
833
879
|
function send () {
|
|
834
880
|
// add trailers when all handler handled
|
|
835
881
|
/* istanbul ignore else */
|
|
836
|
-
if (handled === 0) {
|
|
882
|
+
if (handled === 0 && !sent) {
|
|
883
|
+
sent = true
|
|
837
884
|
res.addTrailers(trailers)
|
|
838
885
|
// we need to properly close the stream
|
|
839
886
|
// after trailers sent
|
|
@@ -846,9 +893,10 @@ function sendTrailer (payload, res, reply) {
|
|
|
846
893
|
skipped = false
|
|
847
894
|
handled--
|
|
848
895
|
|
|
896
|
+
let cbAlreadyCalled = false
|
|
849
897
|
function cb (err, value) {
|
|
850
|
-
|
|
851
|
-
|
|
898
|
+
if (cbAlreadyCalled) return
|
|
899
|
+
cbAlreadyCalled = true
|
|
852
900
|
handled++
|
|
853
901
|
|
|
854
902
|
// we can safely ignore error for trailer
|
|
@@ -914,6 +962,13 @@ function setupResponseListeners (reply) {
|
|
|
914
962
|
}
|
|
915
963
|
}
|
|
916
964
|
|
|
965
|
+
// Fix: release socket._meta so request/reply objects are not retained
|
|
966
|
+
// past the response on keep-alive connections.
|
|
967
|
+
const socket = reply.request.raw.socket
|
|
968
|
+
if (socket && socket._meta && socket._meta.request === reply.request) {
|
|
969
|
+
socket._meta = null
|
|
970
|
+
}
|
|
971
|
+
|
|
917
972
|
if (ctx && ctx.onResponse !== null) {
|
|
918
973
|
onResponseHookRunner(
|
|
919
974
|
ctx.onResponse,
|
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
kSchemaController,
|
|
11
11
|
kOptions,
|
|
12
12
|
kRequestCacheValidateFns,
|
|
13
|
+
kRequestContentType,
|
|
13
14
|
kRouteContext,
|
|
14
15
|
kRequestOriginalUrl,
|
|
15
16
|
kRequestSignal,
|
|
@@ -36,6 +37,7 @@ function Request (id, params, req, query, log, context) {
|
|
|
36
37
|
this.body = undefined
|
|
37
38
|
}
|
|
38
39
|
Request.props = []
|
|
40
|
+
Request.instanceProperties = new Set(['id', 'params', 'raw', 'query', 'log', 'body'])
|
|
39
41
|
|
|
40
42
|
function getTrustProxyFn (tp) {
|
|
41
43
|
if (typeof tp === 'function') {
|
|
@@ -117,8 +119,8 @@ function buildRequestWithTrustProxy (R, trustProxy) {
|
|
|
117
119
|
},
|
|
118
120
|
host: {
|
|
119
121
|
get () {
|
|
120
|
-
const
|
|
121
|
-
if (this.headers['x-forwarded-host'] &&
|
|
122
|
+
const socket = this.raw.socket
|
|
123
|
+
if (this.headers['x-forwarded-host'] && socket != null && proxyFn(socket.remoteAddress, 0)) {
|
|
122
124
|
return getLastEntryInMultiHeaderValue(this.headers['x-forwarded-host'])
|
|
123
125
|
}
|
|
124
126
|
/**
|
|
@@ -132,8 +134,8 @@ function buildRequestWithTrustProxy (R, trustProxy) {
|
|
|
132
134
|
},
|
|
133
135
|
protocol: {
|
|
134
136
|
get () {
|
|
135
|
-
const
|
|
136
|
-
if (this.headers['x-forwarded-proto'] &&
|
|
137
|
+
const socket = this.raw.socket
|
|
138
|
+
if (this.headers['x-forwarded-proto'] && socket != null && proxyFn(socket.remoteAddress, 0)) {
|
|
137
139
|
return getLastEntryInMultiHeaderValue(this.headers['x-forwarded-proto'])
|
|
138
140
|
}
|
|
139
141
|
if (this.socket) {
|
|
@@ -282,6 +284,14 @@ Object.defineProperties(Request.prototype, {
|
|
|
282
284
|
this.additionalHeaders = headers
|
|
283
285
|
}
|
|
284
286
|
},
|
|
287
|
+
mediaType: {
|
|
288
|
+
get () {
|
|
289
|
+
if (!this[kRequestContentType] && this.headers['content-type'] !== undefined) {
|
|
290
|
+
this[kRequestContentType] = this[kRouteContext].contentTypeParser.getContentType(this.headers['content-type'])
|
|
291
|
+
}
|
|
292
|
+
return this[kRequestContentType]?.mediaType
|
|
293
|
+
}
|
|
294
|
+
},
|
|
285
295
|
getValidationFunction: {
|
|
286
296
|
value: function (httpPartOrSchema) {
|
|
287
297
|
if (typeof httpPartOrSchema === 'string') {
|
|
@@ -24,6 +24,7 @@ const {
|
|
|
24
24
|
FST_ERR_ROUTE_MISSING_HANDLER,
|
|
25
25
|
FST_ERR_ROUTE_METHOD_NOT_SUPPORTED,
|
|
26
26
|
FST_ERR_ROUTE_METHOD_INVALID,
|
|
27
|
+
FST_ERR_ROUTE_LOG_LEVEL_INVALID,
|
|
27
28
|
FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED,
|
|
28
29
|
FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT,
|
|
29
30
|
FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT,
|
|
@@ -68,6 +69,7 @@ const routerKeys = [
|
|
|
68
69
|
'ignoreTrailingSlash',
|
|
69
70
|
'maxParamLength',
|
|
70
71
|
'onBadUrl',
|
|
72
|
+
'onMaxParamLength',
|
|
71
73
|
'querystringParser',
|
|
72
74
|
'useSemicolonDelimiter'
|
|
73
75
|
]
|
|
@@ -284,6 +286,7 @@ function buildRouting (options) {
|
|
|
284
286
|
opts.routePath = path
|
|
285
287
|
opts.prefix = prefix
|
|
286
288
|
opts.logLevel = opts.logLevel || this[kLogLevel]
|
|
289
|
+
validateLogLevelOption(opts.logLevel, opts.method, opts.url, logger)
|
|
287
290
|
|
|
288
291
|
if (this[kLogSerializers] || opts.logSerializers) {
|
|
289
292
|
opts.logSerializers = Object.assign(Object.create(this[kLogSerializers]), opts.logSerializers)
|
|
@@ -365,7 +368,8 @@ function buildRouting (options) {
|
|
|
365
368
|
// any route insertion error created by fastify can be safely ignore
|
|
366
369
|
// because it only duplicate route for head
|
|
367
370
|
if (!context[kRouteByFastify]) {
|
|
368
|
-
const
|
|
371
|
+
const methods = Array.isArray(opts.method) ? opts.method : [opts.method]
|
|
372
|
+
const isDuplicatedRoute = methods.some(method => error.message.includes(`Method '${method}' already declared for route`))
|
|
369
373
|
if (isDuplicatedRoute) {
|
|
370
374
|
throw new FST_ERR_DUPLICATED_ROUTE(opts.method, opts.url)
|
|
371
375
|
}
|
|
@@ -476,12 +480,13 @@ function buildRouting (options) {
|
|
|
476
480
|
res.setHeader('Connection', 'close')
|
|
477
481
|
}
|
|
478
482
|
|
|
479
|
-
//
|
|
480
|
-
|
|
483
|
+
// Load-shedding fast path during drain. server.close() and
|
|
484
|
+
// closeIdleConnections() only reap idle sockets; requests already
|
|
485
|
+
// pipelined or arriving on an active keep-alive connection still reach
|
|
486
|
+
// this point with closing === true. Short-circuiting with 503 avoids
|
|
487
|
+
// running the full handler chain (and any downstream calls) for work
|
|
488
|
+
// the load balancer should redirect elsewhere.
|
|
481
489
|
if (return503OnClosing) {
|
|
482
|
-
// On Node v19 we cannot test this behavior as it won't be necessary
|
|
483
|
-
// anymore. It will close all the idle connections before they reach this
|
|
484
|
-
// stage.
|
|
485
490
|
const headers = {
|
|
486
491
|
'Content-Type': 'application/json',
|
|
487
492
|
'Content-Length': '80'
|
|
@@ -635,6 +640,15 @@ function validateHandlerTimeoutOption (handlerTimeout) {
|
|
|
635
640
|
}
|
|
636
641
|
}
|
|
637
642
|
|
|
643
|
+
function validateLogLevelOption (logLevel, method, path, logger) {
|
|
644
|
+
if (logLevel == null || logLevel === '') return
|
|
645
|
+
if (logger?.levels?.values == null) return
|
|
646
|
+
|
|
647
|
+
if (typeof logLevel !== 'string' || logger.levels.values[logLevel] === undefined) {
|
|
648
|
+
throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path, logLevel)
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
638
652
|
function runPreParsing (err, request, reply) {
|
|
639
653
|
if (reply.sent === true) return
|
|
640
654
|
if (err != null) {
|
|
@@ -31,7 +31,7 @@ function buildSchemaController (parentSchemaCtrl, opts) {
|
|
|
31
31
|
bucket: (opts && opts.bucket) || buildSchemas,
|
|
32
32
|
compilersFactory,
|
|
33
33
|
isCustomValidatorCompiler: typeof opts?.compilersFactory?.buildValidator === 'function',
|
|
34
|
-
isCustomSerializerCompiler: typeof opts?.compilersFactory?.
|
|
34
|
+
isCustomSerializerCompiler: typeof opts?.compilersFactory?.buildSerializer === 'function'
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return new SchemaController(undefined, option)
|