acrylblends 0.3.0 → 0.4.0
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/dist/index.d.ts +6 -1
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/acryl-inspect/plugin.json +2 -1
- package/plugins/acryl-inspect/src/report.ts +16 -13
- package/plugins/acryl-inspect/src/service.ts +9 -7
- package/plugins/acryl-inspect/tests/report.spec.ts +7 -8
- package/plugins/acryl-inspect/tests/service.spec.ts +11 -10
- package/plugins/acryl-inspect/upstream.json +2 -2
- package/plugins/acryl-node-server/LICENSE +26 -0
- package/plugins/acryl-node-server/plugin.json +2 -1
- package/plugins/acryl-node-server/src/adapter/conninfo.ts +23 -0
- package/plugins/acryl-node-server/src/adapter/early-hints.ts +55 -0
- package/plugins/acryl-node-server/src/adapter/error.ts +11 -0
- package/plugins/acryl-node-server/src/adapter/headers.ts +249 -0
- package/plugins/acryl-node-server/src/adapter/index.ts +6 -0
- package/plugins/acryl-node-server/src/adapter/listener.ts +540 -0
- package/plugins/acryl-node-server/src/adapter/request.ts +797 -0
- package/plugins/acryl-node-server/src/adapter/response.ts +186 -0
- package/plugins/acryl-node-server/src/adapter/serve-static.ts +238 -0
- package/plugins/acryl-node-server/src/adapter/server.ts +36 -0
- package/plugins/acryl-node-server/src/adapter/types.ts +82 -0
- package/plugins/acryl-node-server/src/adapter/url.ts +42 -0
- package/plugins/acryl-node-server/src/adapter/utils/response/constants.ts +1 -0
- package/plugins/acryl-node-server/src/adapter/utils/response.ts +4 -0
- package/plugins/acryl-node-server/src/adapter/utils/stream.ts +88 -0
- package/plugins/acryl-node-server/src/adapter/utils.ts +96 -0
- package/plugins/acryl-node-server/src/adapter/websocket-types.ts +45 -0
- package/plugins/acryl-node-server/src/adapter/websocket.ts +375 -0
- package/plugins/acryl-node-server/src/index.ts +19 -6
- package/plugins/acryl-node-server/tests/adapter/app.ts +76 -0
- package/plugins/acryl-node-server/tests/adapter/assets/.static/plain.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/favicon.ico +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/secret.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/acryl.html +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/admin/secret.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/data.json +5 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/extensionless +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/foo..bar.txt +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/index.html +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/plain.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-context-path/plain.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin.br +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.br +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.zst +1 -0
- package/plugins/acryl-node-server/tests/adapter/conninfo.test.ts +34 -0
- package/plugins/acryl-node-server/tests/adapter/content-length.test.ts +248 -0
- package/plugins/acryl-node-server/tests/adapter/early-hints.test.ts +457 -0
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-cert.pem +23 -0
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-key.pem +27 -0
- package/plugins/acryl-node-server/tests/adapter/headers.test.ts +252 -0
- package/plugins/acryl-node-server/tests/adapter/helpers/request.ts +190 -0
- package/plugins/acryl-node-server/tests/adapter/listener.test.ts +727 -0
- package/plugins/acryl-node-server/tests/adapter/request-client-disconnect.test.ts +189 -0
- package/plugins/acryl-node-server/tests/adapter/request.test.ts +1230 -0
- package/plugins/acryl-node-server/tests/adapter/response.test.ts +285 -0
- package/plugins/acryl-node-server/tests/adapter/serve-static.test.ts +849 -0
- package/plugins/acryl-node-server/tests/adapter/server-socket.test.ts +790 -0
- package/plugins/acryl-node-server/tests/adapter/server.test.ts +1302 -0
- package/plugins/acryl-node-server/tests/adapter/setup.ts +16 -0
- package/plugins/acryl-node-server/tests/adapter/url.test.ts +76 -0
- package/plugins/acryl-node-server/tests/adapter/utils/response.test.ts +23 -0
- package/plugins/acryl-node-server/tests/adapter/utils/stream.test.ts +75 -0
- package/plugins/acryl-node-server/tests/adapter/utils.test.ts +235 -0
- package/plugins/acryl-node-server/tests/adapter/websocket.test.ts +260 -0
- package/plugins/acryl-node-server/tests/server.spec.ts +44 -8
- package/plugins/acryl-node-server/upstream.json +3 -3
- package/plugins/acryl-router/LICENSE +26 -0
- package/plugins/acryl-router/plugin.json +2 -1
- package/plugins/acryl-router/src/client.ts +2 -0
- package/plugins/acryl-router/src/connection.ts +42 -0
- package/plugins/acryl-router/src/core/app-base.ts +544 -0
- package/plugins/acryl-router/src/core/app.test.ts +3833 -0
- package/plugins/acryl-router/src/core/app.ts +34 -0
- package/plugins/acryl-router/src/core/client/client.test.ts +2313 -0
- package/plugins/acryl-router/src/core/client/client.ts +249 -0
- package/plugins/acryl-router/src/core/client/fetch-result-please.ts +95 -0
- package/plugins/acryl-router/src/core/client/index.ts +17 -0
- package/plugins/acryl-router/src/core/client/types.test.ts +149 -0
- package/plugins/acryl-router/src/core/client/types.ts +393 -0
- package/plugins/acryl-router/src/core/client/utils.test.ts +405 -0
- package/plugins/acryl-router/src/core/client/utils.ts +117 -0
- package/plugins/acryl-router/src/core/compose.test.ts +751 -0
- package/plugins/acryl-router/src/core/compose.ts +73 -0
- package/plugins/acryl-router/src/core/context.test.ts +629 -0
- package/plugins/acryl-router/src/core/context.ts +781 -0
- package/plugins/acryl-router/src/core/helper/accepts/accepts.test.ts +344 -0
- package/plugins/acryl-router/src/core/helper/accepts/accepts.ts +96 -0
- package/plugins/acryl-router/src/core/helper/accepts/index.ts +6 -0
- package/plugins/acryl-router/src/core/helper/adapter/index.test.ts +55 -0
- package/plugins/acryl-router/src/core/helper/adapter/index.ts +90 -0
- package/plugins/acryl-router/src/core/helper/conninfo/index.ts +6 -0
- package/plugins/acryl-router/src/core/helper/conninfo/types.ts +45 -0
- package/plugins/acryl-router/src/core/helper/cookie/index.test.ts +510 -0
- package/plugins/acryl-router/src/core/helper/cookie/index.ts +146 -0
- package/plugins/acryl-router/src/core/helper/factory/index.test.ts +434 -0
- package/plugins/acryl-router/src/core/helper/factory/index.ts +375 -0
- package/plugins/acryl-router/src/core/helper/html/index.test.ts +78 -0
- package/plugins/acryl-router/src/core/helper/html/index.ts +57 -0
- package/plugins/acryl-router/src/core/helper/route/index.test.ts +259 -0
- package/plugins/acryl-router/src/core/helper/route/index.ts +144 -0
- package/plugins/acryl-router/src/core/helper/streaming/index.ts +9 -0
- package/plugins/acryl-router/src/core/helper/streaming/sse.ts +101 -0
- package/plugins/acryl-router/src/core/helper/streaming/stream.test.ts +128 -0
- package/plugins/acryl-router/src/core/helper/streaming/stream.ts +45 -0
- package/plugins/acryl-router/src/core/helper/streaming/text.test.ts +34 -0
- package/plugins/acryl-router/src/core/helper/streaming/text.ts +15 -0
- package/plugins/acryl-router/src/core/helper/streaming/utils.ts +11 -0
- package/plugins/acryl-router/src/core/helper/testing/index.test.ts +42 -0
- package/plugins/acryl-router/src/core/helper/testing/index.ts +28 -0
- package/plugins/acryl-router/src/core/helper/websocket/index.test.ts +124 -0
- package/plugins/acryl-router/src/core/helper/websocket/index.ts +140 -0
- package/plugins/acryl-router/src/core/http-exception.test.ts +45 -0
- package/plugins/acryl-router/src/core/http-exception.ts +77 -0
- package/plugins/acryl-router/src/core/index.ts +53 -0
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.test.ts +434 -0
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.ts +152 -0
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.test.ts +1018 -0
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.ts +220 -0
- package/plugins/acryl-router/src/core/middleware/body-limit/index.test.ts +273 -0
- package/plugins/acryl-router/src/core/middleware/body-limit/index.ts +110 -0
- package/plugins/acryl-router/src/core/middleware/combine/index.test.ts +355 -0
- package/plugins/acryl-router/src/core/middleware/combine/index.ts +171 -0
- package/plugins/acryl-router/src/core/middleware/compress/index.test.ts +535 -0
- package/plugins/acryl-router/src/core/middleware/compress/index.ts +142 -0
- package/plugins/acryl-router/src/core/middleware/context-storage/index.test.ts +43 -0
- package/plugins/acryl-router/src/core/middleware/context-storage/index.ts +58 -0
- package/plugins/acryl-router/src/core/middleware/cors/index.test.ts +532 -0
- package/plugins/acryl-router/src/core/middleware/cors/index.ts +163 -0
- package/plugins/acryl-router/src/core/middleware/csrf/index.test.ts +534 -0
- package/plugins/acryl-router/src/core/middleware/csrf/index.ts +150 -0
- package/plugins/acryl-router/src/core/middleware/etag/digest.test.ts +21 -0
- package/plugins/acryl-router/src/core/middleware/etag/digest.ts +95 -0
- package/plugins/acryl-router/src/core/middleware/etag/index.test.ts +503 -0
- package/plugins/acryl-router/src/core/middleware/etag/index.ts +135 -0
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.test.ts +217 -0
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.ts +278 -0
- package/plugins/acryl-router/src/core/middleware/jwk/index.test.ts +1135 -0
- package/plugins/acryl-router/src/core/middleware/jwk/index.ts +1 -0
- package/plugins/acryl-router/src/core/middleware/jwk/jwk.ts +195 -0
- package/plugins/acryl-router/src/core/middleware/jwk/keys.test.json +48 -0
- package/plugins/acryl-router/src/core/middleware/jwt/index.test.ts +802 -0
- package/plugins/acryl-router/src/core/middleware/jwt/index.ts +9 -0
- package/plugins/acryl-router/src/core/middleware/jwt/jwt.ts +189 -0
- package/plugins/acryl-router/src/core/middleware/language/index.test.ts +552 -0
- package/plugins/acryl-router/src/core/middleware/language/index.ts +12 -0
- package/plugins/acryl-router/src/core/middleware/language/language.ts +314 -0
- package/plugins/acryl-router/src/core/middleware/logger/index.test.ts +204 -0
- package/plugins/acryl-router/src/core/middleware/logger/index.ts +95 -0
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.test.ts +292 -0
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.ts +141 -0
- package/plugins/acryl-router/src/core/middleware/method-override/index.test.ts +221 -0
- package/plugins/acryl-router/src/core/middleware/method-override/index.ts +147 -0
- package/plugins/acryl-router/src/core/middleware/powered-by/index.test.ts +37 -0
- package/plugins/acryl-router/src/core/middleware/powered-by/index.ts +35 -0
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.test.ts +218 -0
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.ts +67 -0
- package/plugins/acryl-router/src/core/middleware/request-id/index.test.ts +168 -0
- package/plugins/acryl-router/src/core/middleware/request-id/index.ts +7 -0
- package/plugins/acryl-router/src/core/middleware/request-id/request-id.ts +59 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/index.test.ts +671 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/index.ts +8 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/permissions-policy.ts +101 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/secure-headers.ts +340 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/index.test.ts +450 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/index.ts +135 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/path.test.ts +50 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/path.ts +25 -0
- package/plugins/acryl-router/src/core/middleware/timeout/index.test.ts +70 -0
- package/plugins/acryl-router/src/core/middleware/timeout/index.ts +58 -0
- package/plugins/acryl-router/src/core/middleware/timing/index.test.ts +310 -0
- package/plugins/acryl-router/src/core/middleware/timing/index.ts +8 -0
- package/plugins/acryl-router/src/core/middleware/timing/timing.ts +256 -0
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.test.ts +381 -0
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.ts +156 -0
- package/plugins/acryl-router/src/core/request/constants.ts +1 -0
- package/plugins/acryl-router/src/core/request.test.ts +751 -0
- package/plugins/acryl-router/src/core/request.ts +502 -0
- package/plugins/acryl-router/src/core/router/common.case.test.ts +1132 -0
- package/plugins/acryl-router/src/core/router/linear-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/linear-router/router.test.ts +80 -0
- package/plugins/acryl-router/src/core/router/linear-router/router.ts +152 -0
- package/plugins/acryl-router/src/core/router/pattern-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/pattern-router/router.test.ts +46 -0
- package/plugins/acryl-router/src/core/router/pattern-router/router.ts +54 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/index.ts +7 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.ts +33 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/node.ts +170 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.test.ts +154 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.ts +165 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.test.ts +265 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.ts +174 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/trie.ts +84 -0
- package/plugins/acryl-router/src/core/router/smart-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/smart-router/router.test.ts +13 -0
- package/plugins/acryl-router/src/core/router/smart-router/router.ts +70 -0
- package/plugins/acryl-router/src/core/router/trie-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/trie-router/node.test.ts +896 -0
- package/plugins/acryl-router/src/core/router/trie-router/node.ts +221 -0
- package/plugins/acryl-router/src/core/router/trie-router/router.test.ts +8 -0
- package/plugins/acryl-router/src/core/router/trie-router/router.ts +18 -0
- package/plugins/acryl-router/src/core/router/utils.ts +1 -0
- package/plugins/acryl-router/src/core/router.ts +103 -0
- package/plugins/acryl-router/src/core/types.test.ts +4134 -0
- package/plugins/acryl-router/src/core/types.ts +2782 -0
- package/plugins/acryl-router/src/core/utils/accept.test.ts +299 -0
- package/plugins/acryl-router/src/core/utils/accept.ts +268 -0
- package/plugins/acryl-router/src/core/utils/basic-auth.test.ts +56 -0
- package/plugins/acryl-router/src/core/utils/basic-auth.ts +26 -0
- package/plugins/acryl-router/src/core/utils/body.test.ts +496 -0
- package/plugins/acryl-router/src/core/utils/body.ts +263 -0
- package/plugins/acryl-router/src/core/utils/buffer.test.ts +147 -0
- package/plugins/acryl-router/src/core/utils/buffer.ts +117 -0
- package/plugins/acryl-router/src/core/utils/color.test.ts +23 -0
- package/plugins/acryl-router/src/core/utils/color.ts +56 -0
- package/plugins/acryl-router/src/core/utils/compress.ts +10 -0
- package/plugins/acryl-router/src/core/utils/concurrent.test.ts +69 -0
- package/plugins/acryl-router/src/core/utils/concurrent.ts +55 -0
- package/plugins/acryl-router/src/core/utils/constants.ts +4 -0
- package/plugins/acryl-router/src/core/utils/cookie.test.ts +460 -0
- package/plugins/acryl-router/src/core/utils/cookie.ts +281 -0
- package/plugins/acryl-router/src/core/utils/crypto.test.ts +43 -0
- package/plugins/acryl-router/src/core/utils/crypto.ts +58 -0
- package/plugins/acryl-router/src/core/utils/encode.test.ts +61 -0
- package/plugins/acryl-router/src/core/utils/encode.ts +34 -0
- package/plugins/acryl-router/src/core/utils/filepath.test.ts +78 -0
- package/plugins/acryl-router/src/core/utils/filepath.ts +60 -0
- package/plugins/acryl-router/src/core/utils/handler.ts +15 -0
- package/plugins/acryl-router/src/core/utils/headers.ts +355 -0
- package/plugins/acryl-router/src/core/utils/html.test.ts +16 -0
- package/plugins/acryl-router/src/core/utils/html.ts +182 -0
- package/plugins/acryl-router/src/core/utils/http-status.ts +72 -0
- package/plugins/acryl-router/src/core/utils/ipaddr.test.ts +149 -0
- package/plugins/acryl-router/src/core/utils/ipaddr.ts +374 -0
- package/plugins/acryl-router/src/core/utils/jwt/index.ts +7 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwa.test.ts +86 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwa.ts +38 -0
- package/plugins/acryl-router/src/core/utils/jwt/jws.ts +235 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwt.test.ts +1788 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwt.ts +292 -0
- package/plugins/acryl-router/src/core/utils/jwt/types.ts +157 -0
- package/plugins/acryl-router/src/core/utils/jwt/utf8.ts +7 -0
- package/plugins/acryl-router/src/core/utils/mime.test.ts +64 -0
- package/plugins/acryl-router/src/core/utils/mime.ts +94 -0
- package/plugins/acryl-router/src/core/utils/stream.test.ts +212 -0
- package/plugins/acryl-router/src/core/utils/stream.ts +107 -0
- package/plugins/acryl-router/src/core/utils/types.test.ts +295 -0
- package/plugins/acryl-router/src/core/utils/types.ts +123 -0
- package/plugins/acryl-router/src/core/utils/url.test.ts +384 -0
- package/plugins/acryl-router/src/core/utils/url.ts +337 -0
- package/plugins/acryl-router/src/core/validator/index.ts +8 -0
- package/plugins/acryl-router/src/core/validator/utils.test.ts +82 -0
- package/plugins/acryl-router/src/core/validator/utils.ts +69 -0
- package/plugins/acryl-router/src/core/validator/validator.test.ts +1488 -0
- package/plugins/acryl-router/src/core/validator/validator.ts +185 -0
- package/plugins/acryl-router/src/helpers/index.ts +13 -3
- package/plugins/acryl-router/src/helpers/schema-validator.ts +35 -0
- package/plugins/acryl-router/src/index.ts +6 -6
- package/plugins/acryl-router/src/middleware/index.ts +25 -6
- package/plugins/acryl-router/src/middleware/loopback-only.ts +19 -13
- package/plugins/acryl-router/src/service.ts +256 -64
- package/plugins/acryl-router/tests/docs-examples.spec.ts +152 -0
- package/plugins/acryl-router/tests/live-install.spec.ts +2 -2
- package/plugins/acryl-router/tests/loader.spec.ts +3 -2
- package/plugins/acryl-router/tests/service.spec.ts +264 -66
- package/plugins/acryl-router/tests/shadow-state.spec.ts +79 -0
- package/plugins/acryl-router/upstream.json +2 -2
- package/plugins/acryl-router-http/plugin.json +2 -1
- package/plugins/acryl-router-http/src/bridge.ts +3 -1
- package/plugins/acryl-router-http/tests/adapter.spec.ts +16 -12
- package/plugins/acryl-router-http/tests/surfaces.spec.ts +12 -10
- package/plugins/acryl-router-http/upstream.json +3 -3
- package/plugins/acryl-state/NOTICE +30 -0
- package/plugins/acryl-state/plugin.json +1 -1
- package/plugins/acryl-state/src/cell.ts +1 -1
- package/plugins/acryl-state/src/service.ts +33 -15
- package/plugins/acryl-state/upstream.json +6 -4
- package/plugins/builder/script.ts +4 -7
- package/plugins/extensions/index.ts +2 -2
- package/plugins/extensions/resolve.ts +28 -3
- package/plugins/openai/prompt.ts +9 -7
- package/plugins/tsconfig.json +5 -4
- package/templates/agent/src/routes.ts +37 -27
- package/templates/agent/test/model.test.ts +2 -1
- package/templates/agent/tsconfig.json +8 -5
- package/templates/blank/src/routes.ts +6 -4
- package/templates/blank/tsconfig.json +2 -4
- package/templates/todo/src/page.ts +1 -1
- package/templates/todo/src/todo.ts +56 -29
- package/templates/todo/tsconfig.json +2 -4
- package/templates/todo/upstream.json +2 -2
- package/plugins/acryl-router/src/compose.ts +0 -21
- package/plugins/acryl-router/src/context.ts +0 -59
- package/plugins/acryl-router/src/helpers/read-body.ts +0 -59
- package/plugins/acryl-router/src/helpers/sse.ts +0 -83
- package/plugins/acryl-router/src/helpers/validate.ts +0 -44
- package/plugins/acryl-router/src/http-error.ts +0 -21
- package/plugins/acryl-router/src/middleware/body-limit.ts +0 -25
- package/plugins/acryl-router/src/middleware/cors.ts +0 -46
- package/plugins/acryl-router/src/middleware/logger.ts +0 -21
- package/plugins/acryl-router/src/middleware/request-id.ts +0 -24
- package/plugins/acryl-router/src/middleware/secure-headers.ts +0 -23
- package/plugins/acryl-router/src/pattern.ts +0 -89
- package/plugins/acryl-router/src/registrar.ts +0 -90
- package/plugins/acryl-router/src/table.ts +0 -156
- package/plugins/acryl-router/src/types.ts +0 -73
- package/plugins/acryl-router/src/util.ts +0 -23
- package/plugins/acryl-router/tests/api.spec.ts +0 -223
- package/plugins/acryl-router/tests/conformance.ts +0 -170
- package/plugins/acryl-router/tests/helpers.spec.ts +0 -172
- package/plugins/acryl-router/tests/middleware.spec.ts +0 -183
- package/plugins/acryl-router/tests/table.spec.ts +0 -47
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello Not Compressed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello br Compressed
|
package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.zst
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello zstd Compressed
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { App } from '../../../acryl-router/src/index.ts'
|
|
2
|
+
import type { AddressType, ConnInfo } from '../../../acryl-router/src/helpers/index.ts'
|
|
3
|
+
import { getConnInfo } from '../../src/adapter/conninfo.ts'
|
|
4
|
+
|
|
5
|
+
describe('ConnInfo', () => {
|
|
6
|
+
it('Should works', async () => {
|
|
7
|
+
const app = new App().get('/', (c) => c.json(getConnInfo(c)))
|
|
8
|
+
|
|
9
|
+
const socket = {
|
|
10
|
+
remoteAddress: '0.0.0.0',
|
|
11
|
+
remoteFamily: 'IPv4',
|
|
12
|
+
remotePort: 3030,
|
|
13
|
+
}
|
|
14
|
+
expect(
|
|
15
|
+
await (
|
|
16
|
+
await app.request(
|
|
17
|
+
'/',
|
|
18
|
+
{},
|
|
19
|
+
{
|
|
20
|
+
incoming: {
|
|
21
|
+
socket,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
).json()
|
|
26
|
+
).toEqual({
|
|
27
|
+
remote: {
|
|
28
|
+
address: socket.remoteAddress,
|
|
29
|
+
addressType: socket.remoteFamily as AddressType,
|
|
30
|
+
port: socket.remotePort,
|
|
31
|
+
},
|
|
32
|
+
} satisfies ConnInfo)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { App } from '../../../acryl-router/src/index.ts'
|
|
2
|
+
import { once } from 'node:events'
|
|
3
|
+
import { createServer } from 'node:http'
|
|
4
|
+
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
5
|
+
import { createServer as createHttp2Server } from 'node:http2'
|
|
6
|
+
import { connect as connectNet } from 'node:net'
|
|
7
|
+
import type { AddressInfo } from 'node:net'
|
|
8
|
+
import { getRequestListener } from '../../src/adapter/listener.ts'
|
|
9
|
+
import { defaultContentType } from '../../src/adapter/response.ts'
|
|
10
|
+
import { createAdaptorServer } from '../../src/adapter/server.ts'
|
|
11
|
+
import { requestServer, requestServerHttp2 } from './helpers/request.ts'
|
|
12
|
+
|
|
13
|
+
// These tests exercise Node's real HTTP serializer. In addition to correctness,
|
|
14
|
+
// assert that plain headers reach writeHead with the original record:
|
|
15
|
+
// silently falling back to a copy must not hide a change to Node's internals.
|
|
16
|
+
describe('automatic Content-Length compatibility', () => {
|
|
17
|
+
it.each(['', 'hello'])('serializes a frozen record without a copy: %j', async (body) => {
|
|
18
|
+
const headers = Object.freeze({ 'content-type': 'text/plain' })
|
|
19
|
+
let writeHeadCalls: unknown[][] = []
|
|
20
|
+
const listener = getRequestListener(() => new Response(body, { headers }))
|
|
21
|
+
const server = createServer((incoming, outgoing) => {
|
|
22
|
+
writeHeadCalls = vi.spyOn(outgoing, 'writeHead').mock.calls
|
|
23
|
+
void listener(incoming, outgoing)
|
|
24
|
+
})
|
|
25
|
+
const res = await requestServer(server, { path: '/' })
|
|
26
|
+
expect(res.status).toBe(200)
|
|
27
|
+
expect(res.headers.get('content-length')).toBe(String(Buffer.byteLength(body)))
|
|
28
|
+
expect(res.headers.has('transfer-encoding')).toBe(false)
|
|
29
|
+
expect(await res.text()).toBe(body)
|
|
30
|
+
expect(writeHeadCalls[0][1]).toBe(headers)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('preserves the byte length for c.json()', async () => {
|
|
34
|
+
const app = new App()
|
|
35
|
+
app.get('/', (c) => c.json({ message: 'hello' }))
|
|
36
|
+
const server = createServer(getRequestListener(app.fetch))
|
|
37
|
+
const res = await requestServer(server, { path: '/' })
|
|
38
|
+
const text = await res.text()
|
|
39
|
+
expect(JSON.parse(text)).toEqual({ message: 'hello' })
|
|
40
|
+
expect(res.headers.get('content-type')).toBe('application/json')
|
|
41
|
+
expect(res.headers.get('content-length')).toBe(String(Buffer.byteLength(text)))
|
|
42
|
+
expect(res.headers.has('transfer-encoding')).toBe(false)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('uses automatic length for JSON with a plain header record', async () => {
|
|
46
|
+
const headers = Object.freeze({ 'Content-Type': 'application/json' })
|
|
47
|
+
let writeHeadCalls: unknown[][] = []
|
|
48
|
+
const listener = getRequestListener(
|
|
49
|
+
() => new Response(JSON.stringify({ message: 'hello' }), { headers })
|
|
50
|
+
)
|
|
51
|
+
const server = createServer((incoming, outgoing) => {
|
|
52
|
+
writeHeadCalls = vi.spyOn(outgoing, 'writeHead').mock.calls
|
|
53
|
+
void listener(incoming, outgoing)
|
|
54
|
+
})
|
|
55
|
+
const res = await requestServer(server, { path: '/' })
|
|
56
|
+
const text = await res.text()
|
|
57
|
+
expect(JSON.parse(text)).toEqual({ message: 'hello' })
|
|
58
|
+
expect(res.headers.get('content-length')).toBe(String(Buffer.byteLength(text)))
|
|
59
|
+
expect(writeHeadCalls[0][1]).toBe(headers)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('uses the UTF-8 byte length for automatic Content-Length with c.text()', async () => {
|
|
63
|
+
const app = new App()
|
|
64
|
+
app.get('/', (c) => c.text('こんにちは'))
|
|
65
|
+
let writeHeadCalls: unknown[][] = []
|
|
66
|
+
const listener = getRequestListener(app.fetch)
|
|
67
|
+
const server = createServer((incoming, outgoing) => {
|
|
68
|
+
outgoing.strictContentLength = true
|
|
69
|
+
writeHeadCalls = vi.spyOn(outgoing, 'writeHead').mock.calls
|
|
70
|
+
void listener(incoming, outgoing)
|
|
71
|
+
})
|
|
72
|
+
const res = await requestServer(server, { path: '/' })
|
|
73
|
+
expect(await res.text()).toBe('こんにちは')
|
|
74
|
+
expect(res.headers.get('content-type')).toBe(defaultContentType)
|
|
75
|
+
expect(res.headers.get('content-length')).toBe('15')
|
|
76
|
+
expect(res.headers.has('transfer-encoding')).toBe(false)
|
|
77
|
+
expect(writeHeadCalls[0][1]).toEqual({ 'Content-Type': defaultContentType })
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
describe.each([
|
|
81
|
+
{ protocol: 'HTTP/1.1', serverOptions: {}, request: requestServer },
|
|
82
|
+
{
|
|
83
|
+
protocol: 'HTTP/2',
|
|
84
|
+
serverOptions: { createServer: createHttp2Server },
|
|
85
|
+
request: requestServerHttp2,
|
|
86
|
+
},
|
|
87
|
+
])('default headers over $protocol', ({ serverOptions, request }) => {
|
|
88
|
+
it.each([
|
|
89
|
+
{ name: 'string', makeBody: (text: string) => text },
|
|
90
|
+
{ name: 'Uint8Array', makeBody: (text: string) => new TextEncoder().encode(text) },
|
|
91
|
+
{ name: 'Blob', makeBody: (text: string) => new Blob([text]) },
|
|
92
|
+
])('preserves byte lengths for a $name body', async ({ makeBody }) => {
|
|
93
|
+
const bodies = ['', 'hello']
|
|
94
|
+
let index = 0
|
|
95
|
+
const server = createAdaptorServer({
|
|
96
|
+
fetch: () => new Response(makeBody(bodies[index++])),
|
|
97
|
+
...serverOptions,
|
|
98
|
+
})
|
|
99
|
+
for (const body of bodies) {
|
|
100
|
+
const res = await request(server, { path: '/' })
|
|
101
|
+
expect(res.status).toBe(200)
|
|
102
|
+
expect(res.headers.get('content-type')).toBe(defaultContentType)
|
|
103
|
+
expect(res.headers.get('content-length')).toBe(String(Buffer.byteLength(body)))
|
|
104
|
+
expect(res.headers.has('transfer-encoding')).toBe(false)
|
|
105
|
+
expect(await res.text()).toBe(body)
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it.each([204, 304])(
|
|
111
|
+
'preserves explicit length when status %i suppresses the body',
|
|
112
|
+
async (status) => {
|
|
113
|
+
const server = createServer(getRequestListener(() => new Response('hello', { status })))
|
|
114
|
+
const res = await requestServer(server, { path: '/' })
|
|
115
|
+
expect(res.status).toBe(status)
|
|
116
|
+
expect(res.headers.get('content-length')).toBe('5')
|
|
117
|
+
expect(await res.text()).toBe('')
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
describe.each([false, true])('custom headers: %s', (customHeaders) => {
|
|
122
|
+
it.each([
|
|
123
|
+
{
|
|
124
|
+
name: 'HEAD',
|
|
125
|
+
method: 'HEAD',
|
|
126
|
+
prepare: () => {},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'previously set Content-Length',
|
|
130
|
+
method: 'GET',
|
|
131
|
+
prepare: (_incoming: IncomingMessage, outgoing: ServerResponse) => {
|
|
132
|
+
outgoing.setHeader('Content-Length', '999')
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'previously removed Content-Length',
|
|
137
|
+
method: 'GET',
|
|
138
|
+
prepare: (_incoming: IncomingMessage, outgoing: ServerResponse) => {
|
|
139
|
+
outgoing.removeHeader('Content-Length')
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'disabled default chunking',
|
|
144
|
+
method: 'GET',
|
|
145
|
+
prepare: (_incoming: IncomingMessage, outgoing: ServerResponse) => {
|
|
146
|
+
outgoing.useChunkedEncodingByDefault = false
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'unavailable native length',
|
|
151
|
+
method: 'GET',
|
|
152
|
+
prepare: (_incoming: IncomingMessage, outgoing: ServerResponse) => {
|
|
153
|
+
Object.defineProperty(outgoing, '_contentLength', { value: undefined })
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'already initialized native length',
|
|
158
|
+
method: 'GET',
|
|
159
|
+
prepare: (_incoming: IncomingMessage, outgoing: ServerResponse) => {
|
|
160
|
+
Object.defineProperty(outgoing, '_contentLength', { value: 999 })
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
])('preserves explicit length behavior for $name', async ({ method, prepare }) => {
|
|
164
|
+
const headers = customHeaders ? Object.freeze({ 'content-type': 'text/plain' }) : undefined
|
|
165
|
+
const listener = getRequestListener(() => new Response('hello', { headers }))
|
|
166
|
+
const server = createServer((incoming, outgoing) => {
|
|
167
|
+
prepare(incoming, outgoing)
|
|
168
|
+
void listener(incoming, outgoing)
|
|
169
|
+
})
|
|
170
|
+
const res = await requestServer(server, { path: '/', method })
|
|
171
|
+
expect(res.status).toBe(200)
|
|
172
|
+
expect(res.headers.get('content-length')).toBe('5')
|
|
173
|
+
expect(await res.text()).toBe(method === 'HEAD' ? '' : 'hello')
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('honors strictContentLength for JSON', async () => {
|
|
178
|
+
const app = new App()
|
|
179
|
+
app.get('/', (c) => c.json({ message: 'hello' }))
|
|
180
|
+
const listener = getRequestListener(app.fetch)
|
|
181
|
+
const server = createServer((incoming, outgoing) => {
|
|
182
|
+
outgoing.strictContentLength = true
|
|
183
|
+
void listener(incoming, outgoing)
|
|
184
|
+
})
|
|
185
|
+
const res = await requestServer(server, { path: '/' })
|
|
186
|
+
const text = await res.text()
|
|
187
|
+
expect(res.status).toBe(200)
|
|
188
|
+
expect(JSON.parse(text)).toEqual({ message: 'hello' })
|
|
189
|
+
expect(res.headers.get('content-length')).toBe(String(Buffer.byteLength(text)))
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('preserves the spelling of an explicit Content-Length value', async () => {
|
|
193
|
+
const headers = Object.freeze({ 'cOnTeNt-LeNgTh': '00005' })
|
|
194
|
+
const server = createServer(getRequestListener(() => new Response('hello', { headers })))
|
|
195
|
+
const res = await requestServer(server, { path: '/' })
|
|
196
|
+
expect(res.headers.get('content-length')).toBe('00005')
|
|
197
|
+
expect(await res.text()).toBe('hello')
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it.each([
|
|
201
|
+
{
|
|
202
|
+
name: 'an invalid header value',
|
|
203
|
+
response: () => new Response('hi', { headers: { 'x-bad': 'a\r\nb' } }),
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'an invalid status code with custom headers',
|
|
207
|
+
response: () => new Response('hi', { status: 1000, headers: { 'x-ok': '1' } }),
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'an invalid status code without custom headers',
|
|
211
|
+
response: () => new Response('hi', { status: 1000 }),
|
|
212
|
+
},
|
|
213
|
+
])('does not leak a stale length into the 500 response after $name', async ({ response }) => {
|
|
214
|
+
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
215
|
+
const server = createServer(getRequestListener(async () => response()))
|
|
216
|
+
try {
|
|
217
|
+
server.listen(0, '127.0.0.1')
|
|
218
|
+
await once(server, 'listening')
|
|
219
|
+
const { port } = server.address() as AddressInfo
|
|
220
|
+
// Read the wire response so a stale length cannot truncate the observed body.
|
|
221
|
+
const raw = await new Promise<string>((resolve, reject) => {
|
|
222
|
+
const chunks: Buffer[] = []
|
|
223
|
+
const socket = connectNet(port, '127.0.0.1', () => {
|
|
224
|
+
socket.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n')
|
|
225
|
+
})
|
|
226
|
+
socket.setTimeout(2000, () => socket.destroy(new Error('Response timed out')))
|
|
227
|
+
socket.on('data', (chunk) => chunks.push(chunk))
|
|
228
|
+
socket.on('end', () => resolve(Buffer.concat(chunks).toString('latin1')))
|
|
229
|
+
socket.on('error', reject)
|
|
230
|
+
})
|
|
231
|
+
const separator = raw.indexOf('\r\n\r\n')
|
|
232
|
+
expect(separator).toBeGreaterThan(0)
|
|
233
|
+
const head = raw.slice(0, separator)
|
|
234
|
+
const body = raw.slice(separator + 4)
|
|
235
|
+
expect(head).toMatch(/^HTTP\/1\.1 500 /)
|
|
236
|
+
expect(body).toContain('Error: ')
|
|
237
|
+
const contentLength = head.match(/^content-length: (\d+)$/im)?.[1]
|
|
238
|
+
if (contentLength !== undefined) {
|
|
239
|
+
expect(Number(contentLength)).toBe(Buffer.byteLength(body, 'latin1'))
|
|
240
|
+
} else {
|
|
241
|
+
expect(head).toMatch(/^transfer-encoding: chunked$/im)
|
|
242
|
+
}
|
|
243
|
+
} finally {
|
|
244
|
+
await new Promise<void>((resolve) => server.close(() => resolve()))
|
|
245
|
+
consoleSpy.mockRestore()
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
})
|