acrylblends 0.4.1 → 0.5.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/LICENSE +73 -0
- package/docs/framework/README.md +51 -51
- package/docs/framework/UPSTREAM.md +1 -1
- package/docs/framework/agents/index.md +24 -0
- package/docs/framework/api/acryl.md +259 -0
- package/docs/framework/api/context.md +527 -0
- package/docs/framework/api/exception.md +80 -0
- package/docs/framework/api/index.md +12 -0
- package/docs/framework/api/presets.md +65 -0
- package/docs/framework/api/request.md +396 -0
- package/docs/framework/api/routing.md +303 -0
- package/docs/framework/{api-summary.md → api/summary.md} +19 -17
- package/docs/framework/concepts/benchmarks.md +26 -0
- package/docs/framework/concepts/developer-experience.md +5 -0
- package/docs/framework/concepts/middleware.md +21 -0
- package/docs/framework/concepts/motivation.md +14 -0
- package/docs/framework/concepts/routers.md +63 -0
- package/docs/framework/concepts/stacks.md +235 -0
- package/docs/framework/concepts/web-standard.md +37 -0
- package/docs/framework/{getting-started.md → cordis/acryl-in-a-cordis-app.md} +16 -16
- package/docs/framework/{concepts.md → cordis/concepts.md} +2 -2
- package/docs/framework/cordis/middleware.md +8 -0
- package/docs/framework/{migration-from-0-3.md → cordis/migration-from-0-3.md} +16 -13
- package/docs/framework/cordis/migration-from-0-4.md +14 -0
- package/docs/framework/{migration-from-dsh-webserver.md → cordis/migration-from-dsh-webserver.md} +7 -7
- package/docs/framework/{routing.md → cordis/mounting.md} +5 -108
- package/docs/framework/{node-server.md → cordis/node-server.md} +4 -4
- package/docs/framework/{surfaces.md → cordis/surfaces.md} +2 -2
- package/docs/framework/cordis/transport-and-cancellation.md +57 -0
- package/docs/framework/{validation.md → cordis/validation.md} +9 -9
- package/docs/framework/getting-started/basic.md +196 -0
- package/docs/framework/getting-started/bun.md +221 -0
- package/docs/framework/getting-started/nodejs.md +344 -0
- package/docs/framework/getting-started/other-runtimes.md +23 -0
- package/docs/framework/guides/best-practices.md +231 -0
- package/docs/framework/guides/create-acrylblends.md +79 -0
- package/docs/framework/guides/examples.md +3 -0
- package/docs/framework/guides/faq.md +19 -0
- package/docs/framework/guides/helpers.md +33 -0
- package/docs/framework/guides/jsx-dom.md +299 -0
- package/docs/framework/guides/jsx.md +440 -0
- package/docs/framework/guides/middleware.md +253 -0
- package/docs/framework/guides/rpc.md +886 -0
- package/docs/framework/guides/testing.md +133 -0
- package/docs/framework/guides/validation.md +383 -0
- package/docs/framework/helpers/accepts.md +60 -0
- package/docs/framework/helpers/adapter.md +87 -0
- package/docs/framework/helpers/conninfo.md +112 -0
- package/docs/framework/helpers/cookie.md +232 -0
- package/docs/framework/helpers/css.md +285 -0
- package/docs/framework/helpers/dev.md +67 -0
- package/docs/framework/helpers/factory.md +180 -0
- package/docs/framework/helpers/html.md +123 -0
- package/docs/framework/helpers/jwt.md +184 -0
- package/docs/framework/helpers/proxy.md +118 -0
- package/docs/framework/helpers/route.md +143 -0
- package/docs/framework/helpers/ssg.md +393 -0
- package/docs/framework/helpers/streaming.md +119 -0
- package/docs/framework/helpers/testing.md +101 -0
- package/docs/framework/helpers/websocket.md +215 -0
- package/docs/framework/middleware/builtin/basic-auth.md +165 -0
- package/docs/framework/middleware/builtin/bearer-auth.md +138 -0
- package/docs/framework/middleware/builtin/body-limit.md +71 -0
- package/docs/framework/middleware/builtin/cache.md +122 -0
- package/docs/framework/middleware/builtin/combine.md +94 -0
- package/docs/framework/middleware/builtin/compress.md +59 -0
- package/docs/framework/middleware/builtin/context-storage.md +78 -0
- package/docs/framework/middleware/builtin/cors.md +135 -0
- package/docs/framework/middleware/builtin/csrf.md +105 -0
- package/docs/framework/middleware/builtin/etag.md +54 -0
- package/docs/framework/middleware/builtin/ip-restriction.md +69 -0
- package/docs/framework/middleware/builtin/jsx-renderer.md +286 -0
- package/docs/framework/middleware/builtin/jwk.md +192 -0
- package/docs/framework/middleware/builtin/jwt.md +145 -0
- package/docs/framework/middleware/builtin/language.md +232 -0
- package/docs/framework/middleware/builtin/logger.md +74 -0
- package/docs/framework/middleware/builtin/loopback-only.md +31 -0
- package/docs/framework/middleware/builtin/method-not-allowed.md +48 -0
- package/docs/framework/middleware/builtin/method-override.md +80 -0
- package/docs/framework/middleware/builtin/mount.md +106 -0
- package/docs/framework/middleware/builtin/pretty-json.md +53 -0
- package/docs/framework/middleware/builtin/request-id.md +94 -0
- package/docs/framework/middleware/builtin/secure-headers.md +247 -0
- package/docs/framework/middleware/builtin/timeout.md +98 -0
- package/docs/framework/middleware/builtin/timing.md +101 -0
- package/docs/framework/middleware/builtin/trailing-slash.md +74 -0
- package/docs/framework/middleware/third-party.md +4 -0
- package/docs/framework/upstream.json +3 -3
- package/lib/accepts-XBuZPVRI.js +52 -0
- package/lib/accepts.d.ts +33 -0
- package/lib/accepts.js +2 -0
- package/lib/acryl-base.d.ts +2 -0
- package/lib/acryl-base.js +332 -0
- package/lib/adapter.d.ts +12 -0
- package/lib/adapter.js +37 -0
- package/lib/app-BM0rTCp7.js +26 -0
- package/lib/app-CmAYW1Al.d.ts +21 -0
- package/lib/basic-auth.d.ts +72 -0
- package/lib/basic-auth.js +95 -0
- package/lib/bearer-auth.d.ts +89 -0
- package/lib/bearer-auth.js +94 -0
- package/lib/body-limit.d.ts +42 -0
- package/lib/body-limit.js +66 -0
- package/lib/client-BHTr318g.js +266 -0
- package/lib/client.d.ts +3 -0
- package/lib/client.js +2 -0
- package/lib/combine.d.ts +85 -0
- package/lib/combine.js +137 -0
- package/lib/compose-BuW2B6PZ.js +50 -0
- package/lib/compress.d.ts +38 -0
- package/lib/compress.js +79 -0
- package/lib/connection-C7xgP1hP.js +24 -0
- package/lib/conninfo.d.ts +25 -0
- package/lib/conninfo.js +2 -0
- package/lib/constants-Dy7ZvN1H.js +4 -0
- package/lib/context-Bm7rI-oK.d.ts +1234 -0
- package/lib/context-DDO0cfuP.js +365 -0
- package/lib/context-storage.d.ts +38 -0
- package/lib/context-storage.js +52 -0
- package/lib/cookie-ClMaKDQf.d.ts +40 -0
- package/lib/cookie.d.ts +24 -0
- package/lib/cookie.js +82 -0
- package/lib/cors.d.ts +52 -0
- package/lib/cors.js +106 -0
- package/lib/csrf.d.ts +75 -0
- package/lib/csrf.js +101 -0
- package/lib/etag.d.ts +40 -0
- package/lib/etag.js +135 -0
- package/lib/factory.d.ts +35 -0
- package/lib/factory.js +30 -0
- package/lib/headers-tu2YYN8T.d.ts +11 -0
- package/lib/html.d.ts +6 -0
- package/lib/html.js +31 -0
- package/lib/http-exception.d.ts +57 -0
- package/lib/http-exception.js +54 -0
- package/lib/http-status-DaAwGAFL.d.ts +35 -0
- package/lib/index-B-3F4wt2.d.ts +12 -0
- package/lib/index-UTBmM3GX.d.ts +68 -0
- package/lib/index-oOClm_Xk.d.ts +45 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +28 -0
- package/lib/ip-restriction.d.ts +68 -0
- package/lib/ip-restriction.js +166 -0
- package/lib/jwk.d.ts +52 -0
- package/lib/jwk.js +117 -0
- package/lib/jwt-BGJBw5AF.js +403 -0
- package/lib/jwt-Dg493Tai.d.ts +51 -0
- package/lib/jwt.d.ts +72 -0
- package/lib/jwt.js +115 -0
- package/lib/language.d.ts +88 -0
- package/lib/language.js +198 -0
- package/lib/logger.d.ts +22 -0
- package/lib/logger.js +54 -0
- package/lib/loopback-only.d.ts +45 -0
- package/lib/loopback-only.js +90 -0
- package/lib/method-not-allowed.d.ts +47 -0
- package/lib/method-not-allowed.js +82 -0
- package/lib/method-override.d.ts +46 -0
- package/lib/method-override.js +103 -0
- package/lib/mime-BQOYHl-l.d.ts +72 -0
- package/lib/node-server/conninfo.d.ts +11 -0
- package/lib/node-server/conninfo.js +19 -0
- package/lib/node-server/serve-static.d.ts +19 -0
- package/lib/node-server/serve-static.js +2 -0
- package/lib/node-server.d.ts +103 -0
- package/lib/node-server.js +1325 -0
- package/lib/powered-by.d.ts +28 -0
- package/lib/powered-by.js +24 -0
- package/lib/pretty-json.d.ts +40 -0
- package/lib/pretty-json.js +39 -0
- package/lib/reg-exp-router-DC1R3qoY.js +363 -0
- package/lib/request-id.d.ts +45 -0
- package/lib/request-id.js +34 -0
- package/lib/request.d.ts +2 -0
- package/lib/request.js +323 -0
- package/lib/route.d.ts +78 -0
- package/lib/route.js +126 -0
- package/lib/router/linear-router.d.ts +11 -0
- package/lib/router/linear-router.js +96 -0
- package/lib/router/pattern-router.d.ts +11 -0
- package/lib/router/pattern-router.js +41 -0
- package/lib/router/reg-exp-router.d.ts +35 -0
- package/lib/router/reg-exp-router.js +2 -0
- package/lib/router/smart-router.d.ts +15 -0
- package/lib/router/smart-router.js +2 -0
- package/lib/router/trie-router.d.ts +11 -0
- package/lib/router/trie-router.js +2 -0
- package/lib/router-CvUxUTOq.d.ts +99 -0
- package/lib/router.d.ts +2 -0
- package/lib/router.js +35 -0
- package/lib/schema-validator.d.ts +28 -0
- package/lib/schema-validator.js +22 -0
- package/lib/secure-headers.d.ts +125 -0
- package/lib/secure-headers.js +163 -0
- package/lib/serve-static-Dw_m6KxR.js +213 -0
- package/lib/serve-static.d.ts +31 -0
- package/lib/serve-static.js +77 -0
- package/lib/smart-router-C5CZ5XSM.js +49 -0
- package/lib/stream-CPdqZ0Fp.d.ts +34 -0
- package/lib/streaming-DHST3Scg.js +96 -0
- package/lib/streaming.d.ts +23 -0
- package/lib/streaming.js +2 -0
- package/lib/testing.d.ts +10 -0
- package/lib/testing.js +17 -0
- package/lib/timeout.d.ts +30 -0
- package/lib/timeout.js +42 -0
- package/lib/timing.d.ts +130 -0
- package/lib/timing.js +183 -0
- package/lib/trailing-slash.d.ts +91 -0
- package/lib/trailing-slash.js +85 -0
- package/lib/trie-router-CfFbapzL.js +146 -0
- package/lib/types-CDO6I3B0.d.ts +40 -0
- package/lib/types-CHesD1KG.d.ts +195 -0
- package/lib/types-CwrQjlaM.d.ts +105 -0
- package/lib/types-DR95J00T.d.ts +29 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +4 -0
- package/lib/utils/accept.d.ts +9 -0
- package/lib/utils/accept.js +193 -0
- package/lib/utils/basic-auth.d.ts +8 -0
- package/lib/utils/basic-auth.js +20 -0
- package/lib/utils/body.d.ts +2 -0
- package/lib/utils/body.js +94 -0
- package/lib/utils/buffer.d.ts +19 -0
- package/lib/utils/buffer.js +51 -0
- package/lib/utils/color.d.ts +24 -0
- package/lib/utils/color.js +37 -0
- package/lib/utils/compress.d.ts +11 -0
- package/lib/utils/compress.js +11 -0
- package/lib/utils/concurrent.d.ts +17 -0
- package/lib/utils/concurrent.js +30 -0
- package/lib/utils/constants.d.ts +7 -0
- package/lib/utils/constants.js +7 -0
- package/lib/utils/cookie.d.ts +2 -0
- package/lib/utils/cookie.js +125 -0
- package/lib/utils/crypto.d.ts +14 -0
- package/lib/utils/crypto.js +34 -0
- package/lib/utils/encode.d.ts +11 -0
- package/lib/utils/encode.js +33 -0
- package/lib/utils/filepath.d.ts +14 -0
- package/lib/utils/filepath.js +25 -0
- package/lib/utils/handler.d.ts +9 -0
- package/lib/utils/handler.js +12 -0
- package/lib/utils/headers.d.ts +2 -0
- package/lib/utils/headers.js +1 -0
- package/lib/utils/html.d.ts +46 -0
- package/lib/utils/html.js +103 -0
- package/lib/utils/http-status.d.ts +2 -0
- package/lib/utils/http-status.js +1 -0
- package/lib/utils/ipaddr.d.ts +56 -0
- package/lib/utils/ipaddr.js +238 -0
- package/lib/utils/jwt.d.ts +24 -0
- package/lib/utils/jwt.js +2 -0
- package/lib/utils/mime.d.ts +2 -0
- package/lib/utils/mime.js +77 -0
- package/lib/utils/stream.d.ts +2 -0
- package/lib/utils/stream.js +88 -0
- package/lib/utils/types.d.ts +2 -0
- package/lib/utils/types.js +1 -0
- package/lib/utils/url.d.ts +46 -0
- package/lib/utils/url.js +197 -0
- package/lib/utils-dw8lxqjL.js +4 -0
- package/lib/validator-D84mq-dO.js +65 -0
- package/lib/validator.d.ts +42 -0
- package/lib/validator.js +2 -0
- package/lib/ws.d.ts +2 -0
- package/lib/ws.js +53 -0
- package/package.json +312 -14
- package/plugins/acryl-inspect/src/service.ts +2 -2
- package/plugins/acryl-inspect/tests/service.spec.ts +3 -3
- package/plugins/acryl-inspect/upstream.json +2 -2
- package/plugins/acryl-node-server/tests/adapter/app.ts +2 -2
- package/plugins/acryl-node-server/tests/adapter/assets/static/acryl.html +1 -1
- package/plugins/acryl-node-server/tests/adapter/assets/static/index.html +1 -1
- package/plugins/acryl-node-server/tests/adapter/conninfo.test.ts +2 -2
- package/plugins/acryl-node-server/tests/adapter/content-length.test.ts +4 -4
- package/plugins/acryl-node-server/tests/adapter/early-hints.test.ts +5 -5
- package/plugins/acryl-node-server/tests/adapter/request-client-disconnect.test.ts +2 -2
- package/plugins/acryl-node-server/tests/adapter/serve-static.test.ts +20 -20
- package/plugins/acryl-node-server/tests/adapter/server-socket.test.ts +2 -2
- package/plugins/acryl-node-server/tests/adapter/server.test.ts +50 -50
- package/plugins/acryl-node-server/tests/adapter/utils/response.test.ts +4 -4
- package/plugins/acryl-node-server/tests/adapter/websocket.test.ts +9 -9
- package/plugins/acryl-node-server/tests/server.spec.ts +6 -6
- package/plugins/acryl-node-server/upstream.json +2 -2
- package/plugins/acryl-router/src/client.ts +1 -1
- package/plugins/acryl-router/src/connection.ts +2 -2
- package/plugins/acryl-router/src/core/app-base.ts +29 -29
- package/plugins/acryl-router/src/core/app.test.ts +175 -175
- package/plugins/acryl-router/src/core/app.ts +8 -8
- package/plugins/acryl-router/src/core/client/client.test.ts +76 -76
- package/plugins/acryl-router/src/core/client/client.ts +2 -2
- package/plugins/acryl-router/src/core/client/fetch-result-please.ts +1 -1
- package/plugins/acryl-router/src/core/client/index.ts +1 -1
- package/plugins/acryl-router/src/core/client/types.test.ts +6 -6
- package/plugins/acryl-router/src/core/client/types.ts +16 -16
- package/plugins/acryl-router/src/core/client/utils.test.ts +2 -2
- package/plugins/acryl-router/src/core/context.test.ts +4 -4
- package/plugins/acryl-router/src/core/context.ts +6 -6
- package/plugins/acryl-router/src/core/helper/accepts/accepts.test.ts +3 -3
- package/plugins/acryl-router/src/core/helper/accepts/index.ts +1 -1
- package/plugins/acryl-router/src/core/helper/adapter/index.test.ts +6 -6
- package/plugins/acryl-router/src/core/helper/adapter/index.ts +1 -1
- package/plugins/acryl-router/src/core/helper/conninfo/index.ts +1 -1
- package/plugins/acryl-router/src/core/helper/cookie/index.test.ts +8 -8
- package/plugins/acryl-router/src/core/helper/cookie/index.ts +1 -1
- package/plugins/acryl-router/src/core/helper/factory/index.test.ts +9 -9
- package/plugins/acryl-router/src/core/helper/factory/index.ts +10 -10
- package/plugins/acryl-router/src/core/helper/html/index.test.ts +4 -4
- package/plugins/acryl-router/src/core/helper/html/index.ts +1 -1
- package/plugins/acryl-router/src/core/helper/route/index.test.ts +7 -7
- package/plugins/acryl-router/src/core/helper/route/index.ts +8 -8
- package/plugins/acryl-router/src/core/helper/streaming/index.ts +1 -1
- package/plugins/acryl-router/src/core/helper/testing/index.test.ts +6 -6
- package/plugins/acryl-router/src/core/helper/testing/index.ts +4 -4
- package/plugins/acryl-router/src/core/helper/websocket/index.ts +2 -1
- package/plugins/acryl-router/src/core/http-exception.ts +1 -1
- package/plugins/acryl-router/src/core/index.ts +9 -9
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.test.ts +6 -6
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.test.ts +5 -5
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/body-limit/index.test.ts +6 -6
- package/plugins/acryl-router/src/core/middleware/body-limit/index.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/combine/index.test.ts +9 -9
- package/plugins/acryl-router/src/core/middleware/combine/index.ts +7 -7
- package/plugins/acryl-router/src/core/middleware/compress/index.test.ts +9 -9
- package/plugins/acryl-router/src/core/middleware/compress/index.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/context-storage/index.test.ts +5 -5
- package/plugins/acryl-router/src/core/middleware/context-storage/index.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/cors/index.test.ts +7 -7
- package/plugins/acryl-router/src/core/middleware/cors/index.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/csrf/index.test.ts +10 -10
- package/plugins/acryl-router/src/core/middleware/csrf/index.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/etag/index.test.ts +42 -42
- package/plugins/acryl-router/src/core/middleware/etag/index.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.test.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.ts +6 -6
- package/plugins/acryl-router/src/core/middleware/jwk/index.test.ts +16 -16
- package/plugins/acryl-router/src/core/middleware/jwk/jwk.ts +7 -6
- package/plugins/acryl-router/src/core/middleware/jwt/index.test.ts +16 -16
- package/plugins/acryl-router/src/core/middleware/jwt/jwt.ts +4 -3
- package/plugins/acryl-router/src/core/middleware/language/index.test.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/language/language.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/logger/index.test.ts +5 -5
- package/plugins/acryl-router/src/core/middleware/logger/index.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.test.ts +24 -24
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.ts +8 -8
- package/plugins/acryl-router/src/core/middleware/method-override/index.test.ts +5 -5
- package/plugins/acryl-router/src/core/middleware/method-override/index.ts +6 -6
- package/plugins/acryl-router/src/core/middleware/powered-by/index.test.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/powered-by/index.ts +6 -6
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.test.ts +30 -30
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.ts +4 -4
- package/plugins/acryl-router/src/core/middleware/request-id/index.test.ts +15 -15
- package/plugins/acryl-router/src/core/middleware/request-id/request-id.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/secure-headers/index.test.ts +35 -35
- package/plugins/acryl-router/src/core/middleware/secure-headers/secure-headers.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/serve-static/index.test.ts +23 -23
- package/plugins/acryl-router/src/core/middleware/serve-static/index.ts +1 -1
- package/plugins/acryl-router/src/core/middleware/timeout/index.test.ts +2 -2
- package/plugins/acryl-router/src/core/middleware/timeout/index.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/timing/index.test.ts +14 -14
- package/plugins/acryl-router/src/core/middleware/timing/timing.ts +3 -3
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.test.ts +7 -7
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.ts +7 -7
- package/plugins/acryl-router/src/core/request.test.ts +42 -42
- package/plugins/acryl-router/src/core/request.ts +6 -6
- package/plugins/acryl-router/src/core/router/linear-router/index.ts +1 -1
- package/plugins/acryl-router/src/core/router/pattern-router/index.ts +1 -1
- package/plugins/acryl-router/src/core/router/reg-exp-router/index.ts +1 -1
- package/plugins/acryl-router/src/core/router/smart-router/index.ts +1 -1
- package/plugins/acryl-router/src/core/router/trie-router/index.ts +1 -1
- package/plugins/acryl-router/src/core/types.test.ts +115 -115
- package/plugins/acryl-router/src/core/types.ts +72 -72
- package/plugins/acryl-router/src/core/utils/body.ts +8 -8
- package/plugins/acryl-router/src/core/utils/html.ts +1 -1
- package/plugins/acryl-router/src/core/utils/jwt/jws.ts +3 -3
- package/plugins/acryl-router/src/core/utils/jwt/jwt.test.ts +2 -2
- package/plugins/acryl-router/src/core/utils/jwt/jwt.ts +3 -3
- package/plugins/acryl-router/src/core/utils/jwt/types.ts +1 -1
- package/plugins/acryl-router/src/core/utils/types.ts +42 -0
- package/plugins/acryl-router/src/core/utils/url.test.ts +2 -2
- package/plugins/acryl-router/src/core/validator/index.ts +1 -1
- package/plugins/acryl-router/src/core/validator/validator.test.ts +28 -28
- package/plugins/acryl-router/src/deprecated.ts +15 -0
- package/plugins/acryl-router/src/index.ts +3 -2
- package/plugins/acryl-router/src/service.ts +10 -10
- package/plugins/acryl-router/tests/docs-examples.spec.ts +11 -11
- package/plugins/acryl-router/tests/live-install.spec.ts +2 -2
- package/plugins/acryl-router/tests/loader.spec.ts +3 -3
- package/plugins/acryl-router/tests/loopback-only.spec.ts +4 -4
- package/plugins/acryl-router/tests/no-dom/consumer.ts +11 -0
- package/plugins/acryl-router/tests/no-dom/tsconfig.json +13 -0
- package/plugins/acryl-router/tests/service.spec.ts +23 -23
- package/plugins/acryl-router/upstream.json +3 -3
- package/plugins/acryl-router-http/tests/adapter.spec.ts +3 -3
- package/plugins/acryl-router-http/tests/surfaces.spec.ts +2 -2
- package/plugins/acryl-router-http/upstream.json +2 -2
- package/plugins/acryl-state/src/service.ts +2 -2
- package/plugins/acryl-state/upstream.json +2 -2
- package/plugins/builder/script.ts +2 -2
- package/plugins/extensions/resolve.ts +70 -10
- package/plugins/openai/prompt.ts +5 -5
- package/shared/AGENTS.core.md +16 -9
- package/templates/agent/src/routes.ts +2 -2
- package/templates/agent/test/model.test.ts +2 -2
- package/templates/agent/tsconfig.json +40 -0
- package/templates/blank/src/routes.ts +2 -2
- package/templates/todo/src/todo.ts +2 -2
- package/templates/todo/upstream.json +2 -2
- package/docs/framework/context.md +0 -129
- package/docs/framework/helpers.md +0 -118
- package/docs/framework/middleware.md +0 -154
- package/docs/framework/request.md +0 -106
- /package/docs/framework/{plugin-lifecycle.md → cordis/plugin-lifecycle.md} +0 -0
|
@@ -4,7 +4,7 @@ import { hc } from './client/index.ts'
|
|
|
4
4
|
import { Context } from './context.ts'
|
|
5
5
|
import { createMiddleware } from './helper/factory/index.ts'
|
|
6
6
|
import { testClient } from './helper/testing/index.ts'
|
|
7
|
-
import {
|
|
7
|
+
import { Acryl } from './app.ts'
|
|
8
8
|
import { poweredBy } from './middleware/powered-by/index.ts'
|
|
9
9
|
import type {
|
|
10
10
|
AddParam,
|
|
@@ -36,7 +36,7 @@ describe('Env', () => {
|
|
|
36
36
|
FLAG: boolean
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
const app = new
|
|
39
|
+
const app = new Acryl<E>()
|
|
40
40
|
app.use('*', poweredBy())
|
|
41
41
|
app.get('/', (c) => {
|
|
42
42
|
const foo = c.get('foo')
|
|
@@ -54,7 +54,7 @@ describe('HandlerInterface', () => {
|
|
|
54
54
|
type Payload = { foo: string; bar: boolean }
|
|
55
55
|
|
|
56
56
|
describe('no path pattern', () => {
|
|
57
|
-
const app = new
|
|
57
|
+
const app = new Acryl<Env>()
|
|
58
58
|
const middleware: MiddlewareHandler<
|
|
59
59
|
Env,
|
|
60
60
|
'/',
|
|
@@ -107,7 +107,7 @@ describe('HandlerInterface', () => {
|
|
|
107
107
|
})
|
|
108
108
|
|
|
109
109
|
describe('path pattern', () => {
|
|
110
|
-
const app = new
|
|
110
|
+
const app = new Acryl<Env>()
|
|
111
111
|
const middleware: MiddlewareHandler<
|
|
112
112
|
Env,
|
|
113
113
|
'/foo',
|
|
@@ -148,7 +148,7 @@ describe('HandlerInterface', () => {
|
|
|
148
148
|
})
|
|
149
149
|
|
|
150
150
|
describe('With path parameters', () => {
|
|
151
|
-
const app = new
|
|
151
|
+
const app = new Acryl<Env>()
|
|
152
152
|
const middleware: MiddlewareHandler<Env, '/post/:id', {}, never> = async (_c, next) => {
|
|
153
153
|
await next()
|
|
154
154
|
}
|
|
@@ -176,7 +176,7 @@ describe('HandlerInterface', () => {
|
|
|
176
176
|
})
|
|
177
177
|
|
|
178
178
|
describe('Without path', () => {
|
|
179
|
-
const app = new
|
|
179
|
+
const app = new Acryl<Env>().basePath('/foo/:foo')
|
|
180
180
|
|
|
181
181
|
it('With basePath and path params', () => {
|
|
182
182
|
const route = app.get(async (c) => {
|
|
@@ -244,7 +244,7 @@ describe('HandlerInterface', () => {
|
|
|
244
244
|
})
|
|
245
245
|
|
|
246
246
|
it('should use the last registered path for a pathless handler', () => {
|
|
247
|
-
const app = new
|
|
247
|
+
const app = new Acryl()
|
|
248
248
|
.get('/foo', (c) => c.text('foo'))
|
|
249
249
|
.get('/bar', (c) => c.text('bar'))
|
|
250
250
|
.post((c) => c.text('baz'))
|
|
@@ -284,7 +284,7 @@ describe('HandlerInterface', () => {
|
|
|
284
284
|
})
|
|
285
285
|
|
|
286
286
|
describe('OnHandlerInterface', () => {
|
|
287
|
-
const app = new
|
|
287
|
+
const app = new Acryl()
|
|
288
288
|
test('Context', () => {
|
|
289
289
|
const middleware: MiddlewareHandler<
|
|
290
290
|
Env,
|
|
@@ -484,7 +484,7 @@ describe('TypedResponse', () => {
|
|
|
484
484
|
|
|
485
485
|
describe('Schema', () => {
|
|
486
486
|
test('Schema', () => {
|
|
487
|
-
type AppType =
|
|
487
|
+
type AppType = Acryl<
|
|
488
488
|
Env,
|
|
489
489
|
ToSchema<
|
|
490
490
|
'post',
|
|
@@ -537,7 +537,7 @@ describe('Schema', () => {
|
|
|
537
537
|
|
|
538
538
|
describe('Support c.json(undefined)', () => {
|
|
539
539
|
it('Should return a correct type', () => {
|
|
540
|
-
const app = new
|
|
540
|
+
const app = new Acryl().get('/this/is/a/test', async (c) => {
|
|
541
541
|
return c.json(undefined)
|
|
542
542
|
})
|
|
543
543
|
type Actual = ExtractSchema<typeof app>
|
|
@@ -565,7 +565,7 @@ describe('Test types of Handler', () => {
|
|
|
565
565
|
const url = 'http://localhost/'
|
|
566
566
|
|
|
567
567
|
test('Env', async () => {
|
|
568
|
-
const app = new
|
|
568
|
+
const app = new Acryl<E>()
|
|
569
569
|
const handler: Handler<E> = (c) => {
|
|
570
570
|
const foo = c.get('foo')
|
|
571
571
|
expectTypeOf(foo).toEqualTypeOf<number>()
|
|
@@ -579,7 +579,7 @@ describe('Test types of Handler', () => {
|
|
|
579
579
|
})
|
|
580
580
|
|
|
581
581
|
test('Env, Path', async () => {
|
|
582
|
-
const app = new
|
|
582
|
+
const app = new Acryl<E>()
|
|
583
583
|
const handler: Handler<E, '/'> = (c) => {
|
|
584
584
|
const foo = c.get('foo')
|
|
585
585
|
expectTypeOf(foo).toEqualTypeOf<number>()
|
|
@@ -597,7 +597,7 @@ describe('Test types of Handler', () => {
|
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
test('Env, Path, Type', async () => {
|
|
600
|
-
const app = new
|
|
600
|
+
const app = new Acryl<E>()
|
|
601
601
|
const handler: Handler<E, '/', { in: { json: User }; out: { json: User } }> = (c) => {
|
|
602
602
|
const foo = c.get('foo')
|
|
603
603
|
expectTypeOf(foo).toEqualTypeOf<number>()
|
|
@@ -609,7 +609,7 @@ describe('Test types of Handler', () => {
|
|
|
609
609
|
})
|
|
610
610
|
|
|
611
611
|
describe('`json()`', () => {
|
|
612
|
-
const app = new
|
|
612
|
+
const app = new Acryl<{ Variables: { foo: string } }>()
|
|
613
613
|
app.get('/post/:id', (c) => {
|
|
614
614
|
c.req.param('id')
|
|
615
615
|
const id = c.req.param('id')
|
|
@@ -686,7 +686,7 @@ describe('Path parameters', () => {
|
|
|
686
686
|
|
|
687
687
|
describe('Path parameters in app', () => {
|
|
688
688
|
test('Optional parameters - /api/:a/:b?', () => {
|
|
689
|
-
const app = new
|
|
689
|
+
const app = new Acryl()
|
|
690
690
|
const routes = app.get('/api/:a/:b?', (c) => {
|
|
691
691
|
const a = c.req.param('a')
|
|
692
692
|
const b = c.req.param('b')
|
|
@@ -705,7 +705,7 @@ describe('Path parameters', () => {
|
|
|
705
705
|
})
|
|
706
706
|
})
|
|
707
707
|
|
|
708
|
-
describe('For
|
|
708
|
+
describe('For AcrylRequest', () => {
|
|
709
709
|
type Input = {
|
|
710
710
|
json: {
|
|
711
711
|
id: number
|
|
@@ -1044,7 +1044,7 @@ describe('MergeSchemaPath', () => {
|
|
|
1044
1044
|
|
|
1045
1045
|
describe('Different types using json()', () => {
|
|
1046
1046
|
describe('no path pattern', () => {
|
|
1047
|
-
const app = new
|
|
1047
|
+
const app = new Acryl()
|
|
1048
1048
|
|
|
1049
1049
|
test('Three different types', () => {
|
|
1050
1050
|
const route = app.get((c) => {
|
|
@@ -1154,7 +1154,7 @@ describe('Different types using json()', () => {
|
|
|
1154
1154
|
})
|
|
1155
1155
|
|
|
1156
1156
|
describe('path pattern', () => {
|
|
1157
|
-
const app = new
|
|
1157
|
+
const app = new Acryl()
|
|
1158
1158
|
|
|
1159
1159
|
test('Three different types', () => {
|
|
1160
1160
|
const route = app.get('/foo', (c) => {
|
|
@@ -1265,7 +1265,7 @@ describe('Different types using json()', () => {
|
|
|
1265
1265
|
})
|
|
1266
1266
|
|
|
1267
1267
|
describe('json() in an async handler', () => {
|
|
1268
|
-
const app = new
|
|
1268
|
+
const app = new Acryl()
|
|
1269
1269
|
|
|
1270
1270
|
test('json', () => {
|
|
1271
1271
|
const route = app.get(async (c) => {
|
|
@@ -1374,25 +1374,25 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1374
1374
|
it('Should not throw type errors', () => {
|
|
1375
1375
|
// app.get(handler...)
|
|
1376
1376
|
|
|
1377
|
-
new
|
|
1377
|
+
new Acryl().get(mw1).get('/', (c) => {
|
|
1378
1378
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1379
1379
|
return c.json(0)
|
|
1380
1380
|
})
|
|
1381
1381
|
|
|
1382
|
-
new
|
|
1382
|
+
new Acryl().get(mw1, mw2).get('/', (c) => {
|
|
1383
1383
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1384
1384
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1385
1385
|
return c.json(0)
|
|
1386
1386
|
})
|
|
1387
1387
|
|
|
1388
|
-
new
|
|
1388
|
+
new Acryl().get(mw1, mw2, mw3).get('/', (c) => {
|
|
1389
1389
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1390
1390
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1391
1391
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
1392
1392
|
return c.json(0)
|
|
1393
1393
|
})
|
|
1394
1394
|
|
|
1395
|
-
new
|
|
1395
|
+
new Acryl().get(mw1, mw2, mw3, mw4).get('/', (c) => {
|
|
1396
1396
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1397
1397
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1398
1398
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
@@ -1400,7 +1400,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1400
1400
|
return c.json(0)
|
|
1401
1401
|
})
|
|
1402
1402
|
|
|
1403
|
-
new
|
|
1403
|
+
new Acryl().get(mw1, mw2, mw3, mw4, mw5).get('/', (c) => {
|
|
1404
1404
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1405
1405
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1406
1406
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
@@ -1409,7 +1409,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1409
1409
|
return c.json(0)
|
|
1410
1410
|
})
|
|
1411
1411
|
|
|
1412
|
-
new
|
|
1412
|
+
new Acryl().get(mw1, mw2, mw3, mw4, mw5, mw6).get('/', (c) => {
|
|
1413
1413
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1414
1414
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1415
1415
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
@@ -1419,7 +1419,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1419
1419
|
return c.json(0)
|
|
1420
1420
|
})
|
|
1421
1421
|
|
|
1422
|
-
new
|
|
1422
|
+
new Acryl().get(mw1, mw2, mw3, mw4, mw5, mw6, mw7).get('/', (c) => {
|
|
1423
1423
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1424
1424
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1425
1425
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
@@ -1430,7 +1430,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1430
1430
|
return c.json(0)
|
|
1431
1431
|
})
|
|
1432
1432
|
|
|
1433
|
-
new
|
|
1433
|
+
new Acryl().get(mw1, mw2, mw3, mw4, mw5, mw6, mw7, mw8).get('/', (c) => {
|
|
1434
1434
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1435
1435
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1436
1436
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
@@ -1442,7 +1442,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1442
1442
|
return c.json(0)
|
|
1443
1443
|
})
|
|
1444
1444
|
|
|
1445
|
-
new
|
|
1445
|
+
new Acryl().get(mw1, mw2, mw3, mw4, mw5, mw6, mw7, mw8, mw9).get('/', (c) => {
|
|
1446
1446
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1447
1447
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1448
1448
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
@@ -1455,7 +1455,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1455
1455
|
return c.json(0)
|
|
1456
1456
|
})
|
|
1457
1457
|
|
|
1458
|
-
new
|
|
1458
|
+
new Acryl().get(mw1, mw2, mw3, mw4, mw5, mw6, mw7, mw8, mw9, mw10).get('/', (c) => {
|
|
1459
1459
|
expectTypeOf(c.var.foo1).toEqualTypeOf<string>()
|
|
1460
1460
|
expectTypeOf(c.var.foo2).toEqualTypeOf<string>()
|
|
1461
1461
|
expectTypeOf(c.var.foo3).toEqualTypeOf<string>()
|
|
@@ -1469,7 +1469,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1469
1469
|
return c.json(0)
|
|
1470
1470
|
})
|
|
1471
1471
|
|
|
1472
|
-
new
|
|
1472
|
+
new Acryl().get(
|
|
1473
1473
|
mw1,
|
|
1474
1474
|
mw2,
|
|
1475
1475
|
mw3,
|
|
@@ -1491,7 +1491,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1491
1491
|
(c) => c.json(0)
|
|
1492
1492
|
)
|
|
1493
1493
|
|
|
1494
|
-
new
|
|
1494
|
+
new Acryl().get(mw1, mw2, mw3, mw4, mw5, mw6, mw7, mw8, mw9, (c) => {
|
|
1495
1495
|
expectTypeOf(c.req.valid('query')).toMatchTypeOf<{
|
|
1496
1496
|
bar1: number
|
|
1497
1497
|
bar2: number
|
|
@@ -1507,7 +1507,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1507
1507
|
return c.json(0)
|
|
1508
1508
|
})
|
|
1509
1509
|
|
|
1510
|
-
new
|
|
1510
|
+
new Acryl().get(
|
|
1511
1511
|
'/',
|
|
1512
1512
|
mw1,
|
|
1513
1513
|
mw2,
|
|
@@ -1530,7 +1530,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1530
1530
|
(c) => c.json(0)
|
|
1531
1531
|
)
|
|
1532
1532
|
|
|
1533
|
-
new
|
|
1533
|
+
new Acryl().get('/', mw1, mw2, mw3, mw4, mw5, mw6, mw7, mw8, mw9, (c) => {
|
|
1534
1534
|
expectTypeOf(c.req.valid('query')).toMatchTypeOf<{
|
|
1535
1535
|
bar1: number
|
|
1536
1536
|
bar2: number
|
|
@@ -1552,7 +1552,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
1554
1554
|
|
|
1555
|
-
new
|
|
1555
|
+
new Acryl<Env>()
|
|
1556
1556
|
.get('/', mw1, (c) => {
|
|
1557
1557
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1558
1558
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1569,7 +1569,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1569
1569
|
c.var.foo1
|
|
1570
1570
|
return c.json(0)
|
|
1571
1571
|
})
|
|
1572
|
-
new
|
|
1572
|
+
new Acryl<Env>()
|
|
1573
1573
|
.get('/', mw1, mw2, (c) => {
|
|
1574
1574
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1575
1575
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1592,7 +1592,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1592
1592
|
c.var.foo2
|
|
1593
1593
|
return c.json(0)
|
|
1594
1594
|
})
|
|
1595
|
-
new
|
|
1595
|
+
new Acryl<Env>()
|
|
1596
1596
|
.get('/', mw1, mw2, mw3, (c) => {
|
|
1597
1597
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1598
1598
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1621,7 +1621,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1621
1621
|
c.var.foo3
|
|
1622
1622
|
return c.json(0)
|
|
1623
1623
|
})
|
|
1624
|
-
new
|
|
1624
|
+
new Acryl<Env>()
|
|
1625
1625
|
.get('/', mw1, mw2, mw3, mw4, (c) => {
|
|
1626
1626
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1627
1627
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1657,7 +1657,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1657
1657
|
return c.json(0)
|
|
1658
1658
|
})
|
|
1659
1659
|
|
|
1660
|
-
new
|
|
1660
|
+
new Acryl<Env>()
|
|
1661
1661
|
.get('/', mw1, mw2, mw3, mw4, mw5, (c) => {
|
|
1662
1662
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1663
1663
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1698,7 +1698,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1698
1698
|
c.var.foo5
|
|
1699
1699
|
return c.json(0)
|
|
1700
1700
|
})
|
|
1701
|
-
new
|
|
1701
|
+
new Acryl<Env>()
|
|
1702
1702
|
.get('/', mw1, mw2, mw3, mw4, mw5, mw6, (c) => {
|
|
1703
1703
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1704
1704
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1745,7 +1745,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1745
1745
|
c.var.foo6
|
|
1746
1746
|
return c.json(0)
|
|
1747
1747
|
})
|
|
1748
|
-
new
|
|
1748
|
+
new Acryl<Env>()
|
|
1749
1749
|
.get('/', mw1, mw2, mw3, mw4, mw5, mw6, mw7, (c) => {
|
|
1750
1750
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1751
1751
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1798,7 +1798,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1798
1798
|
c.var.foo7
|
|
1799
1799
|
return c.json(0)
|
|
1800
1800
|
})
|
|
1801
|
-
new
|
|
1801
|
+
new Acryl<Env>()
|
|
1802
1802
|
.get('/', mw1, mw2, mw3, mw4, mw5, mw6, mw7, mw8, (c) => {
|
|
1803
1803
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1804
1804
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1858,7 +1858,7 @@ describe('c.var with chaining - test only types', () => {
|
|
|
1858
1858
|
return c.json(0)
|
|
1859
1859
|
})
|
|
1860
1860
|
|
|
1861
|
-
new
|
|
1861
|
+
new Acryl<Env>()
|
|
1862
1862
|
.get('/', mw1, mw2, mw3, mw4, mw5, mw6, mw7, mw8, mw9, (c) => {
|
|
1863
1863
|
expectTypeOf(c.get('init')).toEqualTypeOf<number>()
|
|
1864
1864
|
expectTypeOf(c.var.init).toEqualTypeOf<number>()
|
|
@@ -1938,11 +1938,11 @@ declare module './context.ts' {
|
|
|
1938
1938
|
|
|
1939
1939
|
describe('ContextVariableMap type tests', () => {
|
|
1940
1940
|
it('Should not throw type errors with c.var', () => {
|
|
1941
|
-
new
|
|
1941
|
+
new Acryl().get((c) => {
|
|
1942
1942
|
expectTypeOf(c.get('payload')).toEqualTypeOf<string>()
|
|
1943
1943
|
return c.json(0)
|
|
1944
1944
|
})
|
|
1945
|
-
new
|
|
1945
|
+
new Acryl().get((c) => {
|
|
1946
1946
|
expectTypeOf(c.var.payload).toEqualTypeOf<string>()
|
|
1947
1947
|
return c.json(0)
|
|
1948
1948
|
})
|
|
@@ -1958,7 +1958,7 @@ describe('ContextVariableMap type tests', () => {
|
|
|
1958
1958
|
await next()
|
|
1959
1959
|
})
|
|
1960
1960
|
|
|
1961
|
-
new
|
|
1961
|
+
new Acryl().get(middleware, (c) => {
|
|
1962
1962
|
expectTypeOf(c.get('payload')).toEqualTypeOf<number>()
|
|
1963
1963
|
return c.json(0)
|
|
1964
1964
|
})
|
|
@@ -1977,7 +1977,7 @@ describe('ContextVariableMap type tests', () => {
|
|
|
1977
1977
|
* It's challenge to test all cases. This is a minimal pattern.
|
|
1978
1978
|
*/
|
|
1979
1979
|
describe('Env types with chained routes - test only types', () => {
|
|
1980
|
-
const app = new
|
|
1980
|
+
const app = new Acryl<{ Variables: { testVar: string } }>()
|
|
1981
1981
|
it('Should not throw a type error', () => {
|
|
1982
1982
|
app
|
|
1983
1983
|
.post(
|
|
@@ -2002,7 +2002,7 @@ describe('Env types with chained routes - test only types', () => {
|
|
|
2002
2002
|
/**
|
|
2003
2003
|
*/
|
|
2004
2004
|
describe('Env types with validator as first middleware - test only types', () => {
|
|
2005
|
-
const app = new
|
|
2005
|
+
const app = new Acryl<{ Variables: { testVar: string } }>()
|
|
2006
2006
|
it('Should not throw a type error', () => {
|
|
2007
2007
|
const testApp = app.get(
|
|
2008
2008
|
validator('json', () => {
|
|
@@ -2039,7 +2039,7 @@ describe('Env types with validator as first middleware - test only types', () =>
|
|
|
2039
2039
|
})
|
|
2040
2040
|
describe('c.req.valid() in non-last handler after validator middleware - test only types', () => {
|
|
2041
2041
|
it('Should not throw a type error', () => {
|
|
2042
|
-
const app = new
|
|
2042
|
+
const app = new Acryl()
|
|
2043
2043
|
app.get(
|
|
2044
2044
|
'/',
|
|
2045
2045
|
validator('query', () => {
|
|
@@ -2062,7 +2062,7 @@ describe('c.req.valid() in non-last handler after validator middleware - test on
|
|
|
2062
2062
|
})
|
|
2063
2063
|
|
|
2064
2064
|
describe('Env types with `use` middleware - test only types', () => {
|
|
2065
|
-
const app = new
|
|
2065
|
+
const app = new Acryl()
|
|
2066
2066
|
|
|
2067
2067
|
const mw1 = createMiddleware<{ Variables: { foo1: string } }>(async () => {})
|
|
2068
2068
|
const mw2 = createMiddleware<{ Variables: { foo2: string } }>(async () => {})
|
|
@@ -2093,7 +2093,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2093
2093
|
}
|
|
2094
2094
|
|
|
2095
2095
|
// app.use(path, handler)
|
|
2096
|
-
new
|
|
2096
|
+
new Acryl<Env>()
|
|
2097
2097
|
.use('/:id', async (c, next) => {
|
|
2098
2098
|
expectTypeOf(c.var.foo).toEqualTypeOf<string>()
|
|
2099
2099
|
expectTypeOf(c.req.param('id')).toEqualTypeOf<string>()
|
|
@@ -2106,7 +2106,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2106
2106
|
})
|
|
2107
2107
|
|
|
2108
2108
|
// app.use(path, handler x2)
|
|
2109
|
-
new
|
|
2109
|
+
new Acryl<Env>()
|
|
2110
2110
|
.use(
|
|
2111
2111
|
'/:id',
|
|
2112
2112
|
async (c, next) => {
|
|
@@ -2127,7 +2127,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2127
2127
|
})
|
|
2128
2128
|
|
|
2129
2129
|
// app.use(path, handler x3)
|
|
2130
|
-
new
|
|
2130
|
+
new Acryl<Env>()
|
|
2131
2131
|
.use(
|
|
2132
2132
|
'/:id',
|
|
2133
2133
|
async (c, next) => {
|
|
@@ -2153,7 +2153,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2153
2153
|
})
|
|
2154
2154
|
|
|
2155
2155
|
// app.use(path, handler x4)
|
|
2156
|
-
new
|
|
2156
|
+
new Acryl<Env>()
|
|
2157
2157
|
.use(
|
|
2158
2158
|
'/:id',
|
|
2159
2159
|
async (c, next) => {
|
|
@@ -2184,7 +2184,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2184
2184
|
})
|
|
2185
2185
|
|
|
2186
2186
|
// app.use(path, handler x5)
|
|
2187
|
-
new
|
|
2187
|
+
new Acryl<Env>()
|
|
2188
2188
|
.use(
|
|
2189
2189
|
'/:id',
|
|
2190
2190
|
async (c, next) => {
|
|
@@ -2220,7 +2220,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2220
2220
|
})
|
|
2221
2221
|
|
|
2222
2222
|
// app.use(path, handler x6)
|
|
2223
|
-
new
|
|
2223
|
+
new Acryl<Env>()
|
|
2224
2224
|
.use(
|
|
2225
2225
|
'/:id',
|
|
2226
2226
|
async (c, next) => {
|
|
@@ -2261,7 +2261,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2261
2261
|
})
|
|
2262
2262
|
|
|
2263
2263
|
// app.use(path, handler x7)
|
|
2264
|
-
new
|
|
2264
|
+
new Acryl<Env>()
|
|
2265
2265
|
.use(
|
|
2266
2266
|
'/:id',
|
|
2267
2267
|
async (c, next) => {
|
|
@@ -2307,7 +2307,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2307
2307
|
})
|
|
2308
2308
|
|
|
2309
2309
|
// app.use(path, handler x8)
|
|
2310
|
-
new
|
|
2310
|
+
new Acryl<Env>()
|
|
2311
2311
|
.use(
|
|
2312
2312
|
'/:id',
|
|
2313
2313
|
async (c, next) => {
|
|
@@ -2358,7 +2358,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2358
2358
|
})
|
|
2359
2359
|
|
|
2360
2360
|
// app.use(path, handler x9)
|
|
2361
|
-
new
|
|
2361
|
+
new Acryl<Env>()
|
|
2362
2362
|
.use(
|
|
2363
2363
|
'/:id',
|
|
2364
2364
|
async (c, next) => {
|
|
@@ -2414,7 +2414,7 @@ describe('Env types and a path type with `app.use(path, handler...)` - test only
|
|
|
2414
2414
|
})
|
|
2415
2415
|
|
|
2416
2416
|
// app.use(path, handler x10)
|
|
2417
|
-
new
|
|
2417
|
+
new Acryl<Env>()
|
|
2418
2418
|
.use(
|
|
2419
2419
|
'/:id',
|
|
2420
2420
|
async (c, next) => {
|
|
@@ -2475,7 +2475,7 @@ describe('Returning type from `app.use(path, mw)`', () => {
|
|
|
2475
2475
|
await next()
|
|
2476
2476
|
})
|
|
2477
2477
|
it('Should ignore the `*` wildcard when building the schema', () => {
|
|
2478
|
-
const app = new
|
|
2478
|
+
const app = new Acryl().use('*', mw)
|
|
2479
2479
|
type Actual = ExtractSchema<typeof app>
|
|
2480
2480
|
type Expected = {}
|
|
2481
2481
|
type verify = Expect<Equal<Expected, Actual>>
|
|
@@ -2489,7 +2489,7 @@ describe('generic typed variables', () => {
|
|
|
2489
2489
|
type Variables = {
|
|
2490
2490
|
ok: ReturnType<typeof okHelper>
|
|
2491
2491
|
}
|
|
2492
|
-
const app = new
|
|
2492
|
+
const app = new Acryl<{ Variables: Variables }>()
|
|
2493
2493
|
|
|
2494
2494
|
it('Should set and get variables with correct types', async () => {
|
|
2495
2495
|
const route = app
|
|
@@ -2508,7 +2508,7 @@ describe('generic typed variables', () => {
|
|
|
2508
2508
|
})
|
|
2509
2509
|
|
|
2510
2510
|
describe('status code', () => {
|
|
2511
|
-
const app = new
|
|
2511
|
+
const app = new Acryl()
|
|
2512
2512
|
|
|
2513
2513
|
it('should only allow to return .json() with contentful status codes', async () => {
|
|
2514
2514
|
const route = app.get('/', async (c) => c.json({}))
|
|
@@ -2586,7 +2586,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2586
2586
|
test('merge responses from 1 middleware', async () => {
|
|
2587
2587
|
const middleware = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
2588
2588
|
|
|
2589
|
-
const app = new
|
|
2589
|
+
const app = new Acryl().get('/test', middleware, (c) => c.json({ '200': true }, 200))
|
|
2590
2590
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
2591
2591
|
const res = await client.test.$get()
|
|
2592
2592
|
|
|
@@ -2602,7 +2602,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2602
2602
|
const middleware1 = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
2603
2603
|
const middleware2 = createMiddleware(async (c) => c.json({ '401': true }, 401))
|
|
2604
2604
|
|
|
2605
|
-
const app = new
|
|
2605
|
+
const app = new Acryl().get('/test', middleware1, middleware2, (c) =>
|
|
2606
2606
|
c.json({ '200': true }, 200)
|
|
2607
2607
|
)
|
|
2608
2608
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
@@ -2624,7 +2624,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2624
2624
|
const middleware2 = createMiddleware(async (c) => c.json({ '401': true }, 401))
|
|
2625
2625
|
const middleware3 = createMiddleware(async (c) => c.json({ '403': true }, 403))
|
|
2626
2626
|
|
|
2627
|
-
const app = new
|
|
2627
|
+
const app = new Acryl().get('/test', middleware1, middleware2, middleware3, (c) =>
|
|
2628
2628
|
c.json({ '200': true }, 200)
|
|
2629
2629
|
)
|
|
2630
2630
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
@@ -2650,7 +2650,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2650
2650
|
const middleware3 = createMiddleware(async (c) => c.json({ '403': true }, 403))
|
|
2651
2651
|
const middleware4 = createMiddleware(async (c) => c.json({ '404': true }, 404))
|
|
2652
2652
|
|
|
2653
|
-
const app = new
|
|
2653
|
+
const app = new Acryl().get('/test', middleware1, middleware2, middleware3, middleware4, (c) =>
|
|
2654
2654
|
c.json({ '200': true }, 200)
|
|
2655
2655
|
)
|
|
2656
2656
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
@@ -2680,7 +2680,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2680
2680
|
const middleware4 = createMiddleware(async (c) => c.json({ '404': true }, 404))
|
|
2681
2681
|
const middleware5 = createMiddleware(async (c) => c.json({ '300': true }, 300))
|
|
2682
2682
|
|
|
2683
|
-
const app = new
|
|
2683
|
+
const app = new Acryl().get(
|
|
2684
2684
|
'/test',
|
|
2685
2685
|
middleware1,
|
|
2686
2686
|
middleware2,
|
|
@@ -2717,7 +2717,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2717
2717
|
const middleware5 = createMiddleware(async (c) => c.json({ '300': true }, 300))
|
|
2718
2718
|
const middleware6 = createMiddleware(async (c) => c.json({ '201': true }, 201))
|
|
2719
2719
|
|
|
2720
|
-
const app = new
|
|
2720
|
+
const app = new Acryl().get(
|
|
2721
2721
|
'/test',
|
|
2722
2722
|
middleware1,
|
|
2723
2723
|
middleware2,
|
|
@@ -2762,7 +2762,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2762
2762
|
const middleware6 = createMiddleware(async (c) => c.json({ '201': true }, 201))
|
|
2763
2763
|
const middleware7 = createMiddleware(async (c) => c.json({ '202': true }, 202))
|
|
2764
2764
|
|
|
2765
|
-
const app = new
|
|
2765
|
+
const app = new Acryl().get(
|
|
2766
2766
|
'/test',
|
|
2767
2767
|
middleware1,
|
|
2768
2768
|
middleware2,
|
|
@@ -2812,7 +2812,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2812
2812
|
const middleware7 = createMiddleware(async (c) => c.json({ '202': true }, 202))
|
|
2813
2813
|
const middleware8 = createMiddleware(async (c) => c.json({ '203': true }, 203))
|
|
2814
2814
|
|
|
2815
|
-
const app = new
|
|
2815
|
+
const app = new Acryl().get(
|
|
2816
2816
|
'/test',
|
|
2817
2817
|
middleware1,
|
|
2818
2818
|
middleware2,
|
|
@@ -2867,7 +2867,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2867
2867
|
const middleware8 = createMiddleware(async (c) => c.json({ '203': true }, 203))
|
|
2868
2868
|
const middleware9 = createMiddleware(async (c) => c.json({ '301': true }, 301))
|
|
2869
2869
|
|
|
2870
|
-
const app = new
|
|
2870
|
+
const app = new Acryl().get(
|
|
2871
2871
|
'/test',
|
|
2872
2872
|
middleware1,
|
|
2873
2873
|
middleware2,
|
|
@@ -2925,7 +2925,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2925
2925
|
await next()
|
|
2926
2926
|
})
|
|
2927
2927
|
|
|
2928
|
-
const app = new
|
|
2928
|
+
const app = new Acryl().get('/test', middleware, (c) => c.json({ message: 'Hello' }, 200))
|
|
2929
2929
|
const client = hc<typeof app>('http://localhost', {
|
|
2930
2930
|
fetch: app.request,
|
|
2931
2931
|
})
|
|
@@ -2944,7 +2944,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2944
2944
|
test('merge responses from 1 middleware', async () => {
|
|
2945
2945
|
const middleware = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
2946
2946
|
|
|
2947
|
-
const app = new
|
|
2947
|
+
const app = new Acryl().get(middleware, (c) => c.json({ '200': true }, 200))
|
|
2948
2948
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
2949
2949
|
const res = await client.index.$get()
|
|
2950
2950
|
|
|
@@ -2960,7 +2960,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2960
2960
|
const middleware1 = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
2961
2961
|
const middleware2 = createMiddleware(async (c) => c.json({ '401': true }, 401))
|
|
2962
2962
|
|
|
2963
|
-
const app = new
|
|
2963
|
+
const app = new Acryl().get(middleware1, middleware2, (c) => c.json({ '200': true }, 200))
|
|
2964
2964
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
2965
2965
|
const res = await client.index.$get()
|
|
2966
2966
|
|
|
@@ -2980,7 +2980,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
2980
2980
|
const middleware2 = createMiddleware(async (c) => c.json({ '401': true }, 401))
|
|
2981
2981
|
const middleware3 = createMiddleware(async (c) => c.json({ '403': true }, 403))
|
|
2982
2982
|
|
|
2983
|
-
const app = new
|
|
2983
|
+
const app = new Acryl().get(middleware1, middleware2, middleware3, (c) =>
|
|
2984
2984
|
c.json({ '200': true }, 200)
|
|
2985
2985
|
)
|
|
2986
2986
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
@@ -3006,7 +3006,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3006
3006
|
const middleware3 = createMiddleware(async (c) => c.json({ '403': true }, 403))
|
|
3007
3007
|
const middleware4 = createMiddleware(async (c) => c.json({ '404': true }, 404))
|
|
3008
3008
|
|
|
3009
|
-
const app = new
|
|
3009
|
+
const app = new Acryl().get(middleware1, middleware2, middleware3, middleware4, (c) =>
|
|
3010
3010
|
c.json({ '200': true }, 200)
|
|
3011
3011
|
)
|
|
3012
3012
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
@@ -3036,7 +3036,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3036
3036
|
const middleware4 = createMiddleware(async (c) => c.json({ '404': true }, 404))
|
|
3037
3037
|
const middleware5 = createMiddleware(async (c) => c.json({ '300': true }, 300))
|
|
3038
3038
|
|
|
3039
|
-
const app = new
|
|
3039
|
+
const app = new Acryl().get(
|
|
3040
3040
|
middleware1,
|
|
3041
3041
|
middleware2,
|
|
3042
3042
|
middleware3,
|
|
@@ -3072,7 +3072,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3072
3072
|
const middleware5 = createMiddleware(async (c) => c.json({ '300': true }, 300))
|
|
3073
3073
|
const middleware6 = createMiddleware(async (c) => c.json({ '201': true }, 201))
|
|
3074
3074
|
|
|
3075
|
-
const app = new
|
|
3075
|
+
const app = new Acryl().get(
|
|
3076
3076
|
middleware1,
|
|
3077
3077
|
middleware2,
|
|
3078
3078
|
middleware3,
|
|
@@ -3116,7 +3116,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3116
3116
|
const middleware6 = createMiddleware(async (c) => c.json({ '201': true }, 201))
|
|
3117
3117
|
const middleware7 = createMiddleware(async (c) => c.json({ '202': true }, 202))
|
|
3118
3118
|
|
|
3119
|
-
const app = new
|
|
3119
|
+
const app = new Acryl().get(
|
|
3120
3120
|
middleware1,
|
|
3121
3121
|
middleware2,
|
|
3122
3122
|
middleware3,
|
|
@@ -3165,7 +3165,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3165
3165
|
const middleware7 = createMiddleware(async (c) => c.json({ '202': true }, 202))
|
|
3166
3166
|
const middleware8 = createMiddleware(async (c) => c.json({ '203': true }, 203))
|
|
3167
3167
|
|
|
3168
|
-
const app = new
|
|
3168
|
+
const app = new Acryl().get(
|
|
3169
3169
|
middleware1,
|
|
3170
3170
|
middleware2,
|
|
3171
3171
|
middleware3,
|
|
@@ -3219,7 +3219,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3219
3219
|
const middleware8 = createMiddleware(async (c) => c.json({ '203': true }, 203))
|
|
3220
3220
|
const middleware9 = createMiddleware(async (c) => c.json({ '301': true }, 301))
|
|
3221
3221
|
|
|
3222
|
-
const app = new
|
|
3222
|
+
const app = new Acryl().get(
|
|
3223
3223
|
middleware1,
|
|
3224
3224
|
middleware2,
|
|
3225
3225
|
middleware3,
|
|
@@ -3284,37 +3284,37 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3284
3284
|
}
|
|
3285
3285
|
|
|
3286
3286
|
test('infer the correct response type with 1 middleware and 1 handler', () => {
|
|
3287
|
-
const routes = new
|
|
3287
|
+
const routes = new Acryl().get('/', middleware, handler)
|
|
3288
3288
|
type Actual = ExtractSchema<typeof routes>
|
|
3289
3289
|
type verify = Expect<Equal<Expected, Actual>>
|
|
3290
3290
|
})
|
|
3291
3291
|
|
|
3292
3292
|
test('infer the correct response type with 1 middleware and 2 handler', () => {
|
|
3293
|
-
const routes = new
|
|
3293
|
+
const routes = new Acryl().get('/', middleware, handler, handler)
|
|
3294
3294
|
type Actual = ExtractSchema<typeof routes>
|
|
3295
3295
|
type verify = Expect<Equal<Expected, Actual>>
|
|
3296
3296
|
})
|
|
3297
3297
|
|
|
3298
3298
|
test('infer the correct response type with 2 middleware and 1 handler', () => {
|
|
3299
|
-
const routes = new
|
|
3299
|
+
const routes = new Acryl().get('/', middleware, middleware, handler)
|
|
3300
3300
|
type Actual = ExtractSchema<typeof routes>
|
|
3301
3301
|
type verify = Expect<Equal<Expected, Actual>>
|
|
3302
3302
|
})
|
|
3303
3303
|
|
|
3304
3304
|
test('infer the correct response type with 3 middleware and 1 handler', () => {
|
|
3305
|
-
const routes = new
|
|
3305
|
+
const routes = new Acryl().get('/', middleware, middleware, middleware, handler)
|
|
3306
3306
|
type Actual = ExtractSchema<typeof routes>
|
|
3307
3307
|
type verify = Expect<Equal<Expected, Actual>>
|
|
3308
3308
|
})
|
|
3309
3309
|
|
|
3310
3310
|
test('infer the correct response type with 4 middleware and 1 handler', () => {
|
|
3311
|
-
const routes = new
|
|
3311
|
+
const routes = new Acryl().get('/', middleware, middleware, middleware, middleware, handler)
|
|
3312
3312
|
type Actual = ExtractSchema<typeof routes>
|
|
3313
3313
|
type verify = Expect<Equal<Expected, Actual>>
|
|
3314
3314
|
})
|
|
3315
3315
|
|
|
3316
3316
|
test('infer the correct response type with 5 middleware and 1 handler', () => {
|
|
3317
|
-
const routes = new
|
|
3317
|
+
const routes = new Acryl().get(
|
|
3318
3318
|
'/',
|
|
3319
3319
|
middleware,
|
|
3320
3320
|
middleware,
|
|
@@ -3328,7 +3328,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3328
3328
|
})
|
|
3329
3329
|
|
|
3330
3330
|
test('infer the correct response type with 6 middleware and 1 handler', () => {
|
|
3331
|
-
const routes = new
|
|
3331
|
+
const routes = new Acryl().get(
|
|
3332
3332
|
'/',
|
|
3333
3333
|
middleware,
|
|
3334
3334
|
middleware,
|
|
@@ -3343,7 +3343,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3343
3343
|
})
|
|
3344
3344
|
|
|
3345
3345
|
test('infer the correct response type with 7 middleware and 1 handler', () => {
|
|
3346
|
-
const routes = new
|
|
3346
|
+
const routes = new Acryl().get(
|
|
3347
3347
|
'/',
|
|
3348
3348
|
middleware,
|
|
3349
3349
|
middleware,
|
|
@@ -3359,7 +3359,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3359
3359
|
})
|
|
3360
3360
|
|
|
3361
3361
|
test('infer the correct response type with 8 middleware and 1 handler', () => {
|
|
3362
|
-
const routes = new
|
|
3362
|
+
const routes = new Acryl().get(
|
|
3363
3363
|
'/',
|
|
3364
3364
|
middleware,
|
|
3365
3365
|
middleware,
|
|
@@ -3376,7 +3376,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3376
3376
|
})
|
|
3377
3377
|
|
|
3378
3378
|
test('infer the correct response type with 9 middleware and 1 handler', () => {
|
|
3379
|
-
const routes = new
|
|
3379
|
+
const routes = new Acryl().get(
|
|
3380
3380
|
'/',
|
|
3381
3381
|
middleware,
|
|
3382
3382
|
middleware,
|
|
@@ -3410,7 +3410,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3410
3410
|
}
|
|
3411
3411
|
const middleware2 = async () => {}
|
|
3412
3412
|
|
|
3413
|
-
const routes = new
|
|
3413
|
+
const routes = new Acryl().get('/', middleware1, middleware2, handler)
|
|
3414
3414
|
type Actual = ExtractSchema<typeof routes>
|
|
3415
3415
|
type Expected = {
|
|
3416
3416
|
'/': {
|
|
@@ -3459,7 +3459,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3459
3459
|
}
|
|
3460
3460
|
const middleware3 = async () => {}
|
|
3461
3461
|
|
|
3462
|
-
const routes = new
|
|
3462
|
+
const routes = new Acryl().get('/', middleware1, middleware2, middleware3, handler)
|
|
3463
3463
|
type Actual = ExtractSchema<typeof routes>
|
|
3464
3464
|
type Expected = {
|
|
3465
3465
|
'/': {
|
|
@@ -3498,7 +3498,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3498
3498
|
test('merge responses from 1 middleware', async () => {
|
|
3499
3499
|
const middleware = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
3500
3500
|
|
|
3501
|
-
const app = new
|
|
3501
|
+
const app = new Acryl().on('GET', '/test', middleware, (c) => c.json({ '200': true }, 200))
|
|
3502
3502
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
3503
3503
|
const res = await client.test.$get()
|
|
3504
3504
|
|
|
@@ -3514,7 +3514,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3514
3514
|
const middleware1 = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
3515
3515
|
const middleware2 = createMiddleware(async (c) => c.json({ '401': true }, 401))
|
|
3516
3516
|
|
|
3517
|
-
const app = new
|
|
3517
|
+
const app = new Acryl().on('GET', '/test', middleware1, middleware2, (c) =>
|
|
3518
3518
|
c.json({ '200': true }, 200)
|
|
3519
3519
|
)
|
|
3520
3520
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
@@ -3538,7 +3538,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3538
3538
|
const middleware4 = createMiddleware(async (c) => c.json({ '404': true }, 404))
|
|
3539
3539
|
const middleware5 = createMiddleware(async (c) => c.json({ '300': true }, 300))
|
|
3540
3540
|
|
|
3541
|
-
const app = new
|
|
3541
|
+
const app = new Acryl().on(
|
|
3542
3542
|
'GET',
|
|
3543
3543
|
'/test',
|
|
3544
3544
|
middleware1,
|
|
@@ -3582,7 +3582,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3582
3582
|
const middleware8 = createMiddleware(async (c) => c.json({ '203': true }, 203))
|
|
3583
3583
|
const middleware9 = createMiddleware(async (c) => c.json({ '301': true }, 301))
|
|
3584
3584
|
|
|
3585
|
-
const app = new
|
|
3585
|
+
const app = new Acryl().on(
|
|
3586
3586
|
'GET',
|
|
3587
3587
|
'/test',
|
|
3588
3588
|
middleware1,
|
|
@@ -3636,7 +3636,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3636
3636
|
test('merge responses from 1 middleware', async () => {
|
|
3637
3637
|
const middleware = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
3638
3638
|
|
|
3639
|
-
const app = new
|
|
3639
|
+
const app = new Acryl().on(['GET'], '/test', middleware, (c) => c.json({ '200': true }, 200))
|
|
3640
3640
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
3641
3641
|
const res = await client.test.$get()
|
|
3642
3642
|
|
|
@@ -3652,7 +3652,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3652
3652
|
const middleware1 = createMiddleware(async (c) => c.json({ '400': true }, 400))
|
|
3653
3653
|
const middleware2 = createMiddleware(async (c) => c.json({ '401': true }, 401))
|
|
3654
3654
|
|
|
3655
|
-
const app = new
|
|
3655
|
+
const app = new Acryl().on(['GET'], '/test', middleware1, middleware2, (c) =>
|
|
3656
3656
|
c.json({ '200': true }, 200)
|
|
3657
3657
|
)
|
|
3658
3658
|
const client = hc<typeof app>('http://localhost', { fetch: app.request })
|
|
@@ -3676,7 +3676,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3676
3676
|
const middleware4 = createMiddleware(async (c) => c.json({ '404': true }, 404))
|
|
3677
3677
|
const middleware5 = createMiddleware(async (c) => c.json({ '300': true }, 300))
|
|
3678
3678
|
|
|
3679
|
-
const app = new
|
|
3679
|
+
const app = new Acryl().on(
|
|
3680
3680
|
['GET'],
|
|
3681
3681
|
'/test',
|
|
3682
3682
|
middleware1,
|
|
@@ -3720,7 +3720,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3720
3720
|
const middleware8 = createMiddleware(async (c) => c.json({ '203': true }, 203))
|
|
3721
3721
|
const middleware9 = createMiddleware(async (c) => c.json({ '301': true }, 301))
|
|
3722
3722
|
|
|
3723
|
-
const app = new
|
|
3723
|
+
const app = new Acryl().on(
|
|
3724
3724
|
['GET'],
|
|
3725
3725
|
'/test',
|
|
3726
3726
|
middleware1,
|
|
@@ -3773,7 +3773,7 @@ describe('RPC supports Middleware responses', () => {
|
|
|
3773
3773
|
|
|
3774
3774
|
describe('Handlers returning Promise<void>', () => {
|
|
3775
3775
|
it('should not be added to schema when calling await next() with another route', async () => {
|
|
3776
|
-
const app = new
|
|
3776
|
+
const app = new Acryl()
|
|
3777
3777
|
.get('/', async (c, next) => {
|
|
3778
3778
|
await next()
|
|
3779
3779
|
})
|
|
@@ -3786,7 +3786,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
3786
3786
|
})
|
|
3787
3787
|
|
|
3788
3788
|
it('should not be added to schema when only Promise<void> handler exists', async () => {
|
|
3789
|
-
const app = new
|
|
3789
|
+
const app = new Acryl().get('/', async (c, next) => {
|
|
3790
3790
|
await next()
|
|
3791
3791
|
})
|
|
3792
3792
|
|
|
@@ -3797,7 +3797,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
3797
3797
|
})
|
|
3798
3798
|
|
|
3799
3799
|
it('should set path from .use() for subsequent handlers without path', () => {
|
|
3800
|
-
const app = new
|
|
3800
|
+
const app = new Acryl()
|
|
3801
3801
|
.use('/:id', async (c, next) => {
|
|
3802
3802
|
await next()
|
|
3803
3803
|
})
|
|
@@ -3825,7 +3825,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
3825
3825
|
})
|
|
3826
3826
|
|
|
3827
3827
|
it('should preserve existing routes when .use() sets a new path', () => {
|
|
3828
|
-
const app = new
|
|
3828
|
+
const app = new Acryl()
|
|
3829
3829
|
.get((c) => c.text('before'))
|
|
3830
3830
|
.use('/:id', async (c, next) => {
|
|
3831
3831
|
await next()
|
|
@@ -3863,7 +3863,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
3863
3863
|
})
|
|
3864
3864
|
|
|
3865
3865
|
it('should work with .get() that returns Promise<void> instead of .use()', () => {
|
|
3866
|
-
const app = new
|
|
3866
|
+
const app = new Acryl()
|
|
3867
3867
|
.get((c) => c.text('before'))
|
|
3868
3868
|
.get('/:id', async (c, next) => {
|
|
3869
3869
|
await next()
|
|
@@ -3901,7 +3901,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
3901
3901
|
})
|
|
3902
3902
|
|
|
3903
3903
|
it('should work with .get() that returns Promise<void> instead of .use() - multiple middleware', () => {
|
|
3904
|
-
const app = new
|
|
3904
|
+
const app = new Acryl()
|
|
3905
3905
|
.get((c) => c.text('before'))
|
|
3906
3906
|
.get(
|
|
3907
3907
|
'/:id',
|
|
@@ -3945,7 +3945,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
3945
3945
|
})
|
|
3946
3946
|
|
|
3947
3947
|
it('should use the last registered path for a pathless handler with multiple middlewares', () => {
|
|
3948
|
-
const app = new
|
|
3948
|
+
const app = new Acryl()
|
|
3949
3949
|
.get('/foo', async (_c, next) => {
|
|
3950
3950
|
await next()
|
|
3951
3951
|
})
|
|
@@ -3969,7 +3969,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
3969
3969
|
})
|
|
3970
3970
|
|
|
3971
3971
|
it('should use the last registered path for a pathless handler with mixed handlers and middlewares', () => {
|
|
3972
|
-
const app = new
|
|
3972
|
+
const app = new Acryl()
|
|
3973
3973
|
.get('/void', async (_c, next) => {
|
|
3974
3974
|
await next()
|
|
3975
3975
|
})
|
|
@@ -4000,7 +4000,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
4000
4000
|
})
|
|
4001
4001
|
|
|
4002
4002
|
it('should set path as `*` when .use() is called without path argument', () => {
|
|
4003
|
-
const app = new
|
|
4003
|
+
const app = new Acryl()
|
|
4004
4004
|
.get('/foo', async (_c, next) => {
|
|
4005
4005
|
await next()
|
|
4006
4006
|
})
|
|
@@ -4029,7 +4029,7 @@ describe('Handlers returning Promise<void>', () => {
|
|
|
4029
4029
|
// Regression tests for #4388: routes before .use() with explicit paths should not be dropped
|
|
4030
4030
|
describe('Routes before .use() with explicit paths (#4388)', () => {
|
|
4031
4031
|
it('should preserve explicit-path .get() before .use() with path', () => {
|
|
4032
|
-
const app = new
|
|
4032
|
+
const app = new Acryl()
|
|
4033
4033
|
.get('/', (c) => c.text('Hello from /'))
|
|
4034
4034
|
.use('/noop', async (c, next) => {
|
|
4035
4035
|
await next()
|
|
@@ -4050,7 +4050,7 @@ describe('Routes before .use() with explicit paths (#4388)', () => {
|
|
|
4050
4050
|
})
|
|
4051
4051
|
|
|
4052
4052
|
it('should preserve .get() route and infer .post() under .use() path', () => {
|
|
4053
|
-
const app = new
|
|
4053
|
+
const app = new Acryl()
|
|
4054
4054
|
.get('/', (c) => c.text('Hello from /'))
|
|
4055
4055
|
.use('/:slug', async (c, next) => {
|
|
4056
4056
|
await next()
|
|
@@ -4085,14 +4085,14 @@ describe('Routes before .use() with explicit paths (#4388)', () => {
|
|
|
4085
4085
|
})
|
|
4086
4086
|
|
|
4087
4087
|
it('should preserve routes through .route() wrapping', () => {
|
|
4088
|
-
const inner = new
|
|
4088
|
+
const inner = new Acryl()
|
|
4089
4089
|
.get('/', (c) => c.text('index'))
|
|
4090
4090
|
.use('/:slug', async (c, next) => {
|
|
4091
4091
|
await next()
|
|
4092
4092
|
})
|
|
4093
4093
|
.post((c) => c.text('posted'))
|
|
4094
4094
|
|
|
4095
|
-
const app = new
|
|
4095
|
+
const app = new Acryl().route('/api', inner)
|
|
4096
4096
|
|
|
4097
4097
|
const client = hc<typeof app>('http://localhost')
|
|
4098
4098
|
// '/api' $get should exist (from inner .get('/'))
|
|
@@ -4102,7 +4102,7 @@ describe('Routes before .use() with explicit paths (#4388)', () => {
|
|
|
4102
4102
|
})
|
|
4103
4103
|
|
|
4104
4104
|
it('should preserve multiple explicit-path routes before .use()', () => {
|
|
4105
|
-
const app = new
|
|
4105
|
+
const app = new Acryl()
|
|
4106
4106
|
.get('/', (c) => c.text('home'))
|
|
4107
4107
|
.get('/about', (c) => c.text('about'))
|
|
4108
4108
|
.use('/mw', async (c, next) => {
|