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
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
- [FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE](#fst_err_force_close_connections_idle_not_available)
|
|
75
75
|
- [FST_ERR_DUPLICATED_ROUTE](#fst_err_duplicated_route)
|
|
76
76
|
- [FST_ERR_BAD_URL](#fst_err_bad_url)
|
|
77
|
+
- [FST_ERR_MAX_PARAM_LENGTH](#fst_err_max_param_length)
|
|
77
78
|
- [FST_ERR_ASYNC_CONSTRAINT](#fst_err_async_constraint)
|
|
78
79
|
- [FST_ERR_INVALID_URL](#fst_err_invalid_url)
|
|
79
80
|
- [FST_ERR_ROUTE_OPTIONS_NOT_OBJ](#fst_err_route_options_not_obj)
|
|
@@ -82,6 +83,7 @@
|
|
|
82
83
|
- [FST_ERR_ROUTE_MISSING_HANDLER](#fst_err_route_missing_handler)
|
|
83
84
|
- [FST_ERR_ROUTE_METHOD_INVALID](#fst_err_route_method_invalid)
|
|
84
85
|
- [FST_ERR_ROUTE_METHOD_NOT_SUPPORTED](#fst_err_route_method_not_supported)
|
|
86
|
+
- [FST_ERR_ROUTE_LOG_LEVEL_INVALID](#fst_err_route_log_level_invalid)
|
|
85
87
|
- [FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED](#fst_err_route_body_validation_schema_not_supported)
|
|
86
88
|
- [FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT](#fst_err_route_body_limit_option_not_int)
|
|
87
89
|
- [FST_ERR_HANDLER_TIMEOUT](#fst_err_handler_timeout)
|
|
@@ -98,6 +100,7 @@
|
|
|
98
100
|
- [FST_ERR_PLUGIN_TIMEOUT](#fst_err_plugin_timeout)
|
|
99
101
|
- [FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE](#fst_err_plugin_not_present_in_instance)
|
|
100
102
|
- [FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER](#fst_err_plugin_invalid_async_handler)
|
|
103
|
+
- [FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED](#fst_err_plugin_dependency_not_registered)
|
|
101
104
|
- [FST_ERR_VALIDATION](#fst_err_validation)
|
|
102
105
|
- [FST_ERR_LISTEN_OPTIONS_INVALID](#fst_err_listen_options_invalid)
|
|
103
106
|
- [FST_ERR_ERROR_HANDLER_NOT_FN](#fst_err_error_handler_not_fn)
|
|
@@ -209,16 +212,16 @@ fastify.setErrorHandler((error, request, reply) => {
|
|
|
209
212
|
|
|
210
213
|
fastify.register((app, options, next) => {
|
|
211
214
|
// Register child error handler
|
|
212
|
-
|
|
215
|
+
app.setErrorHandler((error, request, reply) => {
|
|
213
216
|
throw error
|
|
214
217
|
})
|
|
215
218
|
|
|
216
|
-
|
|
217
|
-
// Throws a non-Error type, '
|
|
219
|
+
app.get('/bad', async () => {
|
|
220
|
+
// Throws a non-Error type, 'foo'
|
|
218
221
|
throw 'foo'
|
|
219
222
|
})
|
|
220
223
|
|
|
221
|
-
|
|
224
|
+
app.get('/good', async () => {
|
|
222
225
|
// Throws an Error instance, 'bar'
|
|
223
226
|
throw new Error('bar')
|
|
224
227
|
})
|
|
@@ -349,6 +352,7 @@ Below is a table with all the error codes used by Fastify.
|
|
|
349
352
|
| <a id="fst_err_force_close_connections_idle_not_available">FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE</a> | Cannot set forceCloseConnections to `idle` as your HTTP server does not support `closeIdleConnections` method. | Use a different value for `forceCloseConnections`. | [#3925](https://github.com/fastify/fastify/pull/3925) |
|
|
350
353
|
| <a id="fst_err_duplicated_route">FST_ERR_DUPLICATED_ROUTE</a> | The HTTP method already has a registered controller for that URL. | Use a different URL or register the controller for another HTTP method. | [#2954](https://github.com/fastify/fastify/pull/2954) |
|
|
351
354
|
| <a id="fst_err_bad_url">FST_ERR_BAD_URL</a> | The router received an invalid URL. | Use a valid URL. | [#2106](https://github.com/fastify/fastify/pull/2106) |
|
|
355
|
+
| <a id="fst_err_max_param_length">FST_ERR_MAX_PARAM_LENGTH</a> | The router received an URL that exceed max param length. | Adjust the param length or increase the max param length to meet your needs. | [#2106](https://github.com/fastify/fastify/pull/6716) |
|
|
352
356
|
| <a id="fst_err_async_constraint">FST_ERR_ASYNC_CONSTRAINT</a> | The router received an error when using asynchronous constraints. | - | [#4323](https://github.com/fastify/fastify/pull/4323) |
|
|
353
357
|
| <a id="fst_err_invalid_url">FST_ERR_INVALID_URL</a> | URL must be a string. | Use a string for the URL. | [#3653](https://github.com/fastify/fastify/pull/3653) |
|
|
354
358
|
| <a id="fst_err_route_options_not_obj">FST_ERR_ROUTE_OPTIONS_NOT_OBJ</a> | Options for the route must be an object. | Use an object for the route options. | [#4554](https://github.com/fastify/fastify/pull/4554) |
|
|
@@ -357,6 +361,7 @@ Below is a table with all the error codes used by Fastify.
|
|
|
357
361
|
| <a id="fst_err_route_missing_handler">FST_ERR_ROUTE_MISSING_HANDLER</a> | Missing handler function for the route. | Add a handler function. | [#4554](https://github.com/fastify/fastify/pull/4554) |
|
|
358
362
|
| <a id="fst_err_route_method_invalid">FST_ERR_ROUTE_METHOD_INVALID</a> | Method is not a valid value. | Use a valid value for the method. | [#4750](https://github.com/fastify/fastify/pull/4750) |
|
|
359
363
|
| <a id="fst_err_route_method_not_supported">FST_ERR_ROUTE_METHOD_NOT_SUPPORTED</a> | Method is not supported for the route. | Use a supported method. | [#4554](https://github.com/fastify/fastify/pull/4554) |
|
|
364
|
+
| <a id="fst_err_route_log_level_invalid">FST_ERR_ROUTE_LOG_LEVEL_INVALID</a> | `logLevel` must match a configured logger level. | Use one of the configured logger levels for the route. | [#6523](https://github.com/fastify/fastify/pull/6523) |
|
|
360
365
|
| <a id="fst_err_route_body_validation_schema_not_supported">FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED</a> | Body validation schema route is not supported. | Use a different different method for the route. | [#4554](https://github.com/fastify/fastify/pull/4554) |
|
|
361
366
|
| <a id="fst_err_route_body_limit_option_not_int">FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT</a> | `bodyLimit` option must be an integer. | Use an integer for the `bodyLimit` option. | [#4554](https://github.com/fastify/fastify/pull/4554) |
|
|
362
367
|
| <a id="fst_err_handler_timeout">FST_ERR_HANDLER_TIMEOUT</a> | Request timed out. | Increase the `handlerTimeout` option or optimize the handler. | - |
|
|
@@ -372,6 +377,7 @@ Below is a table with all the error codes used by Fastify.
|
|
|
372
377
|
| <a id="fst_err_plugin_timeout">FST_ERR_PLUGIN_TIMEOUT</a> | Plugin did not start in time. | Increase the timeout for the plugin. | [#3106](https://github.com/fastify/fastify/pull/3106) |
|
|
373
378
|
| <a id="fst_err_plugin_not_present_in_instance">FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE</a> | The decorator is not present in the instance. | - | [#4554](https://github.com/fastify/fastify/pull/4554) |
|
|
374
379
|
| <a id="fst_err_plugin_invalid_async_handler">FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER</a> | The plugin being registered mixes async and callback styles. | - | [#5141](https://github.com/fastify/fastify/pull/5141) |
|
|
380
|
+
| <a id="fst_err_plugin_dependency_not_registered">FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED</a> | The dependency of a plugin is not registered. | Register the missing dependency before registering this plugin. | [#6774](https://github.com/fastify/fastify/pull/6774) |
|
|
375
381
|
| <a id="fst_err_validation">FST_ERR_VALIDATION</a> | The Request failed the payload validation. | Check the request payload. | [#4824](https://github.com/fastify/fastify/pull/4824) |
|
|
376
382
|
| <a id="fst_err_listen_options_invalid">FST_ERR_LISTEN_OPTIONS_INVALID</a> | Invalid listen options. | Check the listen options. | [#4886](https://github.com/fastify/fastify/pull/4886) |
|
|
377
383
|
| <a id="fst_err_error_handler_not_fn">FST_ERR_ERROR_HANDLER_NOT_FN</a> | Error Handler must be a function | Provide a function to `setErrorHandler`. | [#5317](https://github.com/fastify/fastify/pull/5317) | <a id="fst_err_error_handler_already_set">FST_ERR_ERROR_HANDLER_ALREADY_SET</a> | Error Handler already set in this scope. Set `allowErrorHandlerOverride: true` to allow overriding. | By default, `setErrorHandler` can only be called once per encapsulation context. | [#6097](https://github.com/fastify/fastify/pull/6098) |
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<h1 align="center">Fastify</h1>
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## HTTP/2
|
|
4
4
|
|
|
5
|
-
_Fastify_ supports
|
|
5
|
+
_Fastify_ supports HTTP/2 over HTTPS (h2) or plaintext (h2c).
|
|
6
6
|
|
|
7
|
-
Currently, none of the
|
|
7
|
+
Currently, none of the HTTP/2-specific APIs are available through _Fastify_, but
|
|
8
8
|
Node's `req` and `res` can be accessed through the `Request` and `Reply`
|
|
9
9
|
interfaces. PRs are welcome.
|
|
10
10
|
|
|
11
11
|
### Secure (HTTPS)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
HTTP/2 is supported in all modern browsers __only over a secure connection__:
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
16
|
'use strict'
|
|
@@ -32,11 +32,11 @@ fastify.get('/', function (request, reply) {
|
|
|
32
32
|
fastify.listen({ port: 3000 })
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
[ALPN negotiation](https://datatracker.ietf.org/doc/html/rfc7301)
|
|
36
|
-
|
|
35
|
+
[ALPN negotiation](https://datatracker.ietf.org/doc/html/rfc7301) enables
|
|
36
|
+
both HTTPS and HTTP/2 over the same socket.
|
|
37
37
|
Node core `req` and `res` objects can be either
|
|
38
38
|
[HTTP/1](https://nodejs.org/api/http.html) or
|
|
39
|
-
[HTTP/2](https://nodejs.org/api/http2.html). _Fastify_ supports
|
|
39
|
+
[HTTP/2](https://nodejs.org/api/http2.html). _Fastify_ supports both out of the
|
|
40
40
|
box:
|
|
41
41
|
|
|
42
42
|
```js
|
|
@@ -53,7 +53,7 @@ const fastify = require('fastify')({
|
|
|
53
53
|
}
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
//
|
|
56
|
+
// This route can be accessed through both protocols
|
|
57
57
|
fastify.get('/', function (request, reply) {
|
|
58
58
|
reply.code(200).send({ hello: 'world' })
|
|
59
59
|
})
|
|
@@ -61,7 +61,7 @@ fastify.get('/', function (request, reply) {
|
|
|
61
61
|
fastify.listen({ port: 3000 })
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Test the
|
|
64
|
+
Test the server with:
|
|
65
65
|
|
|
66
66
|
```
|
|
67
67
|
$ npx h2url https://localhost:3000
|
|
@@ -69,7 +69,7 @@ $ npx h2url https://localhost:3000
|
|
|
69
69
|
|
|
70
70
|
### Plain or insecure
|
|
71
71
|
|
|
72
|
-
For microservices,
|
|
72
|
+
For microservices, HTTP/2 can connect in plain text, but this is not
|
|
73
73
|
supported by browsers.
|
|
74
74
|
|
|
75
75
|
```js
|
|
@@ -737,9 +737,9 @@ fastify.addHook('onResponse', (request, reply, done) => {
|
|
|
737
737
|
done()
|
|
738
738
|
})
|
|
739
739
|
|
|
740
|
-
fastify.addHook('preParsing', (request, reply, done) => {
|
|
740
|
+
fastify.addHook('preParsing', (request, reply, payload, done) => {
|
|
741
741
|
// Your code
|
|
742
|
-
done()
|
|
742
|
+
done(null, payload)
|
|
743
743
|
})
|
|
744
744
|
|
|
745
745
|
fastify.addHook('preValidation', (request, reply, done) => {
|
|
@@ -790,9 +790,9 @@ fastify.route({
|
|
|
790
790
|
// this hook will always be executed after the shared `onResponse` hooks
|
|
791
791
|
done()
|
|
792
792
|
},
|
|
793
|
-
preParsing: function (request, reply, done) {
|
|
793
|
+
preParsing: function (request, reply, payload, done) {
|
|
794
794
|
// This hook will always be executed after the shared `preParsing` hooks
|
|
795
|
-
done()
|
|
795
|
+
done(null, payload)
|
|
796
796
|
},
|
|
797
797
|
preValidation: function (request, reply, done) {
|
|
798
798
|
// This hook will always be executed after the shared `preValidation` hooks
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
## Core Documents
|
|
4
4
|
<a id="reference-core-docs"></a>
|
|
5
5
|
|
|
6
|
-
For the full table of contents
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
For the full table of contents, see [below](#reference-toc). The following list
|
|
7
|
+
is a subset of the full table of contents that details core Fastify APIs and
|
|
8
|
+
concepts, ordered by likely importance to the reader:
|
|
9
9
|
|
|
10
10
|
+ [Server](./Server.md): Documents the core Fastify API. Includes documentation
|
|
11
|
-
for the factory function and the
|
|
11
|
+
for the factory function and the resulting server instance.
|
|
12
12
|
+ [Lifecycle](./Lifecycle.md): Explains the Fastify request lifecycle and
|
|
13
13
|
illustrates where [Hooks](./Hooks.md) are available for integrating with it.
|
|
14
14
|
+ [Routes](./Routes.md): Details how to register routes with Fastify and how
|
|
@@ -25,8 +25,8 @@ order of most likely importance to the reader:
|
|
|
25
25
|
Fastify plugins are built.
|
|
26
26
|
+ [Decorators](./Decorators.md): Explains the server, request, and response
|
|
27
27
|
decorator APIs.
|
|
28
|
-
+ [Hooks](./Hooks.md): Details the API
|
|
29
|
-
|
|
28
|
+
+ [Hooks](./Hooks.md): Details the API that allows plugins to integrate with
|
|
29
|
+
the request lifecycle.
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
## Reference Documentation Table Of Contents
|
|
@@ -42,18 +42,17 @@ This table of contents is in alphabetical order.
|
|
|
42
42
|
Fastify plugins are built.
|
|
43
43
|
+ [Errors](./Errors.md): Details how Fastify handles errors and lists the
|
|
44
44
|
standard set of errors Fastify generates.
|
|
45
|
-
+ [Hooks](./Hooks.md): Details the API
|
|
46
|
-
|
|
47
|
-
+ [
|
|
45
|
+
+ [Hooks](./Hooks.md): Details the API that allows plugins to integrate with
|
|
46
|
+
the request lifecycle.
|
|
47
|
+
+ [HTTP/2](./HTTP2.md): Details Fastify's HTTP/2 support.
|
|
48
48
|
+ [Lifecycle](./Lifecycle.md): Explains the Fastify request lifecycle and
|
|
49
49
|
illustrates where [Hooks](./Hooks.md) are available for integrating with it.
|
|
50
50
|
+ [Logging](./Logging.md): Details Fastify's included logging and how to
|
|
51
51
|
customize it.
|
|
52
|
-
+ [Long Term Support](./LTS.md): Explains Fastify's long
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
middleware.
|
|
52
|
+
+ [Long Term Support](./LTS.md): Explains Fastify's long-term support guarantee
|
|
53
|
+
and the possible exceptions to the [semver](https://semver.org) contract.
|
|
54
|
+
+ [Middleware](./Middleware.md): Details Fastify's support for
|
|
55
|
+
Express.js-style middleware.
|
|
57
56
|
+ [Plugins](./Plugins.md): Explains Fastify's plugin architecture and API.
|
|
58
57
|
+ [Reply](./Reply.md): Details Fastify's response object available to each
|
|
59
58
|
request handler.
|
|
@@ -64,8 +63,7 @@ This table of contents is in alphabetical order.
|
|
|
64
63
|
+ [Server](./Server.md): Documents the core Fastify API. Includes documentation
|
|
65
64
|
for the factory function and the object returned by the factory function.
|
|
66
65
|
+ [TypeScript](./TypeScript.md): Documents Fastify's TypeScript support and
|
|
67
|
-
provides recommendations for
|
|
68
|
-
Fastify.
|
|
66
|
+
provides recommendations for TypeScript application development.
|
|
69
67
|
+ [Validation and Serialization](./Validation-and-Serialization.md): Details
|
|
70
68
|
Fastify's support for validating incoming data and how Fastify serializes data
|
|
71
69
|
for responses.
|
|
@@ -11,10 +11,10 @@ in this document:
|
|
|
11
11
|
date. The release date of any specific version can be found at
|
|
12
12
|
[https://github.com/fastify/fastify/releases](https://github.com/fastify/fastify/releases).
|
|
13
13
|
2. Major releases will receive security updates for an additional six months
|
|
14
|
-
from the release of the next major release. After this period
|
|
15
|
-
review and release security fixes as long as they are provided
|
|
16
|
-
community and they do not violate other constraints,
|
|
17
|
-
Node.js version.
|
|
14
|
+
from the release of the next major release. After this period, Fastify maintainers
|
|
15
|
+
will still review and release security fixes as long as they are provided
|
|
16
|
+
by the community and they do not violate other constraints,
|
|
17
|
+
e.g., minimum supported Node.js version.
|
|
18
18
|
3. Major releases will be tested and verified against all Node.js release lines
|
|
19
19
|
that are supported by the [Node.js LTS
|
|
20
20
|
policy](https://github.com/nodejs/Release) within the LTS period of that
|
|
@@ -24,7 +24,7 @@ in this document:
|
|
|
24
24
|
and verified against alternative runtimes that are compatible with Node.js.
|
|
25
25
|
The maintenance teams of these alternative runtimes are responsible for ensuring
|
|
26
26
|
and guaranteeing these tests work properly.
|
|
27
|
-
1. [N|Solid](https://docs.nodesource.com/docs/product_suite) tests and
|
|
27
|
+
1. [N|Solid](https://docs.nodesource.com/docs/product_suite/) tests and
|
|
28
28
|
verifies each Fastify major release against current N|Solid LTS versions.
|
|
29
29
|
NodeSource ensures Fastify compatibility with N|Solid, aligning with the
|
|
30
30
|
support scope of N|Solid LTS versions at the time of the Fastify release.
|
|
@@ -35,21 +35,21 @@ A "month" is defined as 30 consecutive days.
|
|
|
35
35
|
> ## Security Releases and Semver
|
|
36
36
|
>
|
|
37
37
|
> As a consequence of providing long-term support for major releases, there are
|
|
38
|
-
> occasions
|
|
39
|
-
> release. Such changes will _always_ be
|
|
38
|
+
> occasions when breaking changes must be released as a _minor_ version
|
|
39
|
+
> release. Such changes will _always_ be documented in the [release
|
|
40
40
|
> notes](https://github.com/fastify/fastify/releases).
|
|
41
41
|
>
|
|
42
|
-
> To avoid automatically receiving breaking security updates it is possible to
|
|
42
|
+
> To avoid automatically receiving breaking security updates, it is possible to
|
|
43
43
|
> use the tilde (`~`) range qualifier. For example, to get patches for the 3.15
|
|
44
44
|
> release, and avoid automatically updating to the 3.16 release, specify the
|
|
45
45
|
> dependency as `"fastify": "~3.15.x"`. This will leave your application
|
|
46
|
-
> vulnerable
|
|
46
|
+
> vulnerable. Use this approach with caution.
|
|
47
47
|
|
|
48
48
|
### Security Support Beyond LTS
|
|
49
49
|
|
|
50
50
|
Fastify's partner, HeroDevs, provides commercial security support through the
|
|
51
51
|
OpenJS Ecosystem Sustainability Program for versions of Fastify that are EOL.
|
|
52
|
-
For more information, see
|
|
52
|
+
For more information, see the [Never Ending Support][hd-link] service offered.
|
|
53
53
|
|
|
54
54
|
### Schedule
|
|
55
55
|
<a id="lts-schedule"></a>
|
|
@@ -62,7 +62,7 @@ For more information, see their [Never Ending Support][hd-link] service.
|
|
|
62
62
|
| 4.0.0 | 2022-06-08 | 2025-06-30 | 14, 16, 18, 20, 22 | v5(18), v5(20) |
|
|
63
63
|
| 5.0.0 | 2024-09-17 | TBD | 20, 22 | v5(20) |
|
|
64
64
|
|
|
65
|
-
### CI
|
|
65
|
+
### CI Tested Operating Systems
|
|
66
66
|
<a id="supported-os"></a>
|
|
67
67
|
|
|
68
68
|
Fastify uses GitHub Actions for CI testing, please refer to [GitHub's
|
|
@@ -78,8 +78,7 @@ YAML workflow labels below:
|
|
|
78
78
|
| Windows | `windows-latest` | npm | 20 | v5(20) |
|
|
79
79
|
| MacOS | `macos-latest` | npm | 20 | v5(20) |
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
flag.
|
|
81
|
+
When using [yarn](https://yarnpkg.com/), the `--ignore-engines` flag may be required.
|
|
83
82
|
|
|
84
83
|
[semver]: https://semver.org/
|
|
85
84
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## Lifecycle
|
|
4
4
|
<a id="lifecycle"></a>
|
|
5
5
|
|
|
6
|
-
This
|
|
6
|
+
This diagram shows the internal lifecycle of Fastify.
|
|
7
7
|
|
|
8
8
|
The right branch of each section shows the next phase of the lifecycle. The left
|
|
9
9
|
branch shows the corresponding error code generated if the parent throws an
|
|
@@ -41,10 +41,11 @@ Incoming Request
|
|
|
41
41
|
└─▶ onResponse Hook
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
When `handlerTimeout` is configured, a
|
|
45
|
-
response is not sent within the allowed time,
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
When [`handlerTimeout`](./Server.md#factory-handler-timeout) is configured, a
|
|
45
|
+
timer starts after routing. If the response is not sent within the allowed time,
|
|
46
|
+
`request.signal` is aborted and a `503 Service Unavailable` error is sent.
|
|
47
|
+
The timer is cancelled when the response completes
|
|
48
|
+
or when `reply.hijack()` is called.
|
|
48
49
|
|
|
49
50
|
Before or during the `User Handler`, `reply.hijack()` can be called to:
|
|
50
51
|
- Prevent Fastify from running subsequent hooks and the user handler
|
|
@@ -61,8 +62,8 @@ When the user handles the request, the result may be:
|
|
|
61
62
|
- In an async handler: it returns a payload or throws an `Error`
|
|
62
63
|
- In a sync handler: it sends a payload or an `Error` instance
|
|
63
64
|
|
|
64
|
-
If the reply
|
|
65
|
-
|
|
65
|
+
If the reply is hijacked, all subsequent steps are skipped.
|
|
66
|
+
Otherwise, the data flows as follows:
|
|
66
67
|
|
|
67
68
|
```
|
|
68
69
|
★ schema validation Error
|
|
@@ -96,4 +97,4 @@ graceful shutdown sequence involving
|
|
|
96
97
|
[`preClose`](./Hooks.md#pre-close) hooks, connection draining, and
|
|
97
98
|
[`onClose`](./Hooks.md#on-close) hooks. See the
|
|
98
99
|
[`close`](./Server.md#close) method documentation for the full step-by-step
|
|
99
|
-
lifecycle.
|
|
100
|
+
lifecycle.
|
|
@@ -13,8 +13,8 @@ As Fastify is focused on performance, it uses
|
|
|
13
13
|
[pino](https://github.com/pinojs/pino) as its logger, with the default log
|
|
14
14
|
level set to `'info'` when enabled.
|
|
15
15
|
|
|
16
|
-
#### Basic
|
|
17
|
-
|
|
16
|
+
#### Basic Logging Setup
|
|
17
|
+
The following enables the production JSON logger:
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
20
|
const fastify = require('fastify')({
|
|
@@ -23,8 +23,8 @@ const fastify = require('fastify')({
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
#### Environment-Specific Configuration
|
|
26
|
-
Enabling the logger
|
|
27
|
-
|
|
26
|
+
Enabling the logger for local development, production, and test environments
|
|
27
|
+
requires additional configuration:
|
|
28
28
|
|
|
29
29
|
```js
|
|
30
30
|
const envToLogger = {
|
|
@@ -41,11 +41,13 @@ const envToLogger = {
|
|
|
41
41
|
test: false,
|
|
42
42
|
}
|
|
43
43
|
const fastify = require('fastify')({
|
|
44
|
-
logger: envToLogger[environment] ?? true // defaults to true if no
|
|
44
|
+
logger: envToLogger[environment] ?? true // defaults to true if no matching environment is found
|
|
45
45
|
})
|
|
46
46
|
```
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
> ⚠ Warning:
|
|
49
|
+
> `pino-pretty` needs to be installed as a dev dependency. It is not included
|
|
50
|
+
> by default for performance reasons.
|
|
49
51
|
|
|
50
52
|
### Usage
|
|
51
53
|
The logger can be used in route handlers as follows:
|
|
@@ -57,22 +59,22 @@ fastify.get('/', options, function (request, reply) {
|
|
|
57
59
|
})
|
|
58
60
|
```
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
To log outside route handlers, use the logger available on the Fastify instance:
|
|
63
|
+
|
|
62
64
|
```js
|
|
63
|
-
fastify.log.info('Something important happened!')
|
|
65
|
+
fastify.log.info('Something important happened!')
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
#### Passing Logger Options
|
|
67
69
|
To pass options to the logger, provide them to Fastify. See the
|
|
68
70
|
[Pino documentation](https://github.com/pinojs/pino/blob/main/docs/api.md#options)
|
|
69
|
-
for available options. To specify a file destination, use:
|
|
71
|
+
for the full list of available options. To specify a file destination, use:
|
|
70
72
|
|
|
71
73
|
```js
|
|
72
74
|
const fastify = require('fastify')({
|
|
73
75
|
logger: {
|
|
74
76
|
level: 'info',
|
|
75
|
-
file: '/path/to/file' //
|
|
77
|
+
file: '/path/to/file' // Uses pino.destination()
|
|
76
78
|
}
|
|
77
79
|
})
|
|
78
80
|
|
|
@@ -103,20 +105,19 @@ const fastify = require('fastify')({
|
|
|
103
105
|
#### Request ID Tracking
|
|
104
106
|
By default, Fastify adds an ID to every request for easier tracking. If the
|
|
105
107
|
`requestIdHeader` option is set and the corresponding header is present, its
|
|
106
|
-
value is used; otherwise, a new incremental ID is generated. See Fastify
|
|
107
|
-
[`requestIdHeader`](./Server.md#factory-request-id-header) and
|
|
108
|
+
value is used; otherwise, a new incremental ID is generated. See the Fastify
|
|
109
|
+
factory options [`requestIdHeader`](./Server.md#factory-request-id-header) and
|
|
108
110
|
[`genReqId`](./Server.md#genreqid) for customization options.
|
|
109
111
|
|
|
110
112
|
> ⚠ Warning:
|
|
111
|
-
> Enabling `requestIdHeader` allows
|
|
112
|
-
> value
|
|
113
|
-
> No validation is performed on `requestIdHeader`.
|
|
113
|
+
> Enabling `requestIdHeader` allows callers to set `reqId` to an arbitrary
|
|
114
|
+
> value. No validation is performed on the header value.
|
|
114
115
|
|
|
115
116
|
#### Serializers
|
|
116
117
|
The default logger uses standard serializers for objects with `req`, `res`, and
|
|
117
118
|
`err` properties. The `req` object is the Fastify [`Request`](./Request.md)
|
|
118
119
|
object, and the `res` object is the Fastify [`Reply`](./Reply.md) object. This
|
|
119
|
-
behavior can be
|
|
120
|
+
behavior can be overridden with custom serializers.
|
|
120
121
|
|
|
121
122
|
```js
|
|
122
123
|
const fastify = require('fastify')({
|
|
@@ -129,8 +130,12 @@ const fastify = require('fastify')({
|
|
|
129
130
|
}
|
|
130
131
|
})
|
|
131
132
|
```
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
|
|
134
|
+
> ⚠ Warning:
|
|
135
|
+
> Logging response headers may expose sensitive data, including authentication
|
|
136
|
+
> data, and may violate privacy regulations.
|
|
137
|
+
> Use [log redaction](#log-redaction) to remove sensitive information.
|
|
138
|
+
> The following example is for demonstration purposes only:
|
|
134
139
|
|
|
135
140
|
```js
|
|
136
141
|
const fastify = require('fastify')({
|
|
@@ -151,22 +156,19 @@ const fastify = require('fastify')({
|
|
|
151
156
|
url: request.url,
|
|
152
157
|
path: request.routeOptions.url,
|
|
153
158
|
parameters: request.params,
|
|
154
|
-
// Including headers in the log could violate privacy laws,
|
|
155
|
-
// e.g., GDPR. Use the "redact" option to remove sensitive
|
|
156
|
-
// fields. It could also leak authentication data in the logs.
|
|
157
159
|
headers: request.headers
|
|
158
|
-
}
|
|
160
|
+
}
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
|
-
})
|
|
164
|
+
})
|
|
163
165
|
```
|
|
164
166
|
|
|
165
167
|
> ℹ️ Note:
|
|
166
168
|
> In some cases, the [`Reply`](./Reply.md) object passed to the `res`
|
|
167
169
|
> serializer cannot be fully constructed. When writing a custom `res`
|
|
168
|
-
> serializer,
|
|
169
|
-
> `
|
|
170
|
+
> serializer, verify that any properties other than `statusCode` exist on
|
|
171
|
+
> `reply` before accessing them. For example, verify the existence of
|
|
170
172
|
> `getHeaders` before calling it:
|
|
171
173
|
|
|
172
174
|
```js
|
|
@@ -187,15 +189,15 @@ const fastify = require('fastify')({
|
|
|
187
189
|
},
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
|
-
})
|
|
192
|
+
})
|
|
191
193
|
```
|
|
192
194
|
|
|
193
195
|
> ℹ️ Note:
|
|
194
|
-
> The body cannot be serialized inside
|
|
196
|
+
> The body cannot be serialized inside the `req` serializer because the
|
|
195
197
|
> request is serialized when the child logger is created. At that time, the body
|
|
196
198
|
> is not yet parsed.
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
To log `req.body`, use the `preHandler` hook:
|
|
199
201
|
|
|
200
202
|
```js
|
|
201
203
|
app.addHook('preHandler', function (req, reply, done) {
|
|
@@ -207,18 +209,20 @@ app.addHook('preHandler', function (req, reply, done) {
|
|
|
207
209
|
```
|
|
208
210
|
|
|
209
211
|
> ℹ️ Note:
|
|
210
|
-
> Ensure serializers never throw errors, as this can cause the Node
|
|
212
|
+
> Ensure serializers never throw errors, as this can cause the Node.js
|
|
211
213
|
> process to exit. See the
|
|
212
|
-
> [Pino documentation](https://getpino.io/#/docs/api?id=opt-serializers) for
|
|
213
|
-
> information.
|
|
214
|
+
> [Pino documentation](https://getpino.io/#/docs/api?id=opt-serializers) for
|
|
215
|
+
> more information.
|
|
214
216
|
|
|
215
|
-
*Any logger other than Pino will ignore
|
|
217
|
+
*Any logger other than Pino will ignore the `serializers` option.*
|
|
216
218
|
|
|
217
219
|
### Using Custom Loggers
|
|
218
220
|
A custom logger instance can be supplied by passing it as `loggerInstance`. The
|
|
219
|
-
logger must conform to the Pino interface
|
|
220
|
-
|
|
221
|
-
`
|
|
221
|
+
logger must conform to the Pino interface with the following:
|
|
222
|
+
|
|
223
|
+
- **Methods:** `info`, `error`, `debug`, `fatal`, `warn`, `trace`, `silent`,
|
|
224
|
+
`child`
|
|
225
|
+
- **Properties:** `level` (string)
|
|
222
226
|
|
|
223
227
|
Example:
|
|
224
228
|
|
|
@@ -239,7 +243,7 @@ fastify.get('/', function (request, reply) {
|
|
|
239
243
|
|
|
240
244
|
### Log Redaction
|
|
241
245
|
|
|
242
|
-
[Pino](https://getpino.io) supports low-overhead log redaction for
|
|
246
|
+
[Pino](https://getpino.io) supports low-overhead log redaction for masking
|
|
243
247
|
values of specific properties in recorded logs. For example, log all HTTP
|
|
244
248
|
headers except the `Authorization` header for security:
|
|
245
249
|
|
|
@@ -265,4 +269,5 @@ const fastify = Fastify({
|
|
|
265
269
|
})
|
|
266
270
|
```
|
|
267
271
|
|
|
268
|
-
See https://getpino.io/#/docs/redaction for
|
|
272
|
+
See the [Pino redaction documentation](https://getpino.io/#/docs/redaction) for
|
|
273
|
+
more details.
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Middleware
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
As of Fastify v3.0.0, middleware is not supported out of the box and requires
|
|
6
|
+
an external plugin such as
|
|
7
7
|
[`@fastify/express`](https://github.com/fastify/fastify-express) or
|
|
8
8
|
[`@fastify/middie`](https://github.com/fastify/middie).
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
[`@fastify/express`](https://github.com/fastify/fastify-express) plugin to `use`
|
|
13
|
-
Express middleware:
|
|
10
|
+
The following example registers the `@fastify/express` plugin and uses Express
|
|
11
|
+
middleware:
|
|
14
12
|
|
|
15
13
|
```js
|
|
16
14
|
await fastify.register(require('@fastify/express'))
|
|
@@ -22,37 +20,35 @@ fastify.use(require('ienoopen')())
|
|
|
22
20
|
fastify.use(require('x-xss-protection')())
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
[`@fastify/middie`](https://github.com/fastify/middie) can also be used,
|
|
26
|
-
|
|
27
|
-
performance:
|
|
23
|
+
[`@fastify/middie`](https://github.com/fastify/middie) can also be used, which
|
|
24
|
+
provides support for simple Express-style middleware with improved performance:
|
|
28
25
|
|
|
29
26
|
```js
|
|
30
27
|
await fastify.register(require('@fastify/middie'))
|
|
31
28
|
fastify.use(require('cors')())
|
|
32
29
|
```
|
|
33
30
|
|
|
34
|
-
Middleware can be encapsulated
|
|
35
|
-
|
|
31
|
+
Middleware can be encapsulated using `register`, which controls where it runs,
|
|
32
|
+
as explained in the [Plugins Guide](../Guides/Plugins-Guide.md).
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
the
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
use the
|
|
43
|
-
|
|
44
|
-
[
|
|
45
|
-
[Hooks](./Hooks.md#hooks).
|
|
34
|
+
This is because Fastify wraps the incoming Node.js `req` and `res` objects into
|
|
35
|
+
[Request](./Request.md#request) and [Reply](./Reply.md#reply) instances after
|
|
36
|
+
the middleware phase. As a result, Fastify middleware does not expose the `send`
|
|
37
|
+
method or other methods specific to the Fastify [Reply](./Reply.md#reply)
|
|
38
|
+
instance. To create middleware, use the Node.js `req` and `res` objects.
|
|
39
|
+
Alternatively, use the `preHandler` hook, which has access to the Fastify
|
|
40
|
+
[Request](./Request.md#request) and [Reply](./Reply.md#reply) instances. For
|
|
41
|
+
more information, see [Hooks](./Hooks.md).
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
### Restrict Middleware Execution to Certain Paths
|
|
48
44
|
<a id="restrict-usage"></a>
|
|
49
45
|
|
|
50
|
-
To
|
|
46
|
+
To restrict middleware to specific paths, pass the path as the first argument to
|
|
51
47
|
`use`.
|
|
52
48
|
|
|
53
49
|
> ℹ️ Note:
|
|
54
50
|
> This does not support routes with parameters
|
|
55
|
-
> (e.g
|
|
51
|
+
> (e.g., `/user/:id/comments`). Wildcards are not supported in multiple paths.
|
|
56
52
|
|
|
57
53
|
```js
|
|
58
54
|
const path = require('node:path')
|
|
@@ -68,9 +64,9 @@ fastify.use('/css/(.*)', serveStatic(path.join(__dirname, '/assets')))
|
|
|
68
64
|
fastify.use(['/css', '/js'], serveStatic(path.join(__dirname, '/assets')))
|
|
69
65
|
```
|
|
70
66
|
|
|
71
|
-
### Alternatives
|
|
67
|
+
### Fastify Alternatives
|
|
72
68
|
|
|
73
|
-
Fastify offers alternatives to commonly used middleware, such as
|
|
69
|
+
Fastify offers native alternatives to commonly used middleware, such as
|
|
74
70
|
[`@fastify/helmet`](https://github.com/fastify/fastify-helmet) for
|
|
75
71
|
[`helmet`](https://github.com/helmetjs/helmet),
|
|
76
72
|
[`@fastify/cors`](https://github.com/fastify/fastify-cors) for
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Every decision in the Fastify framework and its official plugins is guided by
|
|
4
4
|
the following technical principles:
|
|
5
5
|
|
|
6
|
-
1.
|
|
7
|
-
2.
|
|
6
|
+
1. "Zero" overhead in production
|
|
7
|
+
2. "Good" developer experience
|
|
8
8
|
3. Works great for small & big projects alike
|
|
9
9
|
4. Easy to migrate to microservices (or even serverless) and back
|
|
10
10
|
5. Security & data validation
|
|
@@ -219,7 +219,7 @@ reply.getHeaders() // { 'x-foo': 'foo', 'x-bar': 'bar' }
|
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
### .removeHeader(key)
|
|
222
|
-
<a id="
|
|
222
|
+
<a id="removeHeader"></a>
|
|
223
223
|
|
|
224
224
|
Remove the value of a previously set header.
|
|
225
225
|
```js
|
|
@@ -705,6 +705,11 @@ If you are sending a stream and you have not set a `'Content-Type'` header,
|
|
|
705
705
|
As noted above, streams are considered to be pre-serialized, so they will be
|
|
706
706
|
sent unmodified without response validation.
|
|
707
707
|
|
|
708
|
+
When sending streams over HTTP/2, Fastify does not change the chunks emitted by
|
|
709
|
+
the stream. If a stream can emit very large chunks, split them in your
|
|
710
|
+
application code, for example by using `fs.createReadStream()` or a transform
|
|
711
|
+
stream that emits smaller chunks.
|
|
712
|
+
|
|
708
713
|
See special note about error handling for streams in
|
|
709
714
|
[`setErrorHandler`](./Server.md#seterrorhandler).
|
|
710
715
|
|