hono 4.13.13 → 5.0.0-rc.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/README.md +2 -2
- package/dist/{types/compose.d.ts → compose.d.ts} +1 -0
- package/dist/compose.js +10 -5
- package/dist/{types/context.d.ts → context.d.ts} +15 -15
- package/dist/context.js +79 -47
- package/dist/helper/factory/define-handler.d.ts +150 -0
- package/dist/helper/factory/define-handler.js +165 -0
- package/dist/{types/helper → helper}/factory/index.d.ts +30 -1
- package/dist/helper/factory/index.js +31 -3
- package/dist/{types/helper → helper}/ssg/middleware.d.ts +0 -6
- package/dist/helper/ssg/middleware.js +1 -16
- package/dist/{types/helper → helper}/ssg/ssg.d.ts +0 -12
- package/dist/helper/ssg/ssg.js +0 -3
- package/dist/{types/hono-base.d.ts → hono-base.d.ts} +3 -60
- package/dist/hono-base.js +6 -97
- package/dist/{types/hono.d.ts → hono.d.ts} +1 -1
- package/dist/{types/middleware → middleware}/basic-auth/index.d.ts +4 -3
- package/dist/middleware/basic-auth/index.js +1 -1
- package/dist/{types/middleware → middleware}/bearer-auth/index.d.ts +4 -27
- package/dist/middleware/bearer-auth/index.js +4 -4
- package/dist/middleware/language/language.js +1 -1
- package/dist/middleware/logger/index.js +6 -8
- package/dist/{types/middleware → middleware}/serve-static/index.d.ts +0 -4
- package/dist/{types/preset → preset}/quick.d.ts +1 -1
- package/dist/{types/preset → preset}/tiny.d.ts +1 -1
- package/dist/{types/request.d.ts → request.d.ts} +3 -48
- package/dist/request.js +0 -49
- package/dist/router/linear-router/router.js +4 -6
- package/dist/router/pattern-router/router.js +2 -2
- package/dist/router/reg-exp-router/node.js +1 -1
- package/dist/router/trie-router/node.js +3 -3
- package/dist/utils/buffer.d.ts +11 -0
- package/dist/utils/buffer.js +1 -8
- package/dist/utils/color.d.ts +16 -0
- package/dist/utils/color.js +7 -23
- package/dist/{types/utils → utils}/http-status.d.ts +1 -9
- package/dist/{types/utils → utils}/url.d.ts +0 -5
- package/dist/utils/url.js +1 -11
- package/dist/{types/validator → validator}/validator.d.ts +5 -0
- package/dist/validator/validator.js +46 -49
- package/package.json +209 -350
- package/dist/adapter/aws-lambda/conninfo.js +0 -43
- package/dist/adapter/aws-lambda/handler.js +0 -342
- package/dist/adapter/aws-lambda/index.js +0 -3
- package/dist/adapter/aws-lambda/types.js +0 -1
- package/dist/adapter/bun/conninfo.js +0 -22
- package/dist/adapter/bun/index.js +0 -6
- package/dist/adapter/bun/serve-static.js +0 -30
- package/dist/adapter/bun/server.js +0 -11
- package/dist/adapter/bun/ssg.js +0 -27
- package/dist/adapter/bun/websocket.js +0 -66
- package/dist/adapter/cloudflare-pages/conninfo.js +0 -24
- package/dist/adapter/cloudflare-pages/handler.js +0 -64
- package/dist/adapter/cloudflare-pages/index.js +0 -3
- package/dist/adapter/cloudflare-workers/conninfo.js +0 -7
- package/dist/adapter/cloudflare-workers/index.js +0 -4
- package/dist/adapter/cloudflare-workers/serve-static-module.js +0 -7
- package/dist/adapter/cloudflare-workers/serve-static.js +0 -28
- package/dist/adapter/cloudflare-workers/utils.js +0 -22
- package/dist/adapter/cloudflare-workers/websocket.js +0 -33
- package/dist/adapter/deno/conninfo.js +0 -17
- package/dist/adapter/deno/deno.d.js +0 -1
- package/dist/adapter/deno/index.js +0 -5
- package/dist/adapter/deno/serve-static.js +0 -35
- package/dist/adapter/deno/ssg.js +0 -29
- package/dist/adapter/deno/websocket.js +0 -32
- package/dist/adapter/lambda-edge/conninfo.js +0 -7
- package/dist/adapter/lambda-edge/handler.js +0 -111
- package/dist/adapter/lambda-edge/index.js +0 -3
- package/dist/adapter/netlify/conninfo.js +0 -24
- package/dist/adapter/netlify/handler.js +0 -11
- package/dist/adapter/netlify/index.js +0 -3
- package/dist/adapter/netlify/mod.js +0 -3
- package/dist/adapter/service-worker/handler.js +0 -16
- package/dist/adapter/service-worker/index.js +0 -25
- package/dist/adapter/service-worker/types.js +0 -1
- package/dist/adapter/vercel/conninfo.js +0 -7
- package/dist/adapter/vercel/handler.js +0 -9
- package/dist/adapter/vercel/index.js +0 -3
- package/dist/cjs/_virtual/_rolldown/runtime.js +0 -33
- package/dist/cjs/adapter/aws-lambda/conninfo.js +0 -44
- package/dist/cjs/adapter/aws-lambda/handler.js +0 -352
- package/dist/cjs/adapter/aws-lambda/index.js +0 -7
- package/dist/cjs/adapter/aws-lambda/types.js +0 -0
- package/dist/cjs/adapter/bun/conninfo.js +0 -23
- package/dist/cjs/adapter/bun/index.js +0 -14
- package/dist/cjs/adapter/bun/serve-static.js +0 -31
- package/dist/cjs/adapter/bun/server.js +0 -12
- package/dist/cjs/adapter/bun/ssg.js +0 -29
- package/dist/cjs/adapter/bun/websocket.js +0 -70
- package/dist/cjs/adapter/cloudflare-pages/conninfo.js +0 -25
- package/dist/cjs/adapter/cloudflare-pages/handler.js +0 -67
- package/dist/cjs/adapter/cloudflare-pages/index.js +0 -7
- package/dist/cjs/adapter/cloudflare-workers/conninfo.js +0 -8
- package/dist/cjs/adapter/cloudflare-workers/index.js +0 -7
- package/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +0 -8
- package/dist/cjs/adapter/cloudflare-workers/serve-static.js +0 -29
- package/dist/cjs/adapter/cloudflare-workers/utils.js +0 -23
- package/dist/cjs/adapter/cloudflare-workers/websocket.js +0 -34
- package/dist/cjs/adapter/deno/conninfo.js +0 -18
- package/dist/cjs/adapter/deno/deno.d.js +0 -0
- package/dist/cjs/adapter/deno/index.js +0 -10
- package/dist/cjs/adapter/deno/serve-static.js +0 -36
- package/dist/cjs/adapter/deno/ssg.js +0 -31
- package/dist/cjs/adapter/deno/websocket.js +0 -33
- package/dist/cjs/adapter/lambda-edge/conninfo.js +0 -8
- package/dist/cjs/adapter/lambda-edge/handler.js +0 -116
- package/dist/cjs/adapter/lambda-edge/index.js +0 -5
- package/dist/cjs/adapter/netlify/conninfo.js +0 -25
- package/dist/cjs/adapter/netlify/handler.js +0 -12
- package/dist/cjs/adapter/netlify/index.js +0 -5
- package/dist/cjs/adapter/netlify/mod.js +0 -5
- package/dist/cjs/adapter/service-worker/handler.js +0 -17
- package/dist/cjs/adapter/service-worker/index.js +0 -27
- package/dist/cjs/adapter/service-worker/types.js +0 -0
- package/dist/cjs/adapter/vercel/conninfo.js +0 -8
- package/dist/cjs/adapter/vercel/handler.js +0 -10
- package/dist/cjs/adapter/vercel/index.js +0 -5
- package/dist/cjs/client/client.js +0 -145
- package/dist/cjs/client/fetch-result-please.js +0 -67
- package/dist/cjs/client/index.js +0 -7
- package/dist/cjs/client/types.js +0 -0
- package/dist/cjs/client/utils.js +0 -70
- package/dist/cjs/compose.js +0 -51
- package/dist/cjs/context.js +0 -383
- package/dist/cjs/helper/accepts/accepts.js +0 -54
- package/dist/cjs/helper/accepts/index.js +0 -3
- package/dist/cjs/helper/adapter/index.js +0 -41
- package/dist/cjs/helper/conninfo/index.js +0 -0
- package/dist/cjs/helper/conninfo/types.js +0 -0
- package/dist/cjs/helper/cookie/index.js +0 -89
- package/dist/cjs/helper/css/common.js +0 -194
- package/dist/cjs/helper/css/index.js +0 -142
- package/dist/cjs/helper/dev/index.js +0 -53
- package/dist/cjs/helper/factory/index.js +0 -33
- package/dist/cjs/helper/html/index.js +0 -34
- package/dist/cjs/helper/proxy/index.js +0 -122
- package/dist/cjs/helper/route/index.js +0 -128
- package/dist/cjs/helper/ssg/index.js +0 -19
- package/dist/cjs/helper/ssg/middleware.js +0 -65
- package/dist/cjs/helper/ssg/plugins.js +0 -68
- package/dist/cjs/helper/ssg/ssg.js +0 -220
- package/dist/cjs/helper/ssg/utils.js +0 -70
- package/dist/cjs/helper/streaming/index.js +0 -8
- package/dist/cjs/helper/streaming/sse.js +0 -59
- package/dist/cjs/helper/streaming/stream.js +0 -26
- package/dist/cjs/helper/streaming/text.js +0 -12
- package/dist/cjs/helper/streaming/utils.js +0 -16
- package/dist/cjs/helper/testing/index.js +0 -18
- package/dist/cjs/helper/websocket/index.js +0 -56
- package/dist/cjs/hono-base.js +0 -351
- package/dist/cjs/hono.js +0 -29
- package/dist/cjs/http-exception.js +0 -56
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/jsx/base.js +0 -266
- package/dist/cjs/jsx/children.js +0 -19
- package/dist/cjs/jsx/components.js +0 -147
- package/dist/cjs/jsx/constants.js +0 -15
- package/dist/cjs/jsx/context.js +0 -170
- package/dist/cjs/jsx/dom/client.js +0 -56
- package/dist/cjs/jsx/dom/components.js +0 -26
- package/dist/cjs/jsx/dom/context.js +0 -43
- package/dist/cjs/jsx/dom/css.js +0 -153
- package/dist/cjs/jsx/dom/hooks/index.js +0 -65
- package/dist/cjs/jsx/dom/index.js +0 -122
- package/dist/cjs/jsx/dom/intrinsic-element/components.js +0 -306
- package/dist/cjs/jsx/dom/jsx-dev-runtime.js +0 -17
- package/dist/cjs/jsx/dom/jsx-runtime.js +0 -5
- package/dist/cjs/jsx/dom/render.js +0 -525
- package/dist/cjs/jsx/dom/server.js +0 -44
- package/dist/cjs/jsx/dom/utils.js +0 -9
- package/dist/cjs/jsx/hooks/index.js +0 -280
- package/dist/cjs/jsx/index.js +0 -89
- package/dist/cjs/jsx/intrinsic-element/common.js +0 -27
- package/dist/cjs/jsx/intrinsic-element/components.js +0 -138
- package/dist/cjs/jsx/intrinsic-elements.js +0 -0
- package/dist/cjs/jsx/jsx-dev-runtime.js +0 -16
- package/dist/cjs/jsx/jsx-runtime.js +0 -37
- package/dist/cjs/jsx/streaming.js +0 -135
- package/dist/cjs/jsx/types.js +0 -0
- package/dist/cjs/jsx/utils.js +0 -116
- package/dist/cjs/middleware/basic-auth/index.js +0 -100
- package/dist/cjs/middleware/bearer-auth/index.js +0 -97
- package/dist/cjs/middleware/body-limit/index.js +0 -69
- package/dist/cjs/middleware/cache/index.js +0 -173
- package/dist/cjs/middleware/combine/index.js +0 -141
- package/dist/cjs/middleware/compress/index.js +0 -82
- package/dist/cjs/middleware/context-storage/index.js +0 -55
- package/dist/cjs/middleware/cors/index.js +0 -109
- package/dist/cjs/middleware/csrf/index.js +0 -106
- package/dist/cjs/middleware/etag/digest.js +0 -62
- package/dist/cjs/middleware/etag/index.js +0 -79
- package/dist/cjs/middleware/ip-restriction/index.js +0 -168
- package/dist/cjs/middleware/jsx-renderer/index.js +0 -104
- package/dist/cjs/middleware/jwk/index.js +0 -3
- package/dist/cjs/middleware/jwk/jwk.js +0 -122
- package/dist/cjs/middleware/jwt/index.js +0 -9
- package/dist/cjs/middleware/jwt/jwt.js +0 -124
- package/dist/cjs/middleware/language/index.js +0 -7
- package/dist/cjs/middleware/language/language.js +0 -208
- package/dist/cjs/middleware/logger/index.js +0 -51
- package/dist/cjs/middleware/method-not-allowed/index.js +0 -84
- package/dist/cjs/middleware/method-override/index.js +0 -105
- package/dist/cjs/middleware/mount/index.js +0 -71
- package/dist/cjs/middleware/powered-by/index.js +0 -25
- package/dist/cjs/middleware/pretty-json/index.js +0 -41
- package/dist/cjs/middleware/request-id/index.js +0 -3
- package/dist/cjs/middleware/request-id/request-id.js +0 -35
- package/dist/cjs/middleware/secure-headers/index.js +0 -4
- package/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -0
- package/dist/cjs/middleware/secure-headers/secure-headers.js +0 -166
- package/dist/cjs/middleware/serve-static/index.js +0 -62
- package/dist/cjs/middleware/serve-static/path.js +0 -17
- package/dist/cjs/middleware/timeout/index.js +0 -42
- package/dist/cjs/middleware/timing/index.js +0 -7
- package/dist/cjs/middleware/timing/timing.js +0 -189
- package/dist/cjs/middleware/trailing-slash/index.js +0 -89
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/preset/quick.js +0 -19
- package/dist/cjs/preset/tiny.js +0 -16
- package/dist/cjs/request/constants.js +0 -5
- package/dist/cjs/request.js +0 -337
- package/dist/cjs/router/linear-router/index.js +0 -3
- package/dist/cjs/router/linear-router/router.js +0 -97
- package/dist/cjs/router/pattern-router/index.js +0 -3
- package/dist/cjs/router/pattern-router/router.js +0 -42
- package/dist/cjs/router/reg-exp-router/index.js +0 -7
- package/dist/cjs/router/reg-exp-router/matcher.js +0 -21
- package/dist/cjs/router/reg-exp-router/node.js +0 -96
- package/dist/cjs/router/reg-exp-router/prepared-router.js +0 -97
- package/dist/cjs/router/reg-exp-router/router.js +0 -102
- package/dist/cjs/router/reg-exp-router/trie.js +0 -74
- package/dist/cjs/router/smart-router/index.js +0 -3
- package/dist/cjs/router/smart-router/router.js +0 -50
- package/dist/cjs/router/trie-router/index.js +0 -3
- package/dist/cjs/router/trie-router/node.js +0 -135
- package/dist/cjs/router/trie-router/router.js +0 -16
- package/dist/cjs/router/utils.js +0 -5
- package/dist/cjs/router.js +0 -40
- package/dist/cjs/types.js +0 -5
- package/dist/cjs/utils/accept.js +0 -194
- package/dist/cjs/utils/basic-auth.js +0 -21
- package/dist/cjs/utils/body.js +0 -97
- package/dist/cjs/utils/buffer.js +0 -55
- package/dist/cjs/utils/color.js +0 -39
- package/dist/cjs/utils/compress.js +0 -12
- package/dist/cjs/utils/concurrent.js +0 -31
- package/dist/cjs/utils/constants.js +0 -8
- package/dist/cjs/utils/cookie.js +0 -129
- package/dist/cjs/utils/crypto.js +0 -38
- package/dist/cjs/utils/encode.js +0 -37
- package/dist/cjs/utils/filepath.js +0 -27
- package/dist/cjs/utils/handler.js +0 -14
- package/dist/cjs/utils/headers.js +0 -0
- package/dist/cjs/utils/html.js +0 -109
- package/dist/cjs/utils/http-status.js +0 -0
- package/dist/cjs/utils/ipaddr.js +0 -247
- package/dist/cjs/utils/jwt/index.js +0 -15
- package/dist/cjs/utils/jwt/jwa.js +0 -25
- package/dist/cjs/utils/jwt/jws.js +0 -135
- package/dist/cjs/utils/jwt/jwt.js +0 -136
- package/dist/cjs/utils/jwt/types.js +0 -124
- package/dist/cjs/utils/jwt/utf8.js +0 -11
- package/dist/cjs/utils/mime.js +0 -80
- package/dist/cjs/utils/stream.js +0 -89
- package/dist/cjs/utils/types.js +0 -0
- package/dist/cjs/utils/url.js +0 -215
- package/dist/cjs/validator/index.js +0 -3
- package/dist/cjs/validator/utils.js +0 -0
- package/dist/cjs/validator/validator.js +0 -65
- package/dist/types/adapter/aws-lambda/conninfo.d.ts +0 -30
- package/dist/types/adapter/aws-lambda/handler.d.ts +0 -230
- package/dist/types/adapter/aws-lambda/index.d.ts +0 -4
- package/dist/types/adapter/aws-lambda/types.d.ts +0 -183
- package/dist/types/adapter/bun/conninfo.d.ts +0 -10
- package/dist/types/adapter/bun/index.d.ts +0 -6
- package/dist/types/adapter/bun/serve-static.d.ts +0 -8
- package/dist/types/adapter/bun/server.d.ts +0 -11
- package/dist/types/adapter/bun/ssg.d.ts +0 -17
- package/dist/types/adapter/bun/websocket.d.ts +0 -54
- package/dist/types/adapter/cloudflare-pages/conninfo.d.ts +0 -24
- package/dist/types/adapter/cloudflare-pages/handler.d.ts +0 -45
- package/dist/types/adapter/cloudflare-pages/index.d.ts +0 -3
- package/dist/types/adapter/cloudflare-workers/conninfo.d.ts +0 -7
- package/dist/types/adapter/cloudflare-workers/index.d.ts +0 -4
- package/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +0 -7
- package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +0 -21
- package/dist/types/adapter/cloudflare-workers/utils.d.ts +0 -13
- package/dist/types/adapter/cloudflare-workers/websocket.d.ts +0 -7
- package/dist/types/adapter/deno/conninfo.d.ts +0 -10
- package/dist/types/adapter/deno/deno.d.ts +0 -1
- package/dist/types/adapter/deno/index.d.ts +0 -5
- package/dist/types/adapter/deno/serve-static.d.ts +0 -8
- package/dist/types/adapter/deno/ssg.d.ts +0 -17
- package/dist/types/adapter/deno/websocket.d.ts +0 -7
- package/dist/types/adapter/lambda-edge/conninfo.d.ts +0 -7
- package/dist/types/adapter/lambda-edge/handler.d.ts +0 -113
- package/dist/types/adapter/lambda-edge/index.d.ts +0 -3
- package/dist/types/adapter/netlify/conninfo.d.ts +0 -24
- package/dist/types/adapter/netlify/handler.d.ts +0 -7
- package/dist/types/adapter/netlify/index.d.ts +0 -3
- package/dist/types/adapter/netlify/mod.d.ts +0 -3
- package/dist/types/adapter/service-worker/handler.d.ts +0 -18
- package/dist/types/adapter/service-worker/index.d.ts +0 -26
- package/dist/types/adapter/service-worker/types.d.ts +0 -17
- package/dist/types/adapter/vercel/conninfo.d.ts +0 -7
- package/dist/types/adapter/vercel/handler.d.ts +0 -7
- package/dist/types/adapter/vercel/index.d.ts +0 -3
- package/dist/types/package.json +0 -3
- package/dist/types/utils/buffer.d.ts +0 -19
- package/dist/types/utils/color.d.ts +0 -23
- package/dist/{types/client → client}/client.d.ts +0 -0
- package/dist/{types/client → client}/fetch-result-please.d.ts +0 -0
- package/dist/{types/client → client}/index.d.ts +0 -0
- package/dist/{types/client → client}/types.d.ts +1 -1
- package/dist/{types/client → client}/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/accepts/accepts.d.ts +0 -0
- package/dist/{types/helper → helper}/accepts/index.d.ts +0 -0
- package/dist/{types/helper → helper}/adapter/index.d.ts +0 -0
- package/dist/{types/helper → helper}/conninfo/index.d.ts +0 -0
- package/dist/{types/helper → helper}/conninfo/types.d.ts +0 -0
- package/dist/{types/helper → helper}/cookie/index.d.ts +0 -0
- package/dist/{types/helper → helper}/css/common.d.ts +0 -0
- package/dist/{types/helper → helper}/css/index.d.ts +0 -0
- package/dist/{types/helper → helper}/dev/index.d.ts +0 -0
- package/dist/{types/helper → helper}/html/index.d.ts +0 -0
- package/dist/{types/helper → helper}/proxy/index.d.ts +0 -0
- package/dist/{types/helper → helper}/route/index.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/index.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/plugins.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/index.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/sse.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/stream.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/text.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/testing/index.d.ts +0 -0
- package/dist/{types/helper → helper}/websocket/index.d.ts +0 -0
- package/dist/{types/http-exception.d.ts → http-exception.d.ts} +0 -0
- package/dist/{types/index.d.ts → index.d.ts} +0 -0
- package/dist/{types/jsx → jsx}/base.d.ts +0 -0
- package/dist/{types/jsx → jsx}/children.d.ts +0 -0
- package/dist/{types/jsx → jsx}/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/constants.d.ts +0 -0
- package/dist/{types/jsx → jsx}/context.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/client.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/context.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/css.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/hooks/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/intrinsic-element/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/jsx-dev-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/jsx-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/render.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/server.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/utils.d.ts +0 -0
- package/dist/{types/jsx → jsx}/hooks/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-element/common.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-element/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-elements.d.ts +0 -0
- package/dist/{types/jsx → jsx}/jsx-dev-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/jsx-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/streaming.d.ts +0 -0
- package/dist/{types/jsx → jsx}/types.d.ts +0 -0
- package/dist/{types/jsx → jsx}/utils.d.ts +0 -0
- package/dist/{types/middleware → middleware}/body-limit/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/cache/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/combine/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/compress/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/context-storage/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/cors/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/csrf/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/etag/digest.d.ts +0 -0
- package/dist/{types/middleware → middleware}/etag/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/ip-restriction/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jsx-renderer/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwk/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwk/jwk.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwt/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwt/jwt.d.ts +0 -0
- package/dist/{types/middleware → middleware}/language/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/language/language.d.ts +0 -0
- package/dist/{types/middleware → middleware}/logger/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/method-not-allowed/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/method-override/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/mount/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/powered-by/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/pretty-json/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/request-id/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/request-id/request-id.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/permissions-policy.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/secure-headers.d.ts +0 -0
- package/dist/{types/middleware → middleware}/serve-static/path.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timeout/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timing/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timing/timing.d.ts +0 -0
- package/dist/{types/middleware → middleware}/trailing-slash/index.d.ts +0 -0
- package/dist/{types/request → request}/constants.d.ts +0 -0
- package/dist/{types/router → router}/linear-router/index.d.ts +0 -0
- package/dist/{types/router → router}/linear-router/router.d.ts +0 -0
- package/dist/{types/router → router}/pattern-router/index.d.ts +0 -0
- package/dist/{types/router → router}/pattern-router/router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/index.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/matcher.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/node.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/prepared-router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/trie.d.ts +0 -0
- package/dist/{types/router → router}/smart-router/index.d.ts +0 -0
- package/dist/{types/router → router}/smart-router/router.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/index.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/node.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/router.d.ts +0 -0
- package/dist/{types/router → router}/utils.d.ts +0 -0
- package/dist/{types/router.d.ts → router.d.ts} +0 -0
- package/dist/{types/types.d.ts → types.d.ts} +1 -1
- /package/dist/{types/utils → utils}/accept.d.ts +0 -0
- /package/dist/{types/utils → utils}/basic-auth.d.ts +0 -0
- /package/dist/{types/utils → utils}/body.d.ts +0 -0
- /package/dist/{types/utils → utils}/compress.d.ts +0 -0
- /package/dist/{types/utils → utils}/concurrent.d.ts +0 -0
- /package/dist/{types/utils → utils}/constants.d.ts +0 -0
- /package/dist/{types/utils → utils}/cookie.d.ts +0 -0
- /package/dist/{types/utils → utils}/crypto.d.ts +0 -0
- /package/dist/{types/utils → utils}/encode.d.ts +0 -0
- /package/dist/{types/utils → utils}/filepath.d.ts +0 -0
- /package/dist/{types/utils → utils}/handler.d.ts +0 -0
- /package/dist/{types/utils → utils}/headers.d.ts +0 -0
- /package/dist/{types/utils → utils}/html.d.ts +0 -0
- /package/dist/{types/utils → utils}/ipaddr.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/index.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jwa.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jws.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jwt.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/types.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/utf8.d.ts +0 -0
- /package/dist/{types/utils → utils}/mime.d.ts +0 -0
- /package/dist/{types/utils → utils}/stream.d.ts +0 -0
- /package/dist/{types/utils → utils}/types.d.ts +0 -0
- /package/dist/{types/validator → validator}/index.d.ts +0 -0
- /package/dist/{types/validator → validator}/utils.d.ts +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/helper/streaming/utils.ts
|
|
3
|
-
let isOldBunVersion = () => {
|
|
4
|
-
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
5
|
-
if (version === void 0) return false;
|
|
6
|
-
const result = version.startsWith("1.1") || version.startsWith("1.0") || version.startsWith("0.");
|
|
7
|
-
isOldBunVersion = () => result;
|
|
8
|
-
return result;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
Object.defineProperty(exports, "isOldBunVersion", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function() {
|
|
14
|
-
return isOldBunVersion;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_client_client = require("../../client/client.js");
|
|
3
|
-
//#region src/helper/testing/index.ts
|
|
4
|
-
/**
|
|
5
|
-
* @module
|
|
6
|
-
* Testing Helper for Hono.
|
|
7
|
-
*/
|
|
8
|
-
const testClient = (app, Env, executionCtx, options) => {
|
|
9
|
-
const customFetch = (input, init) => {
|
|
10
|
-
return app.request(input, init, Env, executionCtx);
|
|
11
|
-
};
|
|
12
|
-
return require_client_client.hc("http://localhost", {
|
|
13
|
-
...options,
|
|
14
|
-
fetch: customFetch
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
exports.testClient = testClient;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/helper/websocket/index.ts
|
|
3
|
-
/**
|
|
4
|
-
* A context for controlling WebSockets
|
|
5
|
-
*/
|
|
6
|
-
var WSContext = class {
|
|
7
|
-
#init;
|
|
8
|
-
constructor(init) {
|
|
9
|
-
this.#init = init;
|
|
10
|
-
this.raw = init.raw;
|
|
11
|
-
this.url = init.url ? new URL(init.url) : null;
|
|
12
|
-
this.protocol = init.protocol ?? null;
|
|
13
|
-
}
|
|
14
|
-
send(source, options) {
|
|
15
|
-
this.#init.send(source, options ?? {});
|
|
16
|
-
}
|
|
17
|
-
raw;
|
|
18
|
-
binaryType = "arraybuffer";
|
|
19
|
-
get readyState() {
|
|
20
|
-
return this.#init.readyState;
|
|
21
|
-
}
|
|
22
|
-
url;
|
|
23
|
-
protocol;
|
|
24
|
-
close(code, reason) {
|
|
25
|
-
this.#init.close(code, reason);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const createWSMessageEvent = (source) => {
|
|
29
|
-
return new MessageEvent("message", { data: source });
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Create a WebSocket adapter/helper
|
|
33
|
-
*/
|
|
34
|
-
const defineWebSocketHelper = (handler) => {
|
|
35
|
-
return ((...args) => {
|
|
36
|
-
if (typeof args[0] === "function") {
|
|
37
|
-
const [createEvents, options] = args;
|
|
38
|
-
return async function upgradeWebSocket(c, next) {
|
|
39
|
-
const result = await handler(c, await createEvents(c), options);
|
|
40
|
-
if (result) return result;
|
|
41
|
-
await next();
|
|
42
|
-
};
|
|
43
|
-
} else {
|
|
44
|
-
const [c, events, options] = args;
|
|
45
|
-
return (async () => {
|
|
46
|
-
const upgraded = await handler(c, events, options);
|
|
47
|
-
if (!upgraded) throw new Error("Failed to upgrade WebSocket");
|
|
48
|
-
return upgraded;
|
|
49
|
-
})();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
//#endregion
|
|
54
|
-
exports.WSContext = WSContext;
|
|
55
|
-
exports.createWSMessageEvent = createWSMessageEvent;
|
|
56
|
-
exports.defineWebSocketHelper = defineWebSocketHelper;
|
package/dist/cjs/hono-base.js
DELETED
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_compose = require("./compose.js");
|
|
3
|
-
const require_utils_url = require("./utils/url.js");
|
|
4
|
-
const require_context = require("./context.js");
|
|
5
|
-
const require_router = require("./router.js");
|
|
6
|
-
const require_utils_constants = require("./utils/constants.js");
|
|
7
|
-
//#region src/hono-base.ts
|
|
8
|
-
/**
|
|
9
|
-
* @module
|
|
10
|
-
* This module is the base module for the Hono object.
|
|
11
|
-
*/
|
|
12
|
-
const notFoundHandler = (c) => {
|
|
13
|
-
return c.text("404 Not Found", 404);
|
|
14
|
-
};
|
|
15
|
-
const errorHandler = (err, c) => {
|
|
16
|
-
if ("getResponse" in err) {
|
|
17
|
-
const res = err.getResponse();
|
|
18
|
-
return c.newResponse(res.body, res);
|
|
19
|
-
}
|
|
20
|
-
console.error(err);
|
|
21
|
-
return c.text("Internal Server Error", 500);
|
|
22
|
-
};
|
|
23
|
-
var Hono = class Hono {
|
|
24
|
-
get;
|
|
25
|
-
post;
|
|
26
|
-
put;
|
|
27
|
-
delete;
|
|
28
|
-
options;
|
|
29
|
-
patch;
|
|
30
|
-
query;
|
|
31
|
-
all;
|
|
32
|
-
on;
|
|
33
|
-
use;
|
|
34
|
-
router;
|
|
35
|
-
getPath;
|
|
36
|
-
_basePath = "/";
|
|
37
|
-
#path = "/";
|
|
38
|
-
routes = [];
|
|
39
|
-
constructor(options = {}) {
|
|
40
|
-
[...require_router.METHODS, "all"].forEach((method) => {
|
|
41
|
-
this[method] = (args1, ...args) => {
|
|
42
|
-
const methodName = method.toUpperCase();
|
|
43
|
-
if (typeof args1 === "string") this.#path = args1;
|
|
44
|
-
else this.#addRoute(methodName, this.#path, args1);
|
|
45
|
-
args.forEach((handler) => {
|
|
46
|
-
this.#addRoute(methodName, this.#path, handler);
|
|
47
|
-
});
|
|
48
|
-
return this;
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
this.on = (method, path, ...handlers) => {
|
|
52
|
-
for (const p of [path].flat()) {
|
|
53
|
-
this.#path = p;
|
|
54
|
-
for (const m of [method].flat()) {
|
|
55
|
-
const methodName = m.toUpperCase();
|
|
56
|
-
for (const handler of handlers) this.#addRoute(methodName, this.#path, handler);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return this;
|
|
60
|
-
};
|
|
61
|
-
this.use = (arg1, ...handlers) => {
|
|
62
|
-
if (typeof arg1 === "string") this.#path = arg1;
|
|
63
|
-
else {
|
|
64
|
-
this.#path = "*";
|
|
65
|
-
handlers.unshift(arg1);
|
|
66
|
-
}
|
|
67
|
-
handlers.forEach((handler) => {
|
|
68
|
-
this.#addRoute("ALL", this.#path, handler);
|
|
69
|
-
});
|
|
70
|
-
return this;
|
|
71
|
-
};
|
|
72
|
-
const { strict, ...optionsWithoutStrict } = options;
|
|
73
|
-
Object.assign(this, optionsWithoutStrict);
|
|
74
|
-
this.getPath = strict ?? true ? options.getPath ?? require_utils_url.getPath : require_utils_url.getPathNoStrict;
|
|
75
|
-
}
|
|
76
|
-
#clone() {
|
|
77
|
-
const clone = new Hono({
|
|
78
|
-
router: this.router,
|
|
79
|
-
getPath: this.getPath
|
|
80
|
-
});
|
|
81
|
-
clone.errorHandler = this.errorHandler;
|
|
82
|
-
clone.#notFoundHandler = this.#notFoundHandler;
|
|
83
|
-
clone.routes = this.routes;
|
|
84
|
-
return clone;
|
|
85
|
-
}
|
|
86
|
-
#notFoundHandler = notFoundHandler;
|
|
87
|
-
errorHandler = errorHandler;
|
|
88
|
-
/**
|
|
89
|
-
* `.route()` allows grouping other Hono instance in routes.
|
|
90
|
-
*
|
|
91
|
-
* @see {@link https://hono.dev/docs/api/routing#grouping}
|
|
92
|
-
*
|
|
93
|
-
* @param {string} path - base Path
|
|
94
|
-
* @param {Hono} app - other Hono instance
|
|
95
|
-
* @returns {Hono} routed Hono instance
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```ts
|
|
99
|
-
* const app = new Hono()
|
|
100
|
-
* const app2 = new Hono()
|
|
101
|
-
*
|
|
102
|
-
* app2.get("/user", (c) => c.text("user"))
|
|
103
|
-
* app.route("/api", app2) // GET /api/user
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
route(path, app) {
|
|
107
|
-
const subApp = this.basePath(path);
|
|
108
|
-
app.routes.map((r) => {
|
|
109
|
-
let handler;
|
|
110
|
-
if (app.errorHandler === errorHandler) handler = r.handler;
|
|
111
|
-
else {
|
|
112
|
-
handler = async (c, next) => (await require_compose.compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
|
|
113
|
-
handler[require_utils_constants.COMPOSED_HANDLER] = r.handler;
|
|
114
|
-
}
|
|
115
|
-
subApp.#addRoute(r.method, r.path, handler, r.basePath);
|
|
116
|
-
});
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* `.basePath()` allows base paths to be specified.
|
|
121
|
-
*
|
|
122
|
-
* @see {@link https://hono.dev/docs/api/routing#base-path}
|
|
123
|
-
*
|
|
124
|
-
* @param {string} path - base Path
|
|
125
|
-
* @returns {Hono} changed Hono instance
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```ts
|
|
129
|
-
* const api = new Hono().basePath('/api')
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
basePath(path) {
|
|
133
|
-
const subApp = this.#clone();
|
|
134
|
-
subApp._basePath = require_utils_url.mergePath(this._basePath, path);
|
|
135
|
-
return subApp;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* `.onError()` handles an error and returns a customized Response.
|
|
139
|
-
*
|
|
140
|
-
* @see {@link https://hono.dev/docs/api/hono#error-handling}
|
|
141
|
-
*
|
|
142
|
-
* @param {ErrorHandler} handler - request Handler for error
|
|
143
|
-
* @returns {Hono} changed Hono instance
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```ts
|
|
147
|
-
* app.onError((err, c) => {
|
|
148
|
-
* console.error(`${err}`)
|
|
149
|
-
* return c.text('Custom Error Message', 500)
|
|
150
|
-
* })
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
onError = (handler) => {
|
|
154
|
-
this.errorHandler = handler;
|
|
155
|
-
return this;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* `.notFound()` allows you to customize a Not Found Response.
|
|
159
|
-
*
|
|
160
|
-
* @see {@link https://hono.dev/docs/api/hono#not-found}
|
|
161
|
-
*
|
|
162
|
-
* @param {NotFoundHandler} handler - request handler for not-found
|
|
163
|
-
* @returns {Hono} changed Hono instance
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* ```ts
|
|
167
|
-
* app.notFound((c) => {
|
|
168
|
-
* return c.text('Custom 404 Message', 404)
|
|
169
|
-
* })
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
notFound = (handler) => {
|
|
173
|
-
this.#notFoundHandler = handler;
|
|
174
|
-
return this;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* `.mount()` allows you to mount applications built with other frameworks into your Hono application.
|
|
178
|
-
*
|
|
179
|
-
* @deprecated Use `mount()` from `hono/mount` instead. `.mount()` will be removed in v5.
|
|
180
|
-
*
|
|
181
|
-
* @see {@link https://hono.dev/docs/api/hono#mount}
|
|
182
|
-
*
|
|
183
|
-
* @param {string} path - base Path
|
|
184
|
-
* @param {Function} applicationHandler - other Request Handler
|
|
185
|
-
* @param {MountOptions} [options] - options of `.mount()`
|
|
186
|
-
* @returns {Hono} mounted Hono instance
|
|
187
|
-
*
|
|
188
|
-
* @example
|
|
189
|
-
* ```ts
|
|
190
|
-
* import { Router as IttyRouter } from 'itty-router'
|
|
191
|
-
* import { Hono } from 'hono'
|
|
192
|
-
* // Create itty-router application
|
|
193
|
-
* const ittyRouter = IttyRouter()
|
|
194
|
-
* // GET /itty-router/hello
|
|
195
|
-
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
|
|
196
|
-
*
|
|
197
|
-
* const app = new Hono()
|
|
198
|
-
* app.mount('/itty-router', ittyRouter.handle)
|
|
199
|
-
* ```
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* const app = new Hono()
|
|
204
|
-
* // Send the request to another application without modification.
|
|
205
|
-
* app.mount('/app', anotherApp, {
|
|
206
|
-
* replaceRequest: (req) => req,
|
|
207
|
-
* })
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
mount(path, applicationHandler, options) {
|
|
211
|
-
let replaceRequest;
|
|
212
|
-
let optionHandler;
|
|
213
|
-
if (options) {
|
|
214
|
-
if (typeof options === "function") optionHandler = options;
|
|
215
|
-
else {
|
|
216
|
-
optionHandler = options.optionHandler;
|
|
217
|
-
if (options.replaceRequest === false) replaceRequest = (request) => request;
|
|
218
|
-
else replaceRequest = options.replaceRequest;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const getOptions = optionHandler ? (c) => {
|
|
222
|
-
const options = optionHandler(c);
|
|
223
|
-
return Array.isArray(options) ? options : [options];
|
|
224
|
-
} : (c) => {
|
|
225
|
-
let executionContext = void 0;
|
|
226
|
-
try {
|
|
227
|
-
executionContext = c.executionCtx;
|
|
228
|
-
} catch {}
|
|
229
|
-
return [c.env, executionContext];
|
|
230
|
-
};
|
|
231
|
-
replaceRequest ||= (() => {
|
|
232
|
-
const mergedPath = require_utils_url.mergePath(this._basePath, path);
|
|
233
|
-
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
234
|
-
return (request) => {
|
|
235
|
-
const url = new URL(request.url);
|
|
236
|
-
url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
|
|
237
|
-
return new Request(url, request);
|
|
238
|
-
};
|
|
239
|
-
})();
|
|
240
|
-
const handler = async (c, next) => {
|
|
241
|
-
const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
|
|
242
|
-
if (res) return res;
|
|
243
|
-
await next();
|
|
244
|
-
};
|
|
245
|
-
this.#addRoute("ALL", require_utils_url.mergePath(path, "*"), handler);
|
|
246
|
-
return this;
|
|
247
|
-
}
|
|
248
|
-
#addRoute(method, path, handler, baseRoutePath) {
|
|
249
|
-
path = require_utils_url.mergePath(this._basePath, path);
|
|
250
|
-
const r = {
|
|
251
|
-
basePath: baseRoutePath !== void 0 ? require_utils_url.mergePath(this._basePath, baseRoutePath) : this._basePath,
|
|
252
|
-
path,
|
|
253
|
-
method,
|
|
254
|
-
handler
|
|
255
|
-
};
|
|
256
|
-
this.router.add(method, path, [handler, r]);
|
|
257
|
-
this.routes.push(r);
|
|
258
|
-
}
|
|
259
|
-
#handleError(err, c) {
|
|
260
|
-
if (err instanceof Error) return this.errorHandler(err, c);
|
|
261
|
-
throw err;
|
|
262
|
-
}
|
|
263
|
-
#dispatch(request, executionCtx, env, method) {
|
|
264
|
-
if (method === "HEAD") return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
|
|
265
|
-
const path = this.getPath(request, { env });
|
|
266
|
-
const matchResult = this.router.match(method, path);
|
|
267
|
-
const c = new require_context.Context(request, {
|
|
268
|
-
path,
|
|
269
|
-
matchResult,
|
|
270
|
-
env,
|
|
271
|
-
executionCtx,
|
|
272
|
-
notFoundHandler: this.#notFoundHandler
|
|
273
|
-
});
|
|
274
|
-
if (matchResult[0].length === 1) {
|
|
275
|
-
let res;
|
|
276
|
-
try {
|
|
277
|
-
res = matchResult[0][0][0][0](c, async () => {
|
|
278
|
-
c.res = await this.#notFoundHandler(c);
|
|
279
|
-
});
|
|
280
|
-
} catch (err) {
|
|
281
|
-
return this.#handleError(err, c);
|
|
282
|
-
}
|
|
283
|
-
return res instanceof Promise ? res.then((resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c))).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c);
|
|
284
|
-
}
|
|
285
|
-
const composed = require_compose.compose(matchResult[0], this.errorHandler, this.#notFoundHandler);
|
|
286
|
-
return (async () => {
|
|
287
|
-
try {
|
|
288
|
-
const context = await composed(c);
|
|
289
|
-
if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
|
|
290
|
-
return context.res;
|
|
291
|
-
} catch (err) {
|
|
292
|
-
return this.#handleError(err, c);
|
|
293
|
-
}
|
|
294
|
-
})();
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* `.fetch()` will be entry point of your app.
|
|
298
|
-
*
|
|
299
|
-
* @see {@link https://hono.dev/docs/api/hono#fetch}
|
|
300
|
-
*
|
|
301
|
-
* @param {Request} request - request Object of request
|
|
302
|
-
* @param {Env} env - env Object
|
|
303
|
-
* @param {ExecutionContext} executionCtx - context of execution
|
|
304
|
-
* @returns {Response | Promise<Response>} response of request
|
|
305
|
-
*
|
|
306
|
-
*/
|
|
307
|
-
fetch = (request, ...rest) => {
|
|
308
|
-
return this.#dispatch(request, rest[1], rest[0], request.method);
|
|
309
|
-
};
|
|
310
|
-
/**
|
|
311
|
-
* `.request()` is a useful method for testing.
|
|
312
|
-
* You can pass a URL or pathname to send a GET request.
|
|
313
|
-
* app will return a Response object.
|
|
314
|
-
* ```ts
|
|
315
|
-
* test('GET /hello is ok', async () => {
|
|
316
|
-
* const res = await app.request('/hello')
|
|
317
|
-
* expect(res.status).toBe(200)
|
|
318
|
-
* })
|
|
319
|
-
* ```
|
|
320
|
-
* @see https://hono.dev/docs/api/hono#request
|
|
321
|
-
*/
|
|
322
|
-
request = (input, requestInit, Env, executionCtx) => {
|
|
323
|
-
if (input instanceof Request) return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
|
|
324
|
-
input = input.toString();
|
|
325
|
-
return this.fetch(new Request(/^https?:\/\//.test(input) ? input : `http://localhost${require_utils_url.mergePath("/", input)}`, requestInit), Env, executionCtx);
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* `.fire()` automatically adds a global fetch event listener.
|
|
329
|
-
* This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
|
|
330
|
-
* @deprecated
|
|
331
|
-
* Use `fire` from `hono/service-worker` instead.
|
|
332
|
-
* ```ts
|
|
333
|
-
* import { Hono } from 'hono'
|
|
334
|
-
* import { fire } from 'hono/service-worker'
|
|
335
|
-
*
|
|
336
|
-
* const app = new Hono()
|
|
337
|
-
* // ...
|
|
338
|
-
* fire(app)
|
|
339
|
-
* ```
|
|
340
|
-
* @see https://hono.dev/docs/api/hono#fire
|
|
341
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
342
|
-
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
|
|
343
|
-
*/
|
|
344
|
-
fire = () => {
|
|
345
|
-
addEventListener("fetch", (event) => {
|
|
346
|
-
event.respondWith(this.#dispatch(event.request, event, void 0, event.request.method));
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
//#endregion
|
|
351
|
-
exports.HonoBase = Hono;
|
package/dist/cjs/hono.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_hono_base = require("./hono-base.js");
|
|
3
|
-
const require_router_reg_exp_router_router = require("./router/reg-exp-router/router.js");
|
|
4
|
-
require("./router/reg-exp-router/index.js");
|
|
5
|
-
const require_router_smart_router_router = require("./router/smart-router/router.js");
|
|
6
|
-
const require_router_trie_router_router = require("./router/trie-router/router.js");
|
|
7
|
-
require("./router/trie-router/index.js");
|
|
8
|
-
//#region src/hono.ts
|
|
9
|
-
/**
|
|
10
|
-
* The Hono class extends the functionality of the HonoBase class.
|
|
11
|
-
* It sets up routing and allows for custom options to be passed.
|
|
12
|
-
*
|
|
13
|
-
* @template E - The environment type.
|
|
14
|
-
* @template S - The schema type.
|
|
15
|
-
* @template BasePath - The base path type.
|
|
16
|
-
*/
|
|
17
|
-
var Hono = class extends require_hono_base.HonoBase {
|
|
18
|
-
/**
|
|
19
|
-
* Creates an instance of the Hono class.
|
|
20
|
-
*
|
|
21
|
-
* @param options - Optional configuration options for the Hono instance.
|
|
22
|
-
*/
|
|
23
|
-
constructor(options = {}) {
|
|
24
|
-
super(options);
|
|
25
|
-
this.router = options.router ?? new require_router_smart_router_router.SmartRouter({ routers: [new require_router_reg_exp_router_router.RegExpRouter(), new require_router_trie_router_router.TrieRouter()] });
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
exports.Hono = Hono;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/http-exception.ts
|
|
3
|
-
/**
|
|
4
|
-
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
|
|
5
|
-
*
|
|
6
|
-
* @see {@link https://hono.dev/docs/api/exception}
|
|
7
|
-
*
|
|
8
|
-
* @param {StatusCode} status - status code of HTTPException
|
|
9
|
-
* @param {HTTPExceptionOptions} options - options of HTTPException
|
|
10
|
-
* @param {HTTPExceptionOptions["res"]} options.res - response of options of HTTPException
|
|
11
|
-
* @param {HTTPExceptionOptions["message"]} options.message - message of options of HTTPException
|
|
12
|
-
* @param {HTTPExceptionOptions["cause"]} options.cause - cause of options of HTTPException
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { HTTPException } from 'hono/http-exception'
|
|
17
|
-
*
|
|
18
|
-
* // ...
|
|
19
|
-
*
|
|
20
|
-
* app.post('/auth', async (c, next) => {
|
|
21
|
-
* // authentication
|
|
22
|
-
* if (authorized === false) {
|
|
23
|
-
* throw new HTTPException(401, { message: 'Custom error message' })
|
|
24
|
-
* }
|
|
25
|
-
* await next()
|
|
26
|
-
* })
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
var HTTPException = class extends Error {
|
|
30
|
-
res;
|
|
31
|
-
status;
|
|
32
|
-
/**
|
|
33
|
-
* Creates an instance of `HTTPException`.
|
|
34
|
-
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
35
|
-
* @param options - Additional options for the exception.
|
|
36
|
-
*/
|
|
37
|
-
constructor(status = 500, options) {
|
|
38
|
-
super(options?.message, { cause: options?.cause });
|
|
39
|
-
this.res = options?.res;
|
|
40
|
-
this.status = status;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Returns the response object associated with the exception.
|
|
44
|
-
* If a response object is not provided, a new response is created with the error message and status code.
|
|
45
|
-
* @returns The response object.
|
|
46
|
-
*/
|
|
47
|
-
getResponse() {
|
|
48
|
-
if (this.res) return new Response(this.res.body, {
|
|
49
|
-
status: this.status,
|
|
50
|
-
headers: this.res.headers
|
|
51
|
-
});
|
|
52
|
-
return new Response(this.message, { status: this.status });
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
//#endregion
|
|
56
|
-
exports.HTTPException = HTTPException;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_context = require("./context.js");
|
|
3
|
-
const require_hono = require("./hono.js");
|
|
4
|
-
//#region src/index.ts
|
|
5
|
-
/**
|
|
6
|
-
* @module
|
|
7
|
-
*
|
|
8
|
-
* Hono - Web Framework built on Web Standards
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { Hono } from 'hono'
|
|
13
|
-
* const app = new Hono()
|
|
14
|
-
*
|
|
15
|
-
* app.get('/', (c) => c.text('Hono!'))
|
|
16
|
-
*
|
|
17
|
-
* export default app
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
//#endregion
|
|
21
|
-
exports.Context = require_context.Context;
|
|
22
|
-
exports.Hono = require_hono.Hono;
|