Last 12 weeks · 132 commits
5 of 6 standards met
What version of Hono are you using? 4.13.1 What runtime/platform is your app running on? (with version if possible) Node.js What steps can reproduce the bug? The documentation includes examples of middleware being used with both and . But in both cases does not work as expected. with : with : What is the expected behavior? return 200 on GET /api, return 200 on GET existing file, return 404 on GET non-existent file, return 405 on POST /api, return 405 on POST existing file, or maybe 404 is also accepted in this case? return 404 on POST non-existent file. What do you see instead? with : return 405 on POST /api, return 405 on POST existing file, return 405 on POST non-existent file. with , return 405 on POST /api, return 200 on POST existing file, return 404 on POST non-existent file. Additional information I think the solution would be: modify so it returns 404 or 405 when request method is neither GET or HEAD, and document the requirement to use with rather than , (though its slightly counter-intuitive as should handle only GET,) particularly when you are using together. Alternatively, ignore wildcard path in middleware, just as route is currently ignored. This feels more generic but I don't know if this is always the expected behavior. This results in 404 on POST existing file, but I think it is at least better than 405 on POST non-existent file. { if (resourceExists(c.req.param("id")) { return c.json({}, 200); } else { return c.notFound(); } }) ``` httpの意味的には405がいう「対象のリソース」というのはそのidが指すデータがあるかどうかではなくパスそのものを指していてここまで求めてはいないのでは(POST /* に対して405で正しいのでは)という気もしてきた
What version of Hono are you using? 4.13.1 What runtime/platform is your app running on? (with version if possible) N/A (type issue) What steps can reproduce the bug? In the following code, causes a type error: In other words, I'd like have a function like that takes in a context object, but only require a subset of the variables, i.e. those provided by a specific middleware. However, when multiple middlewares each add variables to the context, it is suddenly no longer valid to pass into a function that expects a subset. What is the expected behavior? _No response_ What do you see instead? _No response_ Additional information The generic in doesn't seem to be covariant.
Description Fixes #5223: no longer serves files on non-GET/HEAD requests. When is registered with (as shown in the docs), it intercepts every method. A to an existing static file returned instead of falling through, so the middleware never got a chance to respond with . Root cause The handler (src/middleware/serve-static/index.ts) did not filter by HTTP method. It returned a for any request whose path resolved to an existing file, regardless of method. Fix Skip non-GET/HEAD requests and call so downstream middleware (e.g. ) can handle them: Testing Added 2 tests in : POST to an existing static file now falls through (404 / ), is not called. Combined with , a POST to a path with a real GET route still returns with . TDD: both new tests failed before the fix (returned ), pass after. Regression: suite (22/22) and + suites (21/21) all pass. Note on expected behavior For with , a to a static file now returns (not ) because does not register a GET route that can infer an header from. This matches the "or maybe 404 is also accepted in this case?" option in the issue. Using instead keeps the behavior, since a GET route is registered. Closes #5223
Adds missing W3C standard and experimental features to in . Added Directives Standardized Features: () () () Experimental Features: () () () () Reference W3C Permissions Policy Features: https://github.com/w3c/webappsec-permissions-policy/blob/main/features.md The author should do the following, if applicable [x] Add tests [x] Run tests [x] to format the code [x] Add TSDoc/JSDoc to document the code
What is the feature you are proposing? Hono declares as plain , losing the types generated with . Wrangler defines incoming requests as , but accessing one through requires an assertion: Could Hono preserve or parameterize this type, similar to how generated are supported? Hono 4.13.1 on Cloudflare Workers Related: #3097
Summary serialize falsy root JSON inputs (, , , and ) instead of treating them as absent keep as the signal for an omitted JSON body add regression coverage through the complete → path Impact Before this change, RPC endpoints accepting a JSON primitive silently received for these four inputs because the client omitted the body and JSON content type. This can change application behavior—for example, may fail to disable a flag, while , , or may fail to clear a setting. Object and array bodies are unaffected. Regression proof with 's truthiness condition: 4 failed (each expected primitive was received as ) with this PR: 4 passed Testing — 108 tests passed The author should do the following, if applicable [x] Add tests [x] Run tests [x] Format and lint changed files [ ] Add TSDoc/JSDoc — not applicable; no public API was added or changed
Repository: honojs/hono. Description: Web framework built on Web Standards Stars: 31653, Forks: 1215. Primary language: TypeScript. Languages: TypeScript (99.7%), JavaScript (0.2%), Shell (0%), HTML (0%). License: MIT. Homepage: https://hono.dev Topics: aws-lambda, bun, cloudflare, cloudflare-workers, deno, npm, router, typescript, web-framework. Latest release: v4.13.1 (6d ago). Open PRs: 95, open issues: 264. Last activity: 1m ago. Community health: 75%. Top contributors: yusukebe, usualoma, EdamAme-x, watany-dev, ryuapp, nakasyou, metrue, exoego, sor4chi, yasuaki640 and others.