@lovrozagar/honey 0.6.8 → 0.7.1
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/README.md +514 -192
- package/bin/honey.js +25 -0
- package/dist/accepts.d.ts +7 -1
- package/dist/accepts.d.ts.map +1 -1
- package/dist/accepts.js +126 -0
- package/dist/accepts.js.map +1 -0
- package/dist/body-kind.d.ts +26 -0
- package/dist/body-kind.d.ts.map +1 -0
- package/dist/body-kind.js +70 -0
- package/dist/body-kind.js.map +1 -0
- package/dist/body-limit.d.ts +5 -1
- package/dist/body-limit.d.ts.map +1 -1
- package/dist/body-limit.js +126 -0
- package/dist/body-limit.js.map +1 -0
- package/dist/build/index.d.ts +19 -3
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +173 -0
- package/dist/build/index.js.map +1 -0
- package/dist/cli-args.d.ts +33 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +102 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/cli-go/auth.go +26 -0
- package/dist/cli-go/config.go +192 -0
- package/dist/cli-go/errors.go +75 -0
- package/dist/cli-go/multipart.go +79 -0
- package/dist/cli-go/output.go +163 -0
- package/dist/cli-go/root.go +30 -0
- package/dist/cli-go/stream.go +88 -0
- package/dist/cli-go/version.go +5 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +209 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/defaults.js +48 -0
- package/dist/client/defaults.js.map +1 -0
- package/dist/client/error.d.ts +35 -0
- package/dist/client/error.d.ts.map +1 -1
- package/dist/client/error.js +71 -0
- package/dist/client/error.js.map +1 -0
- package/dist/client/http.d.ts +67 -8
- package/dist/client/http.d.ts.map +1 -1
- package/dist/client/http.js +571 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +95 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/path.d.ts +26 -0
- package/dist/client/path.d.ts.map +1 -0
- package/dist/client/path.js +163 -0
- package/dist/client/path.js.map +1 -0
- package/dist/client/redirect-policy.d.ts +12 -0
- package/dist/client/redirect-policy.d.ts.map +1 -0
- package/dist/client/redirect-policy.js +20 -0
- package/dist/client/redirect-policy.js.map +1 -0
- package/dist/client/sdk.d.ts +36 -0
- package/dist/client/sdk.d.ts.map +1 -1
- package/dist/client/sdk.js +292 -0
- package/dist/client/sdk.js.map +1 -0
- package/dist/client/sse.d.ts +13 -0
- package/dist/client/sse.d.ts.map +1 -1
- package/dist/client/sse.js +129 -0
- package/dist/client/sse.js.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/client/ws.d.ts +9 -2
- package/dist/client/ws.d.ts.map +1 -1
- package/dist/client/ws.js +112 -0
- package/dist/client/ws.js.map +1 -0
- package/dist/client-go/errors.go +236 -0
- package/dist/client-go/export.go +44 -0
- package/dist/client-go/invalidation.go +371 -0
- package/dist/client-go/nullable.go +62 -0
- package/dist/client-go/realtime.go +354 -0
- package/dist/client-go/result.go +20 -0
- package/dist/client-go/runtime.go +975 -0
- package/dist/client-go/sse.go +159 -0
- package/dist/client-go/transport.go +495 -0
- package/dist/client-go/ws.go +128 -0
- package/dist/client-info.d.ts +36 -0
- package/dist/client-info.d.ts.map +1 -0
- package/dist/client-info.js +53 -0
- package/dist/client-info.js.map +1 -0
- package/dist/client-mcp/README.md +10 -0
- package/dist/client-mcp/server.ts +221 -0
- package/dist/client-mcp/types.ts +19 -0
- package/dist/client-python/_errors.py +115 -0
- package/dist/client-python/_invalidation.py +494 -0
- package/dist/client-python/_realtime.py +179 -0
- package/dist/client-python/_runtime.py +860 -0
- package/dist/client-python/_sse.py +155 -0
- package/dist/client-python/_transport.py +366 -0
- package/dist/client-python/_ws.py +159 -0
- package/dist/client-python/py.typed +0 -0
- package/dist/client-rust/errors.rs +220 -0
- package/dist/client-rust/invalidation.rs +412 -0
- package/dist/client-rust/invalidation_sync.rs +93 -0
- package/dist/client-rust/nullable.rs +17 -0
- package/dist/client-rust/realtime.rs +702 -0
- package/dist/client-rust/result.rs +22 -0
- package/dist/client-rust/runtime.rs +980 -0
- package/dist/client-rust/runtime_sync.rs +484 -0
- package/dist/client-rust/sse.rs +188 -0
- package/dist/client-rust/ws.rs +167 -0
- package/dist/codegen-go-cli.d.ts.map +1 -1
- package/dist/codegen-go-cli.js +964 -0
- package/dist/codegen-go-cli.js.map +1 -0
- package/dist/codegen-go.d.ts +15 -3
- package/dist/codegen-go.d.ts.map +1 -1
- package/dist/codegen-go.js +872 -0
- package/dist/codegen-go.js.map +1 -0
- package/dist/codegen-hash.js +9 -0
- package/dist/codegen-hash.js.map +1 -0
- package/dist/codegen-ir.d.ts +69 -2
- package/dist/codegen-ir.d.ts.map +1 -1
- package/dist/codegen-ir.js +661 -0
- package/dist/codegen-ir.js.map +1 -0
- package/dist/codegen-lang.d.ts +65 -0
- package/dist/codegen-lang.d.ts.map +1 -0
- package/dist/codegen-lang.js +526 -0
- package/dist/codegen-lang.js.map +1 -0
- package/dist/codegen-load.d.ts +31 -0
- package/dist/codegen-load.d.ts.map +1 -0
- package/dist/codegen-load.js +138 -0
- package/dist/codegen-load.js.map +1 -0
- package/dist/codegen-loaders.js +55 -0
- package/dist/codegen-loaders.js.map +1 -0
- package/dist/codegen-mcp.d.ts.map +1 -1
- package/dist/codegen-mcp.js +368 -0
- package/dist/codegen-mcp.js.map +1 -0
- package/dist/codegen-python.d.ts +13 -1
- package/dist/codegen-python.d.ts.map +1 -1
- package/dist/codegen-python.js +828 -0
- package/dist/codegen-python.js.map +1 -0
- package/dist/codegen-route-tree-intern.d.ts +15 -5
- package/dist/codegen-route-tree-intern.d.ts.map +1 -1
- package/dist/codegen-route-tree-intern.js +221 -0
- package/dist/codegen-route-tree-intern.js.map +1 -0
- package/dist/codegen-rust.d.ts.map +1 -1
- package/dist/codegen-rust.js +1293 -0
- package/dist/codegen-rust.js.map +1 -0
- package/dist/codegen-sanitize.d.ts.map +1 -1
- package/dist/codegen-sanitize.js +56 -0
- package/dist/codegen-sanitize.js.map +1 -0
- package/dist/codegen-schema-naming.d.ts +5 -0
- package/dist/codegen-schema-naming.d.ts.map +1 -1
- package/dist/codegen-schema-naming.js +150 -0
- package/dist/codegen-schema-naming.js.map +1 -0
- package/dist/codegen-sdk-model.d.ts +71 -0
- package/dist/codegen-sdk-model.d.ts.map +1 -0
- package/dist/codegen-sdk-model.js +179 -0
- package/dist/codegen-sdk-model.js.map +1 -0
- package/dist/codegen.d.ts +41 -23
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +4610 -0
- package/dist/codegen.js.map +1 -0
- package/dist/context.d.ts +36 -6
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +242 -0
- package/dist/context.js.map +1 -0
- package/dist/cookie-sign.d.ts +16 -2
- package/dist/cookie-sign.d.ts.map +1 -1
- package/dist/cookie-sign.js +104 -0
- package/dist/cookie-sign.js.map +1 -0
- package/dist/cookie.d.ts +12 -0
- package/dist/cookie.d.ts.map +1 -1
- package/dist/cookie.js +138 -0
- package/dist/cookie.js.map +1 -0
- package/dist/cors.d.ts +1 -0
- package/dist/cors.d.ts.map +1 -1
- package/dist/cors.js +87 -0
- package/dist/cors.js.map +1 -0
- package/dist/crypto.d.ts +6 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +38 -0
- package/dist/crypto.js.map +1 -0
- package/dist/csrf.d.ts +19 -0
- package/dist/csrf.d.ts.map +1 -1
- package/dist/csrf.js +79 -0
- package/dist/csrf.js.map +1 -0
- package/dist/curl-logger.d.ts +14 -3
- package/dist/curl-logger.d.ts.map +1 -1
- package/dist/curl-logger.js +199 -0
- package/dist/curl-logger.js.map +1 -0
- package/dist/detect-runtime.js +13 -0
- package/dist/detect-runtime.js.map +1 -0
- package/dist/dict.d.ts +11 -0
- package/dist/dict.d.ts.map +1 -0
- package/dist/dict.js +13 -0
- package/dist/dict.js.map +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +44 -0
- package/dist/error.js.map +1 -0
- package/dist/errors.js +39 -0
- package/dist/errors.js.map +1 -0
- package/dist/etag.d.ts +2 -0
- package/dist/etag.d.ts.map +1 -1
- package/dist/etag.js +82 -0
- package/dist/etag.js.map +1 -0
- package/dist/feature-detect.d.ts +25 -0
- package/dist/feature-detect.d.ts.map +1 -0
- package/dist/feature-detect.js +144 -0
- package/dist/feature-detect.js.map +1 -0
- package/dist/feature-load.js +36 -0
- package/dist/feature-load.js.map +1 -0
- package/dist/feature-slots.d.ts +44 -0
- package/dist/feature-slots.d.ts.map +1 -0
- package/dist/feature-slots.js +48 -0
- package/dist/feature-slots.js.map +1 -0
- package/dist/fetch-request.d.ts +10 -0
- package/dist/fetch-request.d.ts.map +1 -0
- package/dist/fetch-request.js +13 -0
- package/dist/fetch-request.js.map +1 -0
- package/dist/gen-process.d.ts +15 -0
- package/dist/gen-process.d.ts.map +1 -0
- package/dist/gen-process.js +43 -0
- package/dist/gen-process.js.map +1 -0
- package/dist/gen-write.d.ts +19 -0
- package/dist/gen-write.d.ts.map +1 -0
- package/dist/gen-write.js +120 -0
- package/dist/gen-write.js.map +1 -0
- package/dist/glob.d.ts +21 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +115 -0
- package/dist/glob.js.map +1 -0
- package/dist/go-type-emitter.d.ts +18 -4
- package/dist/go-type-emitter.d.ts.map +1 -1
- package/dist/go-type-emitter.js +594 -0
- package/dist/go-type-emitter.js.map +1 -0
- package/dist/honey-response.d.ts.map +1 -1
- package/dist/honey-response.js +338 -0
- package/dist/honey-response.js.map +1 -0
- package/dist/i18n-slot.d.ts +8 -0
- package/dist/i18n-slot.d.ts.map +1 -1
- package/dist/i18n-slot.js +14 -0
- package/dist/i18n-slot.js.map +1 -0
- package/dist/i18n.d.ts +3 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +250 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +408 -148
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2324 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +3 -5
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +140 -0
- package/dist/init.js.map +1 -0
- package/dist/input.js +4 -0
- package/dist/input.js.map +1 -0
- package/dist/invalidate-check.d.ts +11 -0
- package/dist/invalidate-check.d.ts.map +1 -1
- package/dist/invalidate-check.js +163 -0
- package/dist/invalidate-check.js.map +1 -0
- package/dist/invoke-user.d.ts +35 -0
- package/dist/invoke-user.d.ts.map +1 -0
- package/dist/invoke-user.js +73 -0
- package/dist/invoke-user.js.map +1 -0
- package/dist/ip-restrict.d.ts +13 -1
- package/dist/ip-restrict.d.ts.map +1 -1
- package/dist/ip-restrict.js +60 -0
- package/dist/ip-restrict.js.map +1 -0
- package/dist/ip.d.ts +39 -0
- package/dist/ip.d.ts.map +1 -0
- package/dist/ip.js +209 -0
- package/dist/ip.js.map +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +113 -0
- package/dist/logger.js.map +1 -0
- package/dist/media-type.d.ts +30 -0
- package/dist/media-type.d.ts.map +1 -0
- package/dist/media-type.js +97 -0
- package/dist/media-type.js.map +1 -0
- package/dist/meta-spec-merge.d.ts +32 -0
- package/dist/meta-spec-merge.d.ts.map +1 -0
- package/dist/meta-spec-merge.js +68 -0
- package/dist/meta-spec-merge.js.map +1 -0
- package/dist/meta-spec.d.ts +16 -3
- package/dist/meta-spec.d.ts.map +1 -1
- package/dist/meta-spec.js +535 -0
- package/dist/meta-spec.js.map +1 -0
- package/dist/middleware.d.ts +23 -6
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +253 -0
- package/dist/middleware.js.map +1 -0
- package/dist/node-request.d.ts +57 -12
- package/dist/node-request.d.ts.map +1 -1
- package/dist/node-request.js +407 -0
- package/dist/node-request.js.map +1 -0
- package/dist/node.d.ts +20 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +396 -0
- package/dist/node.js.map +1 -0
- package/dist/openapi/collect.d.ts +6 -3
- package/dist/openapi/collect.d.ts.map +1 -1
- package/dist/openapi/collect.js +30 -0
- package/dist/openapi/collect.js.map +1 -0
- package/dist/openapi/docs-page.d.ts +42 -0
- package/dist/openapi/docs-page.d.ts.map +1 -0
- package/dist/openapi/docs-page.js +80 -0
- package/dist/openapi/docs-page.js.map +1 -0
- package/dist/openapi/document.d.ts +4 -0
- package/dist/openapi/document.d.ts.map +1 -1
- package/dist/openapi/document.js +785 -0
- package/dist/openapi/document.js.map +1 -0
- package/dist/openapi/json-schema-slot.d.ts +7 -0
- package/dist/openapi/json-schema-slot.d.ts.map +1 -1
- package/dist/openapi/json-schema-slot.js +38 -0
- package/dist/openapi/json-schema-slot.js.map +1 -0
- package/dist/openapi/register.d.ts.map +1 -1
- package/dist/openapi/register.js +20 -0
- package/dist/openapi/register.js.map +1 -0
- package/dist/openapi/scalar.d.ts +3 -1
- package/dist/openapi/scalar.d.ts.map +1 -1
- package/dist/openapi/scalar.js +21 -0
- package/dist/openapi/scalar.js.map +1 -0
- package/dist/openapi/serve.d.ts +9 -0
- package/dist/openapi/serve.d.ts.map +1 -0
- package/dist/openapi/serve.js +36 -0
- package/dist/openapi/serve.js.map +1 -0
- package/dist/openapi/spec-factory.d.ts +30 -1
- package/dist/openapi/spec-factory.d.ts.map +1 -1
- package/dist/openapi/spec-factory.js +52 -0
- package/dist/openapi/spec-factory.js.map +1 -0
- package/dist/openapi/spec.d.ts +14 -5
- package/dist/openapi/spec.d.ts.map +1 -1
- package/dist/openapi/spec.js +50 -0
- package/dist/openapi/spec.js.map +1 -0
- package/dist/openapi/swagger.d.ts +3 -1
- package/dist/openapi/swagger.d.ts.map +1 -1
- package/dist/openapi/swagger.js +22 -0
- package/dist/openapi/swagger.js.map +1 -0
- package/dist/pattern.d.ts +71 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +239 -0
- package/dist/pattern.js.map +1 -0
- package/dist/peer.d.ts +17 -0
- package/dist/peer.d.ts.map +1 -0
- package/dist/peer.js +50 -0
- package/dist/peer.js.map +1 -0
- package/dist/plugin.d.ts +67 -16
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +649 -0
- package/dist/plugin.js.map +1 -0
- package/dist/powered-by.d.ts.map +1 -1
- package/dist/powered-by.js +11 -0
- package/dist/powered-by.js.map +1 -0
- package/dist/pretty-json.d.ts.map +1 -1
- package/dist/pretty-json.js +47 -0
- package/dist/pretty-json.js.map +1 -0
- package/dist/producer-stream.d.ts +47 -0
- package/dist/producer-stream.d.ts.map +1 -0
- package/dist/producer-stream.js +267 -0
- package/dist/producer-stream.js.map +1 -0
- package/dist/proxy.d.ts +47 -8
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +274 -0
- package/dist/proxy.js.map +1 -0
- package/dist/python-type-emitter.d.ts +14 -1
- package/dist/python-type-emitter.d.ts.map +1 -1
- package/dist/python-type-emitter.js +157 -0
- package/dist/python-type-emitter.js.map +1 -0
- package/dist/realtime/bus.d.ts +17 -1
- package/dist/realtime/bus.d.ts.map +1 -1
- package/dist/realtime/bus.js +112 -0
- package/dist/realtime/bus.js.map +1 -0
- package/dist/realtime/register.d.ts +3 -0
- package/dist/realtime/register.d.ts.map +1 -0
- package/dist/realtime/register.js +10 -0
- package/dist/realtime/register.js.map +1 -0
- package/dist/realtime/route.d.ts +65 -26
- package/dist/realtime/route.d.ts.map +1 -1
- package/dist/realtime/route.js +72 -0
- package/dist/realtime/route.js.map +1 -0
- package/dist/realtime/server.d.ts +43 -0
- package/dist/realtime/server.d.ts.map +1 -0
- package/dist/realtime/server.js +255 -0
- package/dist/realtime/server.js.map +1 -0
- package/dist/request-id.d.ts +7 -0
- package/dist/request-id.d.ts.map +1 -1
- package/dist/request-id.js +16 -0
- package/dist/request-id.js.map +1 -0
- package/dist/request-limits.d.ts +3 -0
- package/dist/request-limits.d.ts.map +1 -0
- package/dist/request-limits.js +3 -0
- package/dist/request-limits.js.map +1 -0
- package/dist/request-path.d.ts +33 -0
- package/dist/request-path.d.ts.map +1 -0
- package/dist/request-path.js +178 -0
- package/dist/request-path.js.map +1 -0
- package/dist/request-to-curl.d.ts +7 -1
- package/dist/request-to-curl.d.ts.map +1 -1
- package/dist/request-to-curl.js +48 -0
- package/dist/request-to-curl.js.map +1 -0
- package/dist/response.d.ts +25 -2
- package/dist/response.d.ts.map +1 -1
- package/dist/response.js +313 -0
- package/dist/response.js.map +1 -0
- package/dist/rust-type-emitter.d.ts +14 -2
- package/dist/rust-type-emitter.d.ts.map +1 -1
- package/dist/rust-type-emitter.js +463 -0
- package/dist/rust-type-emitter.js.map +1 -0
- package/dist/secure-headers.d.ts.map +1 -1
- package/dist/secure-headers.js +53 -0
- package/dist/secure-headers.js.map +1 -0
- package/dist/serve-register.d.ts +4 -0
- package/dist/serve-register.d.ts.map +1 -1
- package/dist/serve-register.js +9 -0
- package/dist/serve-register.js.map +1 -0
- package/dist/serve-slot.d.ts +3 -0
- package/dist/serve-slot.d.ts.map +1 -1
- package/dist/serve-slot.js +52 -0
- package/dist/serve-slot.js.map +1 -0
- package/dist/serve.d.ts +18 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +157 -0
- package/dist/serve.js.map +1 -0
- package/dist/server-timing.d.ts.map +1 -1
- package/dist/server-timing.js +51 -0
- package/dist/server-timing.js.map +1 -0
- package/dist/static.d.ts +9 -0
- package/dist/static.d.ts.map +1 -1
- package/dist/static.js +102 -0
- package/dist/static.js.map +1 -0
- package/dist/telemetry/otel.d.ts +2 -0
- package/dist/telemetry/otel.d.ts.map +1 -1
- package/dist/telemetry/otel.js +135 -0
- package/dist/telemetry/otel.js.map +1 -0
- package/dist/testing.d.ts +12 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +124 -0
- package/dist/testing.js.map +1 -0
- package/dist/timeout.d.ts +6 -0
- package/dist/timeout.d.ts.map +1 -1
- package/dist/timeout.js +36 -0
- package/dist/timeout.js.map +1 -0
- package/dist/tree.d.ts +133 -36
- package/dist/tree.d.ts.map +1 -1
- package/dist/tree.js +437 -0
- package/dist/tree.js.map +1 -0
- package/dist/trust.d.ts +21 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +100 -0
- package/dist/trust.js.map +1 -0
- package/dist/ts-type-emitter.d.ts.map +1 -1
- package/dist/ts-type-emitter.js +150 -0
- package/dist/ts-type-emitter.js.map +1 -0
- package/dist/type-emitter.d.ts +16 -2
- package/dist/type-emitter.d.ts.map +1 -1
- package/dist/type-emitter.js +729 -0
- package/dist/type-emitter.js.map +1 -0
- package/dist/type-extractor.d.ts +8 -4
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +819 -0
- package/dist/type-extractor.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +96 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +14 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +335 -0
- package/dist/validation.js.map +1 -0
- package/dist/with-headers.d.ts +15 -0
- package/dist/with-headers.d.ts.map +1 -0
- package/dist/with-headers.js +45 -0
- package/dist/with-headers.js.map +1 -0
- package/dist/ws/bun.d.ts +11 -5
- package/dist/ws/bun.d.ts.map +1 -1
- package/dist/ws/bun.js +82 -0
- package/dist/ws/bun.js.map +1 -0
- package/dist/ws/cloudflare.d.ts +25 -3
- package/dist/ws/cloudflare.d.ts.map +1 -1
- package/dist/ws/cloudflare.js +117 -0
- package/dist/ws/cloudflare.js.map +1 -0
- package/dist/ws/deno.d.ts +4 -4
- package/dist/ws/deno.d.ts.map +1 -1
- package/dist/ws/deno.js +133 -0
- package/dist/ws/deno.js.map +1 -0
- package/dist/ws/node.d.ts +20 -3
- package/dist/ws/node.d.ts.map +1 -1
- package/dist/ws/node.js +173 -0
- package/dist/ws/node.js.map +1 -0
- package/dist/ws/session.d.ts +11 -0
- package/dist/ws/session.d.ts.map +1 -0
- package/dist/ws/session.js +60 -0
- package/dist/ws/session.js.map +1 -0
- package/dist/ws/shared.d.ts +65 -0
- package/dist/ws/shared.d.ts.map +1 -0
- package/dist/ws/shared.js +103 -0
- package/dist/ws/shared.js.map +1 -0
- package/dist/ws-origin.d.ts +20 -0
- package/dist/ws-origin.d.ts.map +1 -0
- package/dist/ws-origin.js +41 -0
- package/dist/ws-origin.js.map +1 -0
- package/dist/yaml.d.ts +15 -1
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +101 -0
- package/dist/yaml.js.map +1 -0
- package/docs/invalidate-spec.md +13 -1
- package/docs/meta-spec.md +36 -12
- package/docs/packaging.md +43 -24
- package/docs/regression-matrix/README.md +32 -0
- package/docs/regression-matrix/review.md +44 -0
- package/docs/regression-matrix/ws1-3.md +97 -0
- package/docs/regression-matrix/ws4-8.md +107 -0
- package/docs/regression-matrix/ws9-12.md +266 -0
- package/docs/sdk.md +102 -52
- package/package.json +183 -52
- package/src/accepts.ts +91 -33
- package/src/body-kind.ts +67 -0
- package/src/body-limit.ts +102 -87
- package/src/build/index.ts +104 -54
- package/src/cli-args.ts +123 -0
- package/src/cli-go/auth.go +12 -1
- package/src/cli-go/config.go +29 -2
- package/src/cli-go/errors.go +28 -10
- package/src/cli-go/multipart.go +51 -27
- package/src/cli-go/output.go +58 -4
- package/src/cli-go/root.go +1 -1
- package/src/cli-go/version.go +2 -2
- package/src/cli.ts +154 -148
- package/src/client/error.ts +56 -1
- package/src/client/http.ts +479 -256
- package/src/client/index.ts +55 -17
- package/src/client/path.ts +169 -0
- package/src/client/redirect-policy.ts +19 -0
- package/src/client/sdk.ts +180 -101
- package/src/client/sse.ts +92 -66
- package/src/client/ws.ts +67 -31
- package/src/client-go/errors.go +41 -12
- package/src/client-go/export.go +44 -0
- package/src/client-go/invalidation.go +52 -54
- package/src/client-go/nullable.go +62 -0
- package/src/client-go/realtime.go +147 -110
- package/src/client-go/runtime.go +646 -88
- package/src/client-go/sse.go +104 -94
- package/src/client-go/transport.go +67 -27
- package/src/client-go/ws.go +49 -25
- package/src/client-info.ts +79 -0
- package/src/client-mcp/server.ts +133 -3
- package/src/client-python/_invalidation.py +207 -291
- package/src/client-python/_realtime.py +63 -40
- package/src/client-python/_runtime.py +501 -119
- package/src/client-python/_sse.py +130 -74
- package/src/client-python/_transport.py +37 -9
- package/src/client-python/_ws.py +50 -22
- package/src/client-rust/errors.rs +21 -1
- package/src/client-rust/invalidation.rs +202 -231
- package/src/client-rust/invalidation_sync.rs +16 -229
- package/src/client-rust/nullable.rs +17 -0
- package/src/client-rust/realtime.rs +217 -217
- package/src/client-rust/runtime.rs +602 -177
- package/src/client-rust/runtime_sync.rs +169 -145
- package/src/client-rust/sse.rs +142 -121
- package/src/client-rust/ws.rs +61 -37
- package/src/codegen-go-cli.ts +607 -728
- package/src/codegen-go.ts +710 -770
- package/src/codegen-ir.ts +381 -75
- package/src/codegen-lang.ts +517 -0
- package/src/codegen-load.ts +150 -0
- package/src/codegen-mcp.ts +207 -108
- package/src/codegen-python.ts +684 -816
- package/src/codegen-route-tree-intern.ts +51 -25
- package/src/codegen-rust.ts +946 -1240
- package/src/codegen-sanitize.ts +0 -4
- package/src/codegen-schema-naming.ts +19 -6
- package/src/codegen-sdk-model.ts +228 -0
- package/src/codegen.ts +1488 -1140
- package/src/context.ts +130 -11
- package/src/cookie-sign.ts +85 -16
- package/src/cookie.ts +66 -11
- package/src/cors.ts +55 -54
- package/src/crypto.ts +27 -5
- package/src/csrf.ts +57 -25
- package/src/curl-logger.ts +155 -114
- package/src/dict.ts +12 -0
- package/src/error.ts +4 -2
- package/src/etag.ts +58 -34
- package/src/feature-detect.ts +147 -0
- package/src/feature-slots.ts +70 -0
- package/src/fetch-request.ts +13 -0
- package/src/gen-process.ts +42 -0
- package/src/gen-write.ts +127 -0
- package/src/glob.ts +109 -0
- package/src/go-type-emitter.ts +406 -155
- package/src/honey-response.ts +36 -9
- package/src/i18n-slot.ts +10 -0
- package/src/i18n.ts +98 -23
- package/src/index.ts +1887 -1756
- package/src/init.ts +40 -28
- package/src/invalidate-check.ts +42 -4
- package/src/invoke-user.ts +95 -0
- package/src/ip-restrict.ts +47 -161
- package/src/ip.ts +194 -0
- package/src/logger.ts +65 -36
- package/src/media-type.ts +104 -0
- package/src/meta-spec-merge.ts +80 -0
- package/src/meta-spec.ts +0 -0
- package/src/middleware.ts +112 -12
- package/src/node-request.ts +242 -52
- package/src/node.ts +318 -75
- package/src/openapi/collect.ts +19 -44
- package/src/openapi/docs-page.ts +89 -0
- package/src/openapi/document.ts +503 -224
- package/src/openapi/json-schema-slot.ts +40 -0
- package/src/openapi/register.ts +7 -2
- package/src/openapi/scalar.ts +11 -10
- package/src/openapi/serve.ts +39 -0
- package/src/openapi/spec-factory.ts +50 -1
- package/src/openapi/spec.ts +53 -30
- package/src/openapi/swagger.ts +12 -11
- package/src/pattern.ts +245 -0
- package/src/peer.ts +53 -0
- package/src/plugin.ts +270 -185
- package/src/powered-by.ts +2 -2
- package/src/pretty-json.ts +25 -9
- package/src/producer-stream.ts +296 -0
- package/src/proxy.ts +253 -55
- package/src/python-type-emitter.ts +68 -56
- package/src/realtime/bus.ts +56 -9
- package/src/realtime/register.ts +13 -0
- package/src/realtime/route.ts +129 -80
- package/src/realtime/server.ts +298 -0
- package/src/request-id.ts +13 -3
- package/src/request-limits.ts +2 -0
- package/src/request-path.ts +165 -0
- package/src/request-to-curl.ts +28 -7
- package/src/response.ts +143 -103
- package/src/rust-type-emitter.ts +265 -170
- package/src/secure-headers.ts +8 -4
- package/src/serve-register.ts +4 -0
- package/src/serve-slot.ts +38 -0
- package/src/serve.ts +113 -25
- package/src/server-timing.ts +11 -7
- package/src/static.ts +85 -32
- package/src/telemetry/otel.ts +29 -7
- package/src/testing.ts +76 -14
- package/src/timeout.ts +15 -7
- package/src/tree.ts +405 -333
- package/src/trust.ts +117 -0
- package/src/ts-type-emitter.ts +18 -12
- package/src/type-emitter.ts +227 -89
- package/src/type-extractor.ts +603 -423
- package/src/types.ts +8 -0
- package/src/validation.ts +221 -96
- package/src/with-headers.ts +45 -0
- package/src/ws/bun.ts +53 -15
- package/src/ws/cloudflare.ts +81 -19
- package/src/ws/deno.ts +124 -36
- package/src/ws/node.ts +173 -79
- package/src/ws/session.ts +73 -0
- package/src/ws/shared.ts +140 -0
- package/src/ws-origin.ts +53 -0
- package/src/yaml.ts +45 -22
- package/dist/client-mcp/server.d.ts +0 -10
- package/dist/client-mcp/server.d.ts.map +0 -1
- package/dist/client-mcp/types.d.ts +0 -16
- package/dist/client-mcp/types.d.ts.map +0 -1
- package/dist/cloudflare/realtime.d.ts +0 -30
- package/dist/cloudflare/realtime.d.ts.map +0 -1
- package/dist/realtime/buffer.d.ts +0 -18
- package/dist/realtime/buffer.d.ts.map +0 -1
- package/dist/realtime/longpoll.d.ts +0 -23
- package/dist/realtime/longpoll.d.ts.map +0 -1
- package/dist/realtime/protocol.d.ts +0 -50
- package/dist/realtime/protocol.d.ts.map +0 -1
- package/dist/realtime/runtime.d.ts +0 -74
- package/dist/realtime/runtime.d.ts.map +0 -1
- package/src/cloudflare/realtime.ts +0 -234
- package/src/realtime/buffer.ts +0 -101
- package/src/realtime/longpoll.ts +0 -148
- package/src/realtime/protocol.ts +0 -128
- package/src/realtime/runtime.ts +0 -427
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sanitizeZodJsonSchema } from "../codegen-sanitize.ts"
|
|
1
2
|
import type { StandardSchemaLike } from "../types.ts"
|
|
2
3
|
|
|
3
4
|
export type JsonSchemaConverter = (schema: StandardSchemaLike, io?: "input" | "output") => Record<string, unknown>
|
|
@@ -11,3 +12,42 @@ export function setJsonSchemaConverter(next: JsonSchemaConverter | undefined): v
|
|
|
11
12
|
export function getJsonSchemaConverter(): JsonSchemaConverter | undefined {
|
|
12
13
|
return converter
|
|
13
14
|
}
|
|
15
|
+
|
|
16
|
+
type InstanceConverters = {
|
|
17
|
+
"~standard": {
|
|
18
|
+
jsonSchema?: Partial<Record<"input" | "output", (params?: unknown) => unknown>>
|
|
19
|
+
vendor: string
|
|
20
|
+
}
|
|
21
|
+
toJsonSchema?: () => unknown
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The converter used when the full codegen one is not loaded (`@lovrozagar/honey/openapi/spec`
|
|
26
|
+
* on a worker). It uses only what the schema instance carries — Zod 4's Standard JSON Schema
|
|
27
|
+
* and ArkType's `toJsonSchema()` — so it pulls in no validator package. A node JSON Schema
|
|
28
|
+
* cannot express degrades to `{}`, never the whole schema.
|
|
29
|
+
*/
|
|
30
|
+
export function instanceJsonSchema(
|
|
31
|
+
schema: StandardSchemaLike,
|
|
32
|
+
io: "input" | "output" = "output",
|
|
33
|
+
): Record<string, unknown> {
|
|
34
|
+
const s = schema as unknown as InstanceConverters
|
|
35
|
+
try {
|
|
36
|
+
const fromStandard = s["~standard"].jsonSchema?.[io]
|
|
37
|
+
if (typeof fromStandard === "function") {
|
|
38
|
+
const result = fromStandard({ libraryOptions: { unrepresentable: "any" }, target: "draft-2020-12" })
|
|
39
|
+
if (result !== null && typeof result === "object") {
|
|
40
|
+
return s["~standard"].vendor === "zod"
|
|
41
|
+
? sanitizeZodJsonSchema(result as Record<string, unknown>)
|
|
42
|
+
: (result as Record<string, unknown>)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (typeof s.toJsonSchema === "function") {
|
|
46
|
+
const result = s.toJsonSchema()
|
|
47
|
+
if (result !== null && typeof result === "object") return result as Record<string, unknown>
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
/* the schema cannot describe itself — an unconstrained schema is the honest answer */
|
|
51
|
+
}
|
|
52
|
+
return {}
|
|
53
|
+
}
|
package/src/openapi/register.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { generateManifest, generateOpenApi } from "../codegen.ts"
|
|
2
2
|
import { toYaml } from "../yaml.ts"
|
|
3
3
|
import { scalar } from "./scalar.ts"
|
|
4
|
+
import { artifactResponse, toServedArtifact } from "./serve.ts"
|
|
4
5
|
import { swagger } from "./swagger.ts"
|
|
5
6
|
import { registerOpenApiRuntime } from "./spec-factory.ts"
|
|
6
7
|
|
|
7
8
|
export function enableOpenApi(): void {
|
|
8
9
|
registerOpenApiRuntime({
|
|
10
|
+
artifactResponse,
|
|
9
11
|
docsUi: (kind, specUrl) => (kind === "swagger" ? swagger({ url: specUrl }) : scalar({ url: specUrl })),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
/* served artifacts follow the document's visibility policy and never fail on one schema */
|
|
13
|
+
generateManifest: (app, options) =>
|
|
14
|
+
Promise.resolve(generateManifest(app as never, { visibility: "published", ...options })),
|
|
15
|
+
generateOpenApi: (app, options) => generateOpenApi(app as never, { onSchemaError: "warn", ...options }),
|
|
16
|
+
toServedArtifact,
|
|
12
17
|
toYaml,
|
|
13
18
|
})
|
|
14
19
|
}
|
package/src/openapi/scalar.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TypedResponse } from "../response.ts"
|
|
2
|
+
import { docsPage, escapeAttribute, inlineJson, SCALAR } from "./docs-page.ts"
|
|
2
3
|
|
|
3
4
|
type ScalarOptions = {
|
|
4
5
|
url: string
|
|
@@ -7,11 +8,14 @@ type ScalarOptions = {
|
|
|
7
8
|
|
|
8
9
|
export function scalar(
|
|
9
10
|
options: ScalarOptions,
|
|
10
|
-
): (ctx: {
|
|
11
|
+
): (ctx: {
|
|
12
|
+
res: { html(sk: "ok", body: string, opts?: { headers?: Record<string, string> }): TypedResponse }
|
|
13
|
+
}) => TypedResponse {
|
|
11
14
|
const { url, ...rest } = options
|
|
12
|
-
const config =
|
|
15
|
+
const config = inlineJson({ url, ...rest })
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
return docsPage(
|
|
18
|
+
(nonce) => `<!DOCTYPE html>
|
|
15
19
|
<html>
|
|
16
20
|
<head>
|
|
17
21
|
<meta charset="utf-8" />
|
|
@@ -20,14 +24,11 @@ export function scalar(
|
|
|
20
24
|
</head>
|
|
21
25
|
<body>
|
|
22
26
|
<div id="app"></div>
|
|
23
|
-
<script src="
|
|
24
|
-
<script>
|
|
27
|
+
<script src="${SCALAR.js.url}" integrity="${SCALAR.js.integrity}" crossorigin="anonymous"></script>
|
|
28
|
+
<script nonce="${escapeAttribute(nonce)}">
|
|
25
29
|
Scalar.createApiReference(document.getElementById("app"), ${config})
|
|
26
30
|
</script>
|
|
27
31
|
</body>
|
|
28
|
-
</html
|
|
29
|
-
|
|
30
|
-
const handler = (ctx: { res: { html(sk: "ok", body: string): TypedResponse } }) => ctx.res.html("ok", html)
|
|
31
|
-
Object.defineProperty(handler, Symbol.for("honey.internal"), { value: true })
|
|
32
|
-
return handler
|
|
32
|
+
</html>`,
|
|
33
|
+
)
|
|
33
34
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serving side of `app.openapi()` and `app.manifest()`: serialize a document once, tag it, and
|
|
3
|
+
* answer conditional requests. Part of the lazily loaded OpenAPI feature, so none of this sits
|
|
4
|
+
* in the core bundle.
|
|
5
|
+
*/
|
|
6
|
+
import { ifNoneMatchHits } from "../etag.ts"
|
|
7
|
+
import type { ServedArtifact } from "./spec-factory.ts"
|
|
8
|
+
|
|
9
|
+
const encoder = new TextEncoder()
|
|
10
|
+
|
|
11
|
+
/** Base64url of the first 16 bytes of SHA-256, quoted: a strong validator for the exact bytes. */
|
|
12
|
+
async function entityTag(body: string): Promise<string> {
|
|
13
|
+
const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", encoder.encode(body))).subarray(0, 16)
|
|
14
|
+
let binary = ""
|
|
15
|
+
for (let i = 0; i < hash.length; i++) binary += String.fromCharCode(hash[i])
|
|
16
|
+
return `"${btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}"`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Serialize `value` once; the result is cached per route epoch by the caller. */
|
|
20
|
+
export async function toServedArtifact(body: string, contentType: string): Promise<ServedArtifact> {
|
|
21
|
+
return { body, contentType, etag: await entityTag(body) }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The response for a served artifact. Clients revalidate (`no-cache`) rather than reuse a stale
|
|
26
|
+
* document after a deploy; an unchanged document costs a 304.
|
|
27
|
+
*/
|
|
28
|
+
export function artifactResponse(request: Request, artifact: ServedArtifact): Response {
|
|
29
|
+
const headers = {
|
|
30
|
+
"cache-control": "no-cache",
|
|
31
|
+
"content-type": artifact.contentType,
|
|
32
|
+
etag: artifact.etag,
|
|
33
|
+
"x-content-type-options": "nosniff",
|
|
34
|
+
}
|
|
35
|
+
if (ifNoneMatchHits(request.headers.get("if-none-match"), artifact.etag)) {
|
|
36
|
+
return new Response(null, { headers, status: 304 })
|
|
37
|
+
}
|
|
38
|
+
return new Response(artifact.body, { headers })
|
|
39
|
+
}
|
|
@@ -6,12 +6,19 @@ export type OpenApiGenerate = (
|
|
|
6
6
|
filterRoutes?: (route: { meta: unknown; method: string; path: string }) => boolean
|
|
7
7
|
info: { description?: string; title: string; version: string }
|
|
8
8
|
invalidate?: "error" | "off" | "warn" | { entityKey?: string; level?: "error" | "off" | "warn" }
|
|
9
|
+
onSchemaError?: "throw" | "warn"
|
|
9
10
|
profile?: string
|
|
10
11
|
securitySchemes?: Record<string, unknown>
|
|
11
12
|
},
|
|
12
13
|
) => Promise<unknown>
|
|
13
14
|
|
|
14
|
-
export type ManifestGenerate = (
|
|
15
|
+
export type ManifestGenerate = (
|
|
16
|
+
app: unknown,
|
|
17
|
+
options?: {
|
|
18
|
+
filterRoutes?: (route: { meta: unknown; method: string; path: string }) => boolean
|
|
19
|
+
visibility?: "all" | "published"
|
|
20
|
+
},
|
|
21
|
+
) => Promise<unknown>
|
|
15
22
|
|
|
16
23
|
export type YamlGenerate = (value: unknown) => string
|
|
17
24
|
|
|
@@ -22,10 +29,16 @@ export type DocsUi = (
|
|
|
22
29
|
specUrl: string,
|
|
23
30
|
) => (ctx: { res: HoneyRes }) => Response | Promise<Response>
|
|
24
31
|
|
|
32
|
+
/** A served document, serialized once per route epoch: the bytes, their type and a strong ETag. */
|
|
33
|
+
export type ServedArtifact = { body: string; contentType: string; etag: string }
|
|
34
|
+
|
|
25
35
|
export type OpenApiRuntime = {
|
|
36
|
+
/** Answer a request for a served artifact: `ETag`, `Cache-Control`, and 304 on a match. */
|
|
37
|
+
artifactResponse: (request: Request, artifact: ServedArtifact) => Response
|
|
26
38
|
docsUi: DocsUi
|
|
27
39
|
generateManifest: ManifestGenerate
|
|
28
40
|
generateOpenApi: OpenApiGenerate
|
|
41
|
+
toServedArtifact: (body: string, contentType: string) => Promise<ServedArtifact>
|
|
29
42
|
toYaml: YamlGenerate
|
|
30
43
|
}
|
|
31
44
|
|
|
@@ -49,3 +62,39 @@ export function getOpenApiRuntime(): OpenApiRuntime {
|
|
|
49
62
|
export function tryGetOpenApiRuntime(): OpenApiRuntime | undefined {
|
|
50
63
|
return runtime
|
|
51
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Memoize `compute` per route epoch. A failure is cached too, until the routes change: a
|
|
68
|
+
* document that cannot be generated fails every request the same way instead of re-running the
|
|
69
|
+
* whole generation per request.
|
|
70
|
+
*/
|
|
71
|
+
export function epochCached<T>(epochOf: () => number, compute: () => Promise<T>): () => Promise<T> {
|
|
72
|
+
let entry: { epoch: number; value: Promise<T> } | null = null
|
|
73
|
+
return () => {
|
|
74
|
+
const epoch = epochOf()
|
|
75
|
+
if (entry === null || entry.epoch !== epoch) {
|
|
76
|
+
const value = Promise.resolve().then(compute)
|
|
77
|
+
/* handled here so a failure no request is awaiting yet is never an unhandled rejection */
|
|
78
|
+
value.catch(() => {})
|
|
79
|
+
entry = { epoch, value }
|
|
80
|
+
}
|
|
81
|
+
return entry.value
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const APP = Symbol.for("honey.app")
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Bind an internal handler (`spec()`, docs UIs) to the app serving it. Returns a new function
|
|
89
|
+
* per app, so one `spec()` handler mounted on two apps documents each of them — binding onto
|
|
90
|
+
* the shared function object would make the second mount throw or steal the first.
|
|
91
|
+
*/
|
|
92
|
+
export function bindInternalHandler<F extends (ctx: never, app?: unknown) => unknown>(fn: F, app: unknown): F {
|
|
93
|
+
const bound = ((ctx: never) => fn(ctx, app)) as unknown as F
|
|
94
|
+
for (const key of Reflect.ownKeys(fn)) {
|
|
95
|
+
if (typeof key !== "symbol" || key === APP) continue
|
|
96
|
+
Object.defineProperty(bound, key, { value: (fn as unknown as Record<symbol, unknown>)[key] })
|
|
97
|
+
}
|
|
98
|
+
Object.defineProperty(bound, APP, { value: app })
|
|
99
|
+
return bound
|
|
100
|
+
}
|
package/src/openapi/spec.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DefaultMeta } from "../types.ts"
|
|
2
1
|
import type { TypedResponse } from "../response.ts"
|
|
2
|
+
import type { DefaultMeta } from "../types.ts"
|
|
3
3
|
import { generateOpenApiFromTree, type OpenApiRouteInfo } from "./document.ts"
|
|
4
4
|
import { tryGetOpenApiRuntime } from "./spec-factory.ts"
|
|
5
5
|
|
|
@@ -13,38 +13,61 @@ type SpecOptions<TMeta = Record<string, unknown> | null> = {
|
|
|
13
13
|
version: string
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
type SpecCtx = { res: { raw(response: Response): TypedResponse } }
|
|
17
|
+
|
|
18
|
+
type Cached = { body: Promise<string>; epoch: number }
|
|
19
|
+
|
|
20
|
+
const JSON_HEADERS = { "content-type": "application/json; charset=utf-8" }
|
|
21
|
+
|
|
22
|
+
function appEpoch(app: object): number {
|
|
23
|
+
return (app as { _epoch?: number })._epoch ?? 0
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Serve an OpenAPI document for the app the handler is mounted on.
|
|
28
|
+
*
|
|
29
|
+
* Walks the live route graph. Schemas are converted with the full codegen converter when
|
|
30
|
+
* `@lovrozagar/honey/openapi` is loaded, and otherwise with what the schema instances carry
|
|
31
|
+
* (Zod 4, ArkType), so a worker bundle still documents bodies and parameters. The serialized
|
|
32
|
+
* document is cached per app and rebuilt when routes change; a failed build is cached for the
|
|
33
|
+
* same route graph too, so a broken schema costs one build, not one per request.
|
|
34
|
+
*/
|
|
17
35
|
export function spec<TMeta = Record<string, unknown> | null>(
|
|
18
36
|
options: SpecOptions<TMeta>,
|
|
19
|
-
): (ctx:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
): (ctx: SpecCtx, app?: unknown) => Promise<TypedResponse> {
|
|
38
|
+
const cache = new WeakMap<object, Cached>()
|
|
39
|
+
const info = { description: options.description, title: options.title, version: options.version }
|
|
40
|
+
|
|
41
|
+
const build = async (app: object): Promise<string> => {
|
|
42
|
+
const generateOptions = {
|
|
43
|
+
filterRoutes: options.filterRoutes as ((route: OpenApiRouteInfo) => boolean) | undefined,
|
|
44
|
+
info,
|
|
45
|
+
/* a served document is not an authoring moment — the check belongs to `honey generate` */
|
|
46
|
+
invalidate: "off" as const,
|
|
47
|
+
profile: options.profile,
|
|
48
|
+
securitySchemes: options.securitySchemes,
|
|
49
|
+
}
|
|
50
|
+
const runtime = tryGetOpenApiRuntime()
|
|
51
|
+
const document = runtime
|
|
52
|
+
? await runtime.generateOpenApi(app, { ...generateOptions, onSchemaError: "warn" })
|
|
53
|
+
: generateOpenApiFromTree(app, generateOptions)
|
|
54
|
+
return JSON.stringify(document)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const handler = async (ctx: SpecCtx, bound?: unknown): Promise<TypedResponse> => {
|
|
58
|
+
const app = (bound ?? Object.getOwnPropertyDescriptor(handler, Symbol.for("honey.app"))?.value) as
|
|
59
|
+
| object
|
|
60
|
+
| undefined
|
|
61
|
+
if (app === undefined) {
|
|
62
|
+
throw new Error("spec(): the handler is not mounted on an app — register it with app.get(path, spec(...))")
|
|
63
|
+
}
|
|
64
|
+
const epoch = appEpoch(app)
|
|
65
|
+
let entry = cache.get(app)
|
|
66
|
+
if (entry === undefined || entry.epoch !== epoch) {
|
|
67
|
+
entry = { body: build(app), epoch }
|
|
68
|
+
cache.set(app, entry)
|
|
46
69
|
}
|
|
47
|
-
return ctx.res.
|
|
70
|
+
return ctx.res.raw(new Response(await entry.body, { headers: JSON_HEADERS }))
|
|
48
71
|
}
|
|
49
72
|
Object.defineProperty(handler, Symbol.for("honey.internal"), { value: true })
|
|
50
73
|
return handler
|
package/src/openapi/swagger.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TypedResponse } from "../response.ts"
|
|
2
|
+
import { docsPage, escapeAttribute, inlineJson, SWAGGER_UI } from "./docs-page.ts"
|
|
2
3
|
|
|
3
4
|
type SwaggerOptions = {
|
|
4
5
|
url: string
|
|
@@ -7,28 +8,28 @@ type SwaggerOptions = {
|
|
|
7
8
|
|
|
8
9
|
export function swagger(
|
|
9
10
|
options: SwaggerOptions,
|
|
10
|
-
): (ctx: {
|
|
11
|
+
): (ctx: {
|
|
12
|
+
res: { html(sk: "ok", body: string, opts?: { headers?: Record<string, string> }): TypedResponse }
|
|
13
|
+
}) => TypedResponse {
|
|
11
14
|
const { url, ...rest } = options
|
|
12
|
-
const config =
|
|
15
|
+
const config = inlineJson({ dom_id: "#swagger-ui", url, ...rest })
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
return docsPage(
|
|
18
|
+
(nonce) => `<!DOCTYPE html>
|
|
15
19
|
<html>
|
|
16
20
|
<head>
|
|
17
21
|
<meta charset="utf-8" />
|
|
18
22
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
19
23
|
<title>Swagger UI</title>
|
|
20
|
-
<link rel="stylesheet" href="
|
|
24
|
+
<link rel="stylesheet" href="${SWAGGER_UI.css.url}" integrity="${SWAGGER_UI.css.integrity}" crossorigin="anonymous" />
|
|
21
25
|
</head>
|
|
22
26
|
<body>
|
|
23
27
|
<div id="swagger-ui"></div>
|
|
24
|
-
<script src="
|
|
25
|
-
<script>
|
|
28
|
+
<script src="${SWAGGER_UI.js.url}" integrity="${SWAGGER_UI.js.integrity}" crossorigin="anonymous"></script>
|
|
29
|
+
<script nonce="${escapeAttribute(nonce)}">
|
|
26
30
|
SwaggerUIBundle(${config})
|
|
27
31
|
</script>
|
|
28
32
|
</body>
|
|
29
|
-
</html
|
|
30
|
-
|
|
31
|
-
const handler = (ctx: { res: { html(sk: "ok", body: string): TypedResponse } }) => ctx.res.html("ok", html)
|
|
32
|
-
Object.defineProperty(handler, Symbol.for("honey.internal"), { value: true })
|
|
33
|
-
return handler
|
|
33
|
+
</html>`,
|
|
34
|
+
)
|
|
34
35
|
}
|
package/src/pattern.ts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one route-pattern grammar. Registration, the router tree, scope matching, codegen
|
|
3
|
+
* selectors and OpenAPI paths all consume the parsed form; nothing re-derives params from
|
|
4
|
+
* a pattern string with its own regex.
|
|
5
|
+
*
|
|
6
|
+
* pattern = "/" | ("/" segment)+ ["/"]
|
|
7
|
+
* segment = static | param | wildcard
|
|
8
|
+
* param = ":" name ["?"] optional only as the last segment
|
|
9
|
+
* wildcard = "*" [name] last segment only; unnamed is called "*"
|
|
10
|
+
* name = [A-Za-z_$][A-Za-z0-9_$-]*
|
|
11
|
+
*
|
|
12
|
+
* Empty segments are dropped (`//a` is `/a`), a trailing slash is not significant, and a
|
|
13
|
+
* pattern without a leading slash gets one. `.` and `..` segments are rejected.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { encodeSegment } from "./request-path.ts"
|
|
17
|
+
|
|
18
|
+
export type StaticSegment = { readonly k: "static"; readonly v: string }
|
|
19
|
+
export type ParamSegment = { readonly k: "param"; readonly n: string; readonly o: boolean }
|
|
20
|
+
export type WildcardSegment = { readonly k: "wildcard"; readonly n: string }
|
|
21
|
+
export type Segment = StaticSegment | ParamSegment | WildcardSegment
|
|
22
|
+
|
|
23
|
+
/** `METHOD /canonical/pattern` — stable identity of a route across apps, trees and codegen. */
|
|
24
|
+
export type RouteId = string
|
|
25
|
+
|
|
26
|
+
const NAME = /^[A-Za-z_$][A-Za-z0-9_$-]*$/
|
|
27
|
+
const DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i
|
|
28
|
+
|
|
29
|
+
/** Name given to a `*` wildcard without a name. */
|
|
30
|
+
export const UNNAMED_WILDCARD = "*"
|
|
31
|
+
|
|
32
|
+
function invalid(path: string, why: string): never {
|
|
33
|
+
throw new Error(`Invalid route pattern "${path}": ${why}`)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function parsePattern(path: string): Segment[] {
|
|
37
|
+
if (typeof path !== "string") invalid(String(path), "must be a string")
|
|
38
|
+
if (path.includes("#")) invalid(path, "fragments are not part of a route pattern")
|
|
39
|
+
const raw = path.split("/")
|
|
40
|
+
const segments: Segment[] = []
|
|
41
|
+
const names = new Set<string>()
|
|
42
|
+
for (let i = 0; i < raw.length; i++) {
|
|
43
|
+
const seg = raw[i]
|
|
44
|
+
if (seg === "") continue
|
|
45
|
+
/* `%2e` is a dot to every URL parser, so `/%2e%2e` can never be requested either */
|
|
46
|
+
if (DOT_SEGMENT.test(seg)) invalid(path, `"${seg}" segments are not allowed`)
|
|
47
|
+
const c = seg.charCodeAt(0)
|
|
48
|
+
if (c === 58 /* : */) {
|
|
49
|
+
const optional = seg.endsWith("?")
|
|
50
|
+
const name = optional ? seg.slice(1, -1) : seg.slice(1)
|
|
51
|
+
if (!NAME.test(name)) {
|
|
52
|
+
invalid(
|
|
53
|
+
path,
|
|
54
|
+
`parameter ":${name}" is not a valid name (letters, digits, "_", "$" and "-"; it takes the whole segment)`,
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
if (names.has(name)) invalid(path, `parameter ":${name}" appears twice`)
|
|
58
|
+
names.add(name)
|
|
59
|
+
segments.push({ k: "param", n: name, o: optional })
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
if (c === 42 /* * */) {
|
|
63
|
+
const name = seg.length > 1 ? seg.slice(1) : UNNAMED_WILDCARD
|
|
64
|
+
if (name !== UNNAMED_WILDCARD && !NAME.test(name)) {
|
|
65
|
+
invalid(path, `wildcard "*${name}" is not a valid name`)
|
|
66
|
+
}
|
|
67
|
+
if (names.has(name)) invalid(path, `"${name}" appears twice`)
|
|
68
|
+
names.add(name)
|
|
69
|
+
segments.push({ k: "wildcard", n: name })
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
if (seg.includes("?")) invalid(path, "query strings are not part of a route pattern")
|
|
73
|
+
/* the request path is percent-encoded the way URL parsing encodes it; so is a literal */
|
|
74
|
+
segments.push({ k: "static", v: encodeSegment(seg) })
|
|
75
|
+
}
|
|
76
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
77
|
+
const s = segments[i]
|
|
78
|
+
if (s.k === "wildcard") invalid(path, "a wildcard must be the last segment")
|
|
79
|
+
if (s.k === "param" && s.o) invalid(path, "an optional parameter must be the last segment")
|
|
80
|
+
}
|
|
81
|
+
return segments
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function formatSegment(seg: Segment): string {
|
|
85
|
+
if (seg.k === "static") return seg.v
|
|
86
|
+
if (seg.k === "param") return `:${seg.n}${seg.o ? "?" : ""}`
|
|
87
|
+
return seg.n === UNNAMED_WILDCARD ? "*" : `*${seg.n}`
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Canonical pattern string: leading slash, no empty segments, no trailing slash. */
|
|
91
|
+
export function canonical(segments: readonly Segment[]): string {
|
|
92
|
+
if (segments.length === 0) return "/"
|
|
93
|
+
let out = ""
|
|
94
|
+
for (const seg of segments) out += `/${formatSegment(seg)}`
|
|
95
|
+
return out
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Parse and re-print — throws on anything the grammar cannot express. */
|
|
99
|
+
export function normalizePattern(path: string): string {
|
|
100
|
+
return canonical(parsePattern(path))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Join two patterns: `joinPatterns("/api/", "users")` is `/api/users`. */
|
|
104
|
+
export function joinPatterns(base: string, path: string): string {
|
|
105
|
+
const b = parsePattern(base)
|
|
106
|
+
const p = parsePattern(path)
|
|
107
|
+
if (b.length > 0) {
|
|
108
|
+
const last = b[b.length - 1]
|
|
109
|
+
if (last.k === "wildcard" || (last.k === "param" && last.o)) {
|
|
110
|
+
if (p.length > 0) invalid(`${base}${path}`, "cannot append to a wildcard or optional parameter")
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/* re-parse: a name used on both sides (`/:id` + `/:id`) is only caught on the whole pattern */
|
|
114
|
+
return normalizePattern(canonical([...b, ...p]))
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Concrete variants of a pattern: an optional last parameter yields the pattern with and
|
|
119
|
+
* without it. Every other pattern is its own single variant.
|
|
120
|
+
*/
|
|
121
|
+
export function expandOptional(segments: readonly Segment[]): Segment[][] {
|
|
122
|
+
const last = segments[segments.length - 1]
|
|
123
|
+
if (last !== undefined && last.k === "param" && last.o) {
|
|
124
|
+
return [segments.slice(0, -1), [...segments.slice(0, -1), { k: "param", n: last.n, o: false }]]
|
|
125
|
+
}
|
|
126
|
+
return [[...segments]]
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function isStaticPattern(segments: readonly Segment[]): boolean {
|
|
130
|
+
for (const s of segments) if (s.k !== "static") return false
|
|
131
|
+
return true
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Parameter and wildcard names, in order. */
|
|
135
|
+
export function patternParams(segments: readonly Segment[]): string[] {
|
|
136
|
+
const out: string[] = []
|
|
137
|
+
for (const s of segments) if (s.k !== "static") out.push(s.n)
|
|
138
|
+
return out
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function routeId(method: string, pattern: string): RouteId {
|
|
142
|
+
return `${method} ${pattern}`
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Split a RouteId back into method and canonical pattern. */
|
|
146
|
+
export function splitRouteId(id: RouteId): { method: string; pattern: string } {
|
|
147
|
+
const sp = id.indexOf(" ")
|
|
148
|
+
return { method: id.slice(0, sp), pattern: id.slice(sp + 1) }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** OpenAPI path template: `:id` and named wildcards become `{name}`. */
|
|
152
|
+
export function toOpenApiTemplate(segments: readonly Segment[]): string {
|
|
153
|
+
if (segments.length === 0) return "/"
|
|
154
|
+
let out = ""
|
|
155
|
+
for (const s of segments) {
|
|
156
|
+
if (s.k === "static") out += `/${s.v}`
|
|
157
|
+
else if (s.k === "param") out += `/{${s.n}}`
|
|
158
|
+
else out += s.n === UNNAMED_WILDCARD ? "/{wildcard}" : `/{${s.n}}`
|
|
159
|
+
}
|
|
160
|
+
return out
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/*
|
|
164
|
+
* Scopes. `app.use("/admin", mw)` guards request paths: a path is inside the scope when its
|
|
165
|
+
* leading segments match the scope pattern — static segments literally, `:param` any one
|
|
166
|
+
* segment, `*` and an optional last param everything below. The scope uses the route
|
|
167
|
+
* grammar, so `/orgs/:id` and `/admin/*` mean what they mean in a route.
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
/** How much of a route a scope covers: every path it serves, none, or only some. */
|
|
171
|
+
export type ScopeCoverage = "all" | "none" | "some"
|
|
172
|
+
|
|
173
|
+
function coverVariant(route: readonly Segment[], scope: readonly Segment[]): ScopeCoverage {
|
|
174
|
+
let uncertain = false
|
|
175
|
+
for (let i = 0; i < scope.length; i++) {
|
|
176
|
+
const s = scope[i] as Segment
|
|
177
|
+
/* a wildcard or optional last param covers everything at and below this depth */
|
|
178
|
+
if (s.k === "wildcard" || (s.k === "param" && s.o)) return uncertain ? "some" : "all"
|
|
179
|
+
const r = route[i]
|
|
180
|
+
/* the route's paths end before the scope's do */
|
|
181
|
+
if (r === undefined) return "none"
|
|
182
|
+
/* a route wildcard serves paths both inside and outside the rest of the scope */
|
|
183
|
+
if (r.k === "wildcard") return "some"
|
|
184
|
+
if (r.k === "static") {
|
|
185
|
+
if (s.k === "static" && s.v !== r.v && safeDecode(r.v) !== safeDecode(s.v)) return "none"
|
|
186
|
+
continue
|
|
187
|
+
}
|
|
188
|
+
/* route param against a scope literal: inside the scope only when the value matches */
|
|
189
|
+
if (s.k === "static") uncertain = true
|
|
190
|
+
}
|
|
191
|
+
return uncertain ? "some" : "all"
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function combine(a: ScopeCoverage, b: ScopeCoverage): ScopeCoverage {
|
|
195
|
+
return a === b ? a : "some"
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Decide at registration time whether a scope covers a route. `"some"` means the answer
|
|
200
|
+
* depends on the request path (a route param or wildcard can land inside the scope), so the
|
|
201
|
+
* scope's middleware is guarded by {@link pathInScope} at request time.
|
|
202
|
+
*/
|
|
203
|
+
export function scopeCoverage(route: readonly Segment[], scope: readonly Segment[]): ScopeCoverage {
|
|
204
|
+
let out: ScopeCoverage | undefined
|
|
205
|
+
for (const rv of expandOptional(route)) {
|
|
206
|
+
const c = coverVariant(rv, scope)
|
|
207
|
+
out = out === undefined ? c : combine(out, c)
|
|
208
|
+
}
|
|
209
|
+
return out ?? "none"
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function safeDecode(s: string): string {
|
|
213
|
+
if (s.indexOf("%") === -1) return s
|
|
214
|
+
try {
|
|
215
|
+
return decodeURIComponent(s)
|
|
216
|
+
} catch {
|
|
217
|
+
return s
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Is a request path inside a scope? Splits the path the way the router does (empty segments
|
|
223
|
+
* dropped) and compares each segment both as sent and percent-decoded, so a route param that
|
|
224
|
+
* decodes to a scoped literal is guarded exactly like the literal.
|
|
225
|
+
*/
|
|
226
|
+
export function pathInScope(path: string, scope: readonly Segment[]): boolean {
|
|
227
|
+
let pos = 0
|
|
228
|
+
const len = path.length
|
|
229
|
+
for (let i = 0; i < scope.length; i++) {
|
|
230
|
+
const s = scope[i] as Segment
|
|
231
|
+
if (s.k === "wildcard" || (s.k === "param" && s.o)) return true
|
|
232
|
+
while (pos < len && path.charCodeAt(pos) === 47) pos++
|
|
233
|
+
if (pos >= len) return false
|
|
234
|
+
let end = path.indexOf("/", pos)
|
|
235
|
+
if (end === -1) end = len
|
|
236
|
+
if (s.k === "static") {
|
|
237
|
+
const seg = path.substring(pos, end)
|
|
238
|
+
/* both sides decoded: a literal is stored encoded (`%C3%A9`), and a request may spell the
|
|
239
|
+
* same bytes with lowercase escapes (`%c3%a9`) or raw */
|
|
240
|
+
if (seg !== s.v && safeDecode(seg) !== safeDecode(s.v)) return false
|
|
241
|
+
}
|
|
242
|
+
pos = end
|
|
243
|
+
}
|
|
244
|
+
return true
|
|
245
|
+
}
|
package/src/peer.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address of the TCP peer of a request, as the runtime reports it. Adapters register it;
|
|
3
|
+
* `ctx.ip` reads it through the app's trust setting (`trust.ts`).
|
|
4
|
+
*
|
|
5
|
+
* - Node (`serve()` from `/node`): the socket's `remoteAddress`
|
|
6
|
+
* - Bun: `server.requestIP(req)`, whether `serve()` or `Bun.serve({ fetch: app.fetch })` passed the server
|
|
7
|
+
* - Deno: `info.remoteAddr`, whether `serve()` or `Deno.serve(app.fetch)` passed the info
|
|
8
|
+
* - Cloudflare Workers: `CF-Connecting-IP`, which the edge sets and a client cannot
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type PeerSource = string | (() => string | null)
|
|
12
|
+
|
|
13
|
+
const peers = new WeakMap<object, PeerSource>()
|
|
14
|
+
|
|
15
|
+
/** A request object can report its own peer under this key (the Node shim does, allocation-free). */
|
|
16
|
+
export const PEER_ADDRESS = Symbol.for("honey.peerAddress")
|
|
17
|
+
|
|
18
|
+
/** Called by adapters before `app.fetch`. A function is called at most once, on first read. */
|
|
19
|
+
export function setPeerAddress(req: Request, address: PeerSource): void {
|
|
20
|
+
peers.set(req, address)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isWorkers(): boolean {
|
|
24
|
+
return (globalThis as { navigator?: { userAgent?: string } }).navigator?.userAgent === "Cloudflare-Workers"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type BunServerLike = { requestIP?: (req: Request) => { address?: string } | null }
|
|
28
|
+
|
|
29
|
+
export function peerAddressOf(req: Request, env: unknown): string | null {
|
|
30
|
+
const own = (req as unknown as Record<symbol, unknown>)[PEER_ADDRESS]
|
|
31
|
+
if (typeof own === "string") return own
|
|
32
|
+
const registered = peers.get(req)
|
|
33
|
+
if (registered !== undefined) {
|
|
34
|
+
if (typeof registered === "string") return registered === "" ? null : registered
|
|
35
|
+
const resolved = registered()
|
|
36
|
+
peers.set(req, resolved ?? "")
|
|
37
|
+
return resolved
|
|
38
|
+
}
|
|
39
|
+
if (env !== null && typeof env === "object") {
|
|
40
|
+
const e = env as BunServerLike & { server?: BunServerLike; remoteAddr?: { hostname?: unknown } }
|
|
41
|
+
const server = typeof e.requestIP === "function" ? e : e.server
|
|
42
|
+
if (server !== undefined && typeof server.requestIP === "function") {
|
|
43
|
+
try {
|
|
44
|
+
return server.requestIP(req)?.address ?? null
|
|
45
|
+
} catch {
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (typeof e.remoteAddr?.hostname === "string") return e.remoteAddr.hostname
|
|
50
|
+
}
|
|
51
|
+
if (isWorkers()) return req.headers.get("cf-connecting-ip")
|
|
52
|
+
return null
|
|
53
|
+
}
|