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
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { test } = require('node:test')
|
|
4
|
-
const { request } = require('undici')
|
|
4
|
+
const { request, Agent, fetch } = require('undici')
|
|
5
5
|
const Fastify = require('../..')
|
|
6
6
|
|
|
7
7
|
const { buildCertificate } = require('../build-certificate')
|
|
8
|
-
const { Agent } = require('undici')
|
|
9
8
|
test.before(buildCertificate)
|
|
10
9
|
|
|
11
10
|
test('https', async (t) => {
|
|
@@ -5,7 +5,7 @@ const errors = require('../../lib/errors')
|
|
|
5
5
|
const { readFileSync } = require('node:fs')
|
|
6
6
|
const { resolve } = require('node:path')
|
|
7
7
|
|
|
8
|
-
const expectedErrors =
|
|
8
|
+
const expectedErrors = 91
|
|
9
9
|
|
|
10
10
|
test(`should expose ${expectedErrors} errors`, t => {
|
|
11
11
|
t.plan(1)
|
|
@@ -630,6 +630,16 @@ test('FST_ERR_BAD_URL', t => {
|
|
|
630
630
|
t.assert.ok(error instanceof Error)
|
|
631
631
|
})
|
|
632
632
|
|
|
633
|
+
test('FST_ERR_MAX_PARAM_LENGTH', t => {
|
|
634
|
+
t.plan(5)
|
|
635
|
+
const error = new errors.FST_ERR_MAX_PARAM_LENGTH()
|
|
636
|
+
t.assert.strictEqual(error.name, 'FastifyError')
|
|
637
|
+
t.assert.strictEqual(error.code, 'FST_ERR_MAX_PARAM_LENGTH')
|
|
638
|
+
t.assert.strictEqual(error.message, "'%s' is exceeding the max param length")
|
|
639
|
+
t.assert.strictEqual(error.statusCode, 414)
|
|
640
|
+
t.assert.ok(error instanceof Error)
|
|
641
|
+
})
|
|
642
|
+
|
|
633
643
|
test('FST_ERR_ASYNC_CONSTRAINT', t => {
|
|
634
644
|
t.plan(5)
|
|
635
645
|
const error = new errors.FST_ERR_ASYNC_CONSTRAINT()
|
|
@@ -710,6 +720,16 @@ test('FST_ERR_ROUTE_METHOD_NOT_SUPPORTED', t => {
|
|
|
710
720
|
t.assert.ok(error instanceof Error)
|
|
711
721
|
})
|
|
712
722
|
|
|
723
|
+
test('FST_ERR_ROUTE_LOG_LEVEL_INVALID', t => {
|
|
724
|
+
t.plan(5)
|
|
725
|
+
const error = new errors.FST_ERR_ROUTE_LOG_LEVEL_INVALID()
|
|
726
|
+
t.assert.strictEqual(error.name, 'FastifyError')
|
|
727
|
+
t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_LOG_LEVEL_INVALID')
|
|
728
|
+
t.assert.strictEqual(error.message, "Log level for '%s:%s' route must be a valid logger level. Received: '%s'")
|
|
729
|
+
t.assert.strictEqual(error.statusCode, 500)
|
|
730
|
+
t.assert.ok(error instanceof TypeError)
|
|
731
|
+
})
|
|
732
|
+
|
|
713
733
|
test('FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED', t => {
|
|
714
734
|
t.plan(5)
|
|
715
735
|
const error = new errors.FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED()
|
|
@@ -810,6 +830,16 @@ test('FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER', t => {
|
|
|
810
830
|
t.assert.ok(error instanceof TypeError)
|
|
811
831
|
})
|
|
812
832
|
|
|
833
|
+
test('FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED', t => {
|
|
834
|
+
t.plan(5)
|
|
835
|
+
const error = new errors.FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED('my-dep', 'my-plugin')
|
|
836
|
+
t.assert.strictEqual(error.name, 'FastifyError')
|
|
837
|
+
t.assert.strictEqual(error.code, 'FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED')
|
|
838
|
+
t.assert.strictEqual(error.message, "The dependency 'my-dep' of plugin 'my-plugin' is not registered")
|
|
839
|
+
t.assert.strictEqual(error.statusCode, 500)
|
|
840
|
+
t.assert.ok(error instanceof Error)
|
|
841
|
+
})
|
|
842
|
+
|
|
813
843
|
test('FST_ERR_PLUGIN_CALLBACK_NOT_FN', t => {
|
|
814
844
|
t.plan(5)
|
|
815
845
|
const error = new errors.FST_ERR_PLUGIN_CALLBACK_NOT_FN()
|
|
@@ -149,7 +149,7 @@ test('checkDependencies should check if the given dependency is present in the i
|
|
|
149
149
|
})
|
|
150
150
|
|
|
151
151
|
test('checkDependencies should check if the given dependency is present in the instance (errored)', t => {
|
|
152
|
-
t.plan(
|
|
152
|
+
t.plan(3)
|
|
153
153
|
|
|
154
154
|
fn[Symbol.for('plugin-meta')] = {
|
|
155
155
|
name: 'test-plugin',
|
|
@@ -164,6 +164,8 @@ test('checkDependencies should check if the given dependency is present in the i
|
|
|
164
164
|
t.assert.fail('should throw')
|
|
165
165
|
} catch (err) {
|
|
166
166
|
t.assert.strictEqual(err.message, "The dependency 'plugin' of plugin 'test-plugin' is not registered")
|
|
167
|
+
t.assert.strictEqual(err.code, 'FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED')
|
|
168
|
+
t.assert.strictEqual(err.name, 'FastifyError')
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
function fn () {}
|
|
@@ -487,11 +487,13 @@ test('Request with undefined socket', t => {
|
|
|
487
487
|
t.assert.ok(request.compileValidationSchema instanceof Function)
|
|
488
488
|
})
|
|
489
489
|
|
|
490
|
-
test('Request with trust proxy and undefined socket', t => {
|
|
491
|
-
t.plan(
|
|
490
|
+
test('Request with trust proxy and undefined socket does not trust x-forwarded-host/proto', t => {
|
|
491
|
+
t.plan(2)
|
|
492
492
|
const headers = {
|
|
493
|
+
host: 'hostname',
|
|
493
494
|
'x-forwarded-for': '2.2.2.2, 1.1.1.1',
|
|
494
|
-
'x-forwarded-host': 'fastify.test'
|
|
495
|
+
'x-forwarded-host': 'fastify.test',
|
|
496
|
+
'x-forwarded-proto': 'https'
|
|
495
497
|
}
|
|
496
498
|
const req = {
|
|
497
499
|
method: 'GET',
|
|
@@ -502,5 +504,27 @@ test('Request with trust proxy and undefined socket', t => {
|
|
|
502
504
|
|
|
503
505
|
const TpRequest = Request.buildRequest(Request, true)
|
|
504
506
|
const request = new TpRequest('id', 'params', req, 'query', 'log')
|
|
507
|
+
t.assert.strictEqual(request.host, 'hostname')
|
|
508
|
+
t.assert.deepStrictEqual(request.protocol, undefined)
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
test('Request with trust proxy and null socket does not trust x-forwarded-host/proto', t => {
|
|
512
|
+
t.plan(2)
|
|
513
|
+
const headers = {
|
|
514
|
+
host: 'hostname',
|
|
515
|
+
'x-forwarded-for': '2.2.2.2, 1.1.1.1',
|
|
516
|
+
'x-forwarded-host': 'fastify.test',
|
|
517
|
+
'x-forwarded-proto': 'https'
|
|
518
|
+
}
|
|
519
|
+
const req = {
|
|
520
|
+
method: 'GET',
|
|
521
|
+
url: '/',
|
|
522
|
+
socket: null,
|
|
523
|
+
headers
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const TpRequest = Request.buildRequest(Request, true)
|
|
527
|
+
const request = new TpRequest('id', 'params', req, 'query', 'log')
|
|
528
|
+
t.assert.strictEqual(request.host, 'hostname')
|
|
505
529
|
t.assert.deepStrictEqual(request.protocol, undefined)
|
|
506
530
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { sep } = require('node:path')
|
|
2
2
|
const { test } = require('node:test')
|
|
3
3
|
const Fastify = require('../../fastify')
|
|
4
|
+
const { kSchemaController } = require('../../lib/symbols')
|
|
4
5
|
|
|
5
6
|
test('SchemaController are NOT loaded when the controllers are custom', async t => {
|
|
6
7
|
const app = Fastify({
|
|
@@ -22,6 +23,38 @@ test('SchemaController are NOT loaded when the controllers are custom', async t
|
|
|
22
23
|
t.assert.equal(stringifyModule, undefined, 'Stringify compiler is loaded')
|
|
23
24
|
})
|
|
24
25
|
|
|
26
|
+
test('isCustomSerializerCompiler flag is set correctly when only buildSerializer is provided', async t => {
|
|
27
|
+
const app = Fastify({
|
|
28
|
+
schemaController: {
|
|
29
|
+
compilersFactory: {
|
|
30
|
+
buildSerializer: () => () => { }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
await app.ready()
|
|
36
|
+
|
|
37
|
+
const schemaController = app[kSchemaController]
|
|
38
|
+
t.assert.equal(schemaController.isCustomValidatorCompiler, false, 'isCustomValidatorCompiler should be false')
|
|
39
|
+
t.assert.equal(schemaController.isCustomSerializerCompiler, true, 'isCustomSerializerCompiler should be true')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
test('isCustomValidatorCompiler flag is set correctly when only buildValidator is provided', async t => {
|
|
43
|
+
const app = Fastify({
|
|
44
|
+
schemaController: {
|
|
45
|
+
compilersFactory: {
|
|
46
|
+
buildValidator: () => () => { }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
await app.ready()
|
|
52
|
+
|
|
53
|
+
const schemaController = app[kSchemaController]
|
|
54
|
+
t.assert.equal(schemaController.isCustomValidatorCompiler, true, 'isCustomValidatorCompiler should be true')
|
|
55
|
+
t.assert.equal(schemaController.isCustomSerializerCompiler, false, 'isCustomSerializerCompiler should be false')
|
|
56
|
+
})
|
|
57
|
+
|
|
25
58
|
test('SchemaController are loaded when the controllers are not custom', async t => {
|
|
26
59
|
const app = Fastify()
|
|
27
60
|
await app.ready()
|
|
@@ -16,7 +16,7 @@ t.test('logging', { timeout: 60000 }, async (t) => {
|
|
|
16
16
|
let localhost
|
|
17
17
|
let localhostForURL
|
|
18
18
|
|
|
19
|
-
t.plan(
|
|
19
|
+
t.plan(15)
|
|
20
20
|
|
|
21
21
|
t.before(async function () {
|
|
22
22
|
[localhost, localhostForURL] = await helper.getLoopbackHost()
|
|
@@ -282,6 +282,23 @@ t.test('logging', { timeout: 60000 }, async (t) => {
|
|
|
282
282
|
t.assert.strictEqual(stream.readableLength, 0)
|
|
283
283
|
})
|
|
284
284
|
|
|
285
|
+
await t.test('should not log incoming request, outgoing response and route not found for 414 onMaxParamLength when disabled', async (t) => {
|
|
286
|
+
t.plan(1)
|
|
287
|
+
const stream = split(JSON.parse)
|
|
288
|
+
const fastify = Fastify({ disableRequestLogging: true, logger: { level: 'info', stream } })
|
|
289
|
+
t.after(() => fastify.close())
|
|
290
|
+
|
|
291
|
+
await fastify.ready()
|
|
292
|
+
|
|
293
|
+
await fastify.inject({
|
|
294
|
+
method: 'GET',
|
|
295
|
+
url: `/${'1234567890'.repeat(12)}`
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
// no more readable data
|
|
299
|
+
t.assert.strictEqual(stream.readableLength, 0)
|
|
300
|
+
})
|
|
301
|
+
|
|
285
302
|
await t.test('should log incoming request and outgoing response based on disableRequestLogging function', async (t) => {
|
|
286
303
|
const lines = [
|
|
287
304
|
'incoming request',
|
|
@@ -10,7 +10,7 @@ const Fastify = require('../../fastify')
|
|
|
10
10
|
const { on } = stream
|
|
11
11
|
|
|
12
12
|
t.test('logger options', { timeout: 60000 }, async (t) => {
|
|
13
|
-
t.plan(
|
|
13
|
+
t.plan(18)
|
|
14
14
|
|
|
15
15
|
await t.test('logger can be silenced', (t) => {
|
|
16
16
|
t.plan(17)
|
|
@@ -479,6 +479,43 @@ t.test('logger options', { timeout: 60000 }, async (t) => {
|
|
|
479
479
|
}
|
|
480
480
|
})
|
|
481
481
|
|
|
482
|
+
await t.test('Should throw when custom log level for a route is invalid', async (t) => {
|
|
483
|
+
t.plan(4)
|
|
484
|
+
|
|
485
|
+
const fastify = Fastify({
|
|
486
|
+
logger: true
|
|
487
|
+
})
|
|
488
|
+
t.after(() => fastify.close())
|
|
489
|
+
|
|
490
|
+
try {
|
|
491
|
+
fastify.get('/log', { logLevel: 'invalid' }, (req, reply) => {
|
|
492
|
+
reply.send({ hello: 'world' })
|
|
493
|
+
})
|
|
494
|
+
t.assert.fail('fastify.get should throw')
|
|
495
|
+
} catch (err) {
|
|
496
|
+
t.assert.ok(err)
|
|
497
|
+
t.assert.strictEqual(err.code, 'FST_ERR_ROUTE_LOG_LEVEL_INVALID')
|
|
498
|
+
t.assert.strictEqual(err.statusCode, 500)
|
|
499
|
+
t.assert.strictEqual(err.message, "Log level for 'GET:/log' route must be a valid logger level. Received: 'invalid'")
|
|
500
|
+
}
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
await t.test('Should allow null custom log level for a route', async (t) => {
|
|
504
|
+
t.plan(1)
|
|
505
|
+
|
|
506
|
+
const fastify = Fastify({
|
|
507
|
+
logger: true
|
|
508
|
+
})
|
|
509
|
+
t.after(() => fastify.close())
|
|
510
|
+
|
|
511
|
+
fastify.get('/log', { logLevel: null }, (req, reply) => {
|
|
512
|
+
reply.send({ hello: 'world' })
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
const response = await fastify.inject({ method: 'GET', url: '/log' })
|
|
516
|
+
t.assert.deepEqual(await response.json(), { hello: 'world' })
|
|
517
|
+
})
|
|
518
|
+
|
|
482
519
|
await t.test('should pass when using unWritable props in the logger option', (t) => {
|
|
483
520
|
t.plan(8)
|
|
484
521
|
const fastify = Fastify({
|
|
@@ -575,7 +575,7 @@ test('allow re-thrown error to default error handler when route handler is async
|
|
|
575
575
|
})
|
|
576
576
|
|
|
577
577
|
// Issue 2078 https://github.com/fastify/fastify/issues/2078
|
|
578
|
-
// Supported error code list:
|
|
578
|
+
// Supported error code list: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
|
579
579
|
const invalidErrorCodes = [
|
|
580
580
|
undefined,
|
|
581
581
|
null,
|
|
@@ -192,6 +192,46 @@ test('error in trailers should be ignored', (t, testDone) => {
|
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
194
|
|
|
195
|
+
test('send is called once when multiple trailer callbacks run synchronously', (t, testDone) => {
|
|
196
|
+
t.plan(6)
|
|
197
|
+
const fastify = Fastify()
|
|
198
|
+
let endCalls = 0
|
|
199
|
+
let addTrailersCalls = 0
|
|
200
|
+
|
|
201
|
+
fastify.get('/', function (request, reply) {
|
|
202
|
+
const originalEnd = reply.raw.end.bind(reply.raw)
|
|
203
|
+
reply.raw.end = function (...args) {
|
|
204
|
+
endCalls++
|
|
205
|
+
return originalEnd(...args)
|
|
206
|
+
}
|
|
207
|
+
const originalAddTrailers = reply.raw.addTrailers.bind(reply.raw)
|
|
208
|
+
reply.raw.addTrailers = function (...args) {
|
|
209
|
+
addTrailersCalls++
|
|
210
|
+
return originalAddTrailers(...args)
|
|
211
|
+
}
|
|
212
|
+
reply.trailer('Return-Early', function (reply, payload, done) {
|
|
213
|
+
done(null, 'a')
|
|
214
|
+
})
|
|
215
|
+
reply.trailer('Content-MD5', function (reply, payload, done) {
|
|
216
|
+
done(null, 'b')
|
|
217
|
+
})
|
|
218
|
+
reply.send('hello')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
fastify.inject({
|
|
222
|
+
method: 'GET',
|
|
223
|
+
url: '/'
|
|
224
|
+
}, (error, res) => {
|
|
225
|
+
t.assert.ifError(error)
|
|
226
|
+
t.assert.strictEqual(res.statusCode, 200)
|
|
227
|
+
t.assert.strictEqual(res.trailers['return-early'], 'a')
|
|
228
|
+
t.assert.strictEqual(res.trailers['content-md5'], 'b')
|
|
229
|
+
t.assert.strictEqual(endCalls, 1)
|
|
230
|
+
t.assert.strictEqual(addTrailersCalls, 1)
|
|
231
|
+
testDone()
|
|
232
|
+
})
|
|
233
|
+
})
|
|
234
|
+
|
|
195
235
|
describe('trailer handler counter', () => {
|
|
196
236
|
const data = JSON.stringify({ hello: 'world' })
|
|
197
237
|
const hash = createHash('md5')
|
|
@@ -266,6 +306,36 @@ describe('trailer handler counter', () => {
|
|
|
266
306
|
testDone()
|
|
267
307
|
})
|
|
268
308
|
})
|
|
309
|
+
|
|
310
|
+
test('mixed callback and promise trailers only use the first completion', (t, testDone) => {
|
|
311
|
+
t.plan(7)
|
|
312
|
+
const fastify = Fastify()
|
|
313
|
+
|
|
314
|
+
fastify.get('/', function (request, reply) {
|
|
315
|
+
reply.trailer('Async', function (reply, payload, done) {
|
|
316
|
+
setTimeout(() => done(null, 'async'), 10)
|
|
317
|
+
})
|
|
318
|
+
reply.trailer('Mixed', function (reply, payload, done) {
|
|
319
|
+
done(null, 'correct')
|
|
320
|
+
return Promise.resolve('corrupted')
|
|
321
|
+
})
|
|
322
|
+
reply.send('hello')
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
fastify.inject({
|
|
326
|
+
method: 'GET',
|
|
327
|
+
url: '/'
|
|
328
|
+
}, (error, res) => {
|
|
329
|
+
t.assert.ifError(error)
|
|
330
|
+
t.assert.strictEqual(res.statusCode, 200)
|
|
331
|
+
t.assert.strictEqual(res.headers['transfer-encoding'], 'chunked')
|
|
332
|
+
t.assert.strictEqual(res.headers.trailer, 'async mixed')
|
|
333
|
+
t.assert.strictEqual(res.trailers.async, 'async')
|
|
334
|
+
t.assert.strictEqual(res.trailers.mixed, 'correct')
|
|
335
|
+
t.assert.ok(!res.headers['content-length'])
|
|
336
|
+
testDone()
|
|
337
|
+
})
|
|
338
|
+
})
|
|
269
339
|
})
|
|
270
340
|
|
|
271
341
|
test('removeTrailer', (t, testDone) => {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { test } = require('node:test')
|
|
4
|
+
const Fastify = require('..')
|
|
5
|
+
|
|
6
|
+
test('request.mediaType should match the content-type header', async (t) => {
|
|
7
|
+
t.plan(2)
|
|
8
|
+
|
|
9
|
+
const fastify = Fastify()
|
|
10
|
+
|
|
11
|
+
fastify.post('/', (request, reply) => {
|
|
12
|
+
t.assert.strictEqual(request.mediaType, 'application/json')
|
|
13
|
+
reply.send({ mediaType: request.mediaType })
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const response = await fastify.inject({
|
|
17
|
+
method: 'POST',
|
|
18
|
+
url: '/',
|
|
19
|
+
body: JSON.stringify({ hello: 'world' }),
|
|
20
|
+
headers: {
|
|
21
|
+
'content-type': 'application/json'
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
const body = await response.json()
|
|
25
|
+
t.assert.strictEqual(body.mediaType, 'application/json')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('request.mediaType should strip the charset parameter', async (t) => {
|
|
29
|
+
t.plan(2)
|
|
30
|
+
|
|
31
|
+
const fastify = Fastify()
|
|
32
|
+
|
|
33
|
+
fastify.post('/', (request, reply) => {
|
|
34
|
+
t.assert.strictEqual(request.mediaType, 'application/json')
|
|
35
|
+
reply.send({ mediaType: request.mediaType })
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const response = await fastify.inject({
|
|
39
|
+
method: 'POST',
|
|
40
|
+
url: '/',
|
|
41
|
+
body: JSON.stringify({ hello: 'world' }),
|
|
42
|
+
headers: {
|
|
43
|
+
'content-type': 'application/json; charset=utf-8'
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
const body = await response.json()
|
|
47
|
+
t.assert.strictEqual(body.mediaType, 'application/json')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('request.mediaType should strip the space', async (t) => {
|
|
51
|
+
t.plan(2)
|
|
52
|
+
|
|
53
|
+
const fastify = Fastify()
|
|
54
|
+
|
|
55
|
+
fastify.post('/', (request, reply) => {
|
|
56
|
+
t.assert.strictEqual(request.mediaType, 'application/json')
|
|
57
|
+
reply.send({ mediaType: request.mediaType })
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const response = await fastify.inject({
|
|
61
|
+
method: 'POST',
|
|
62
|
+
url: '/',
|
|
63
|
+
body: JSON.stringify({ hello: 'world' }),
|
|
64
|
+
headers: {
|
|
65
|
+
'content-type': ' application/json ; charset=utf-8'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
const body = await response.json()
|
|
69
|
+
t.assert.strictEqual(body.mediaType, 'application/json')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('request.mediaType supported in hooks', async (t) => {
|
|
73
|
+
t.plan(5)
|
|
74
|
+
|
|
75
|
+
const fastify = Fastify()
|
|
76
|
+
|
|
77
|
+
fastify.post('/', {
|
|
78
|
+
preParsing: (request, reply, payload, done) => {
|
|
79
|
+
t.assert.strictEqual(request.mediaType, 'application/json')
|
|
80
|
+
done(null, payload)
|
|
81
|
+
},
|
|
82
|
+
preValidation: (request, reply, done) => {
|
|
83
|
+
t.assert.strictEqual(request.mediaType, 'application/json')
|
|
84
|
+
done()
|
|
85
|
+
},
|
|
86
|
+
preHandler: (request, reply, done) => {
|
|
87
|
+
t.assert.strictEqual(request.mediaType, 'application/json')
|
|
88
|
+
done()
|
|
89
|
+
}
|
|
90
|
+
}, (request, reply) => {
|
|
91
|
+
t.assert.strictEqual(request.mediaType, 'application/json')
|
|
92
|
+
reply.send({ mediaType: request.mediaType })
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const response = await fastify.inject({
|
|
96
|
+
method: 'POST',
|
|
97
|
+
url: '/',
|
|
98
|
+
body: JSON.stringify({ hello: 'world' }),
|
|
99
|
+
headers: {
|
|
100
|
+
'content-type': 'application/json'
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
const body = await response.json()
|
|
104
|
+
t.assert.strictEqual(body.mediaType, 'application/json')
|
|
105
|
+
})
|
|
@@ -241,6 +241,40 @@ test('Prefix with trailing /', (t, testDone) => {
|
|
|
241
241
|
completion.patience.then(testDone)
|
|
242
242
|
})
|
|
243
243
|
|
|
244
|
+
test('Prefix with trailing / and nested prefix without leading /', (t, testDone) => {
|
|
245
|
+
t.plan(4)
|
|
246
|
+
const fastify = Fastify()
|
|
247
|
+
|
|
248
|
+
fastify.register(function (fastify, opts, done) {
|
|
249
|
+
fastify.register(function (fastify, opts, done) {
|
|
250
|
+
fastify.get('/route', (req, reply) => {
|
|
251
|
+
reply.send({ hello: 'world' })
|
|
252
|
+
})
|
|
253
|
+
done()
|
|
254
|
+
}, { prefix: 'inner' })
|
|
255
|
+
done()
|
|
256
|
+
}, { prefix: '/v1/' })
|
|
257
|
+
|
|
258
|
+
const completion = waitForCb({ steps: 2 })
|
|
259
|
+
fastify.inject({
|
|
260
|
+
method: 'GET',
|
|
261
|
+
url: '/v1/inner/route'
|
|
262
|
+
}, (err, res) => {
|
|
263
|
+
t.assert.ifError(err)
|
|
264
|
+
t.assert.deepStrictEqual(JSON.parse(res.payload), { hello: 'world' })
|
|
265
|
+
completion.stepIn()
|
|
266
|
+
})
|
|
267
|
+
fastify.inject({
|
|
268
|
+
method: 'GET',
|
|
269
|
+
url: '/v1//inner/route'
|
|
270
|
+
}, (err, res) => {
|
|
271
|
+
t.assert.ifError(err)
|
|
272
|
+
t.assert.strictEqual(res.statusCode, 404)
|
|
273
|
+
completion.stepIn()
|
|
274
|
+
})
|
|
275
|
+
completion.patience.then(testDone)
|
|
276
|
+
})
|
|
277
|
+
|
|
244
278
|
test('Prefix works multiple levels deep', (t, testDone) => {
|
|
245
279
|
t.plan(2)
|
|
246
280
|
const fastify = Fastify()
|