0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 11:51:01 +01:00
Commit Graph

1139 Commits

Author SHA1 Message Date
Yusuke Wada
9fd3cd3914 chore: pretty 2023-07-07 18:02:29 +09:00
watany
c2cbc0a80b
ci: update ci action (#1222) 2023-07-07 17:48:36 +09:00
watany
edca699b96
feat(adapter): AWS Lambda Adapter supports requests via Lambda@edge (#1210)
* edge-adaptor

* add env

* Revert "add env"

This reverts commit 9662e574fd.

* Revert "add env"

This reverts commit 9662e574fd.

* v0.1

* Revert "edge-adaptor"

This reverts commit ed6b2566b1.

* runtimetest

* WIP: runtime-test

* lint

* build lambda-edge

* ci lambda-edge

* remove gitpod

* test fix

* fix of self check
2023-07-07 17:41:33 +09:00
Yusuke Wada
a8ebb47ddd
docs: add a svg logo image (#1217) 2023-07-04 18:45:55 +09:00
Pascal
b0e0ce85a0
feat: Add Server-Timing API as middleware (#1215)
* feat(timing): add Server-Timing API as middleware

* refactor(timing): rename config to TimingOptions
2023-07-03 11:19:49 +09:00
flow
d6f4d1a501
Fix replaceUrlParam to ignore regexp in path (#1214)
* Fix replaceUrlParam to ignore regexp in path

* Generate deno_dist files
2023-07-02 22:25:19 +09:00
Tom Lienard
09175e1289
fix(tests): Lagon env test (#1209) 2023-07-01 17:20:23 +09:00
Yusuke Wada
3891845458 v3.2.7 2023-06-29 20:13:56 +09:00
Yusuke Wada
8ebd8b7b76
fix(jsonT): remove overloads from JSONTRespond (#1208)
* fix(`jsonT`): remove overloads from `JSONTRespond`

* denoify

* update tests
2023-06-29 20:09:00 +09:00
ryoppippi
bae5419d54
feat: add deleteCookie (#1190)
* add deleteCookie

* fix test

* fix test

* add test for deteleCookie with third argument opt
2023-06-29 19:58:38 +09:00
Yusuke Wada
5b873fcc5c
fix(types): allow not to set skipLibCheck (#1206)
* fix(types): allow not to set `skipLibCheck`

* use `unknown`

* denoify
2023-06-29 16:48:00 +09:00
James A Rosen
ddc34e1f6a
perf(Request): optimize Request.prototype.header (#1204)
`Request.prototype.header` has two overloads:

 1. with a string name, it returns that header value if present
 2. with no argument, it returns all the headers as an object

Previously, the implementation built the whole object for (2) even when
returning a single header. This was wasteful. This commit changes it to
return the header by name if specified and only iterate over all the
headers when the caller asks for the whole object.
2023-06-29 16:27:05 +09:00
James A Rosen
f356702efc
fix(etag): support multi-value If-None-Match (#1199)
* chore(etag): reduce global state in tests

Previously, the `etag` tests used a single Hono `app` that was
instantiated statically before the tests. Having a shared app increases
the chances of inter-test conflicts and makes it impossible to modify
the app for a single test. This, in turn, makes it harder for test
maintainers to see the connection between the app configuration and the
expectations.

This commit moves the creation of the `app` into a `beforeEach` block
and moves any app configuration that relates to a single test case into
that test case.

* perf(etag): don't override ETags from upstream

Previously, the `etag` middleware would always compute an `ETag`
header based on the SHA-1 of the `Response` body. In cases where the
upstream response already includes the header, this wastefully
clones the response, reads the body into memory, and computes a hash.

This commit changes the middleware to bypass the hash computation if
the `Response` already has an ETag.

* perf(etag): 304s include only necessary headers

The spec[^1] for 304 Not Modified says,

> The server generating a 304 response MUST generate any of the
> following header fields that would have been sent in a 200 (OK)
> response to the same request:
>
>  * Content-Location, Date, ETag, and Vary
>  * Cache-Control and Expires (see [CACHING])
>
> Since the goal of a 304 response is to minimize information transfer
> when the recipient already has one or more cached representations, a
> sender SHOULD NOT generate representation metadata other than the
> above listed fields unless said metadata exists for the purpose of
> guiding cache updates (e.g., Last-Modified might be useful if the
> response does not have an ETag field).

Previously, the `etag` middleware was sending all headers from the
original response except for `content-type` (omitted by
`Context.prototype.set res`) and `content-length` (omitted by the `etag`
middleware itself).

This commit changes the middleware to include only the headers
required with the spec, upgrading it from _conditionally compliant_ to
_fully compliant_. The list is configurable as
`options.retainedHeaders`.

[^1]: https://www.rfc-editor.org/rfc/rfc9110#name-304-not-modified

* fix(etag): Support multi-value If-None-Match

The spec[^1] for `If-None-Match` says,

> If the field value is a list of entity tags, the condition is false if
> one of the listed tags matches the entity tag of the selected
> representation.

and provides these examples:

```
If-None-Match: "xyzzy"
If-None-Match: W/"xyzzy"
If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"
If-None-Match: *
```

The value `*` isn't relevant for this middleware, but the other values
are.

This commit adds support for multi-value comma-separated ETags in the
`If-None-Match` header.

[^1]: https://www.rfc-editor.org/rfc/rfc9110#name-if-none-match

* perf(etag): prefer Header.prototype.get

Previously, the `etag` middleware used `c.req.header(...)` to access the
`If-None-Match` header. This method works, but is less efficient than
accessing the value via the raw `Headers` object.

Additionally, the middleware was trying multiple case versions for the
same header, but header-lookup is case-insensitive, so it was wasting
time on requests that lacked the header altogether.

This change also makes `etag` consistent with the other middleware in
this repo (e.g. `basic-auth`, `compress`), which all use
`c.req.headers.get(...)` to access headers.
2023-06-29 16:23:26 +09:00
Yusuke Wada
5965102619
ci(bun): fix Bun version (#1205) 2023-06-27 18:14:06 +09:00
Yusuke Wada
ee5929b045
fix(tsconfig): remove skipLibCheck (#1201) 2023-06-26 17:14:40 +09:00
Yusuke Wada
4b2dfb824b
fix(utils/cookie): allow 0 to maxAge (#1196)
* fix(utils/cookie): allow 0 to maxAge

* denoify
2023-06-23 17:33:20 +09:00
Yusuke Wada
1459bc6277 v3.2.6 2023-06-22 22:40:57 +09:00
Yusuke Wada
e2b26d6074
fix(cookie): maxAge should be positive (#1194)
* Allow setting cookie's maxAge to 0.

* fix(cookie): `maxAge` should be positive

* denoify

---------

Co-authored-by: David Manouchehri <david.manouchehri@ai.moda>
2023-06-22 22:37:07 +09:00
Kelly Littlepage
387d696303
fix: application/x-www-form-urlencoded decoding (#1189)
The current logic for decoding application/x-www-form-urlencoded is
overly restrictive and misses `Content-Type` headers with a character
encoding set, i.e., application/x-www-form-urlencoded; charset=UTF-8.

This fix harmonizes the logic for handling multipart/form-data
and application/x-www-form-urlencoded in the `parseBody` method of
request objects.
2023-06-21 22:51:59 +09:00
Yusuke Wada
94812fcf2d v3.2.5 2023-06-07 21:59:42 +09:00
Yusuke Wada
5f9453b498
feat(jsx): React-like style conversion (#1159)
* feat(jsx): React-like `style` conversion

* denoify
2023-06-07 21:56:04 +09:00
IGUCHI Kanahiro
a6b0833060
fix: avoid range-error (#1168)
* fix: avoid range-error

* fix: avoid range-error

* denoify
2023-06-07 21:54:49 +09:00
Alexander Kozlov
8387b8c0f6
fix(HttpException): error message should not be the HTTP reason phrase (#1161)
* fix(HttpException): error message should not be the HTTP reason phrase

* review fixes

---------

Co-authored-by: Nasa <nasa@mail.inc>
2023-06-07 21:17:52 +09:00
IGUCHI Kanahiro
39dcab0eb2
fix: replace to use better base64-encoder (#1165) 2023-06-06 14:25:49 +09:00
Yusuke Wada
a14e65a6ca
chore(benchmark): add radix3 (#1167) 2023-06-06 14:16:26 +09:00
ayame113
81d271279c
feat: Allow context.jsonT to take interface as an argument (#1162) 2023-06-06 10:23:09 +09:00
Yusuke Wada
aaa1c6d4b9 v3.2.4 2023-06-04 09:24:03 +09:00
Taku Amano
8a1b9aa9a8
refactor: Tweaks variable names to reduce code. (#1157)
* refactor: Tweaks variable names to reduce code.

* Delete meaningless comments

* chore: denoify
2023-06-04 09:16:29 +09:00
Yusuke Wada
2d6abaff5c
fix(tire-router/pattern-router): fixed the named capture issue (#1148)
* fix(trie-router): fixed the named capture issue

* denoify

* denoify

* refactor(pattern-router): Use Object.assign for shortening the code. (#1154)

* refactor(pattern-router): Use `Object.assign` for shortening the code.

* chore: denoify

---------

Co-authored-by: Taku Amano <taku@taaas.jp>
2023-06-03 09:08:01 +09:00
Yusuke Wada
0e1755c9e4
feat: handle HEAD method (#1142)
* feat: handle HEAD method

* remove `head` from `METHOS`

* fixed the lagon test

* show `depracated` message (will be removed next minor? version)

* denoify

* use `request.url`

* denoify

* Invoke dispatch() without changing request.method for HEAD method. (#1152)

* Invoke `dispatch()` without changing request.method for HEAD method.

* chore: denoify

* refactored

* denoify

* refactor: dispatch() arguments can no longer be omitted (#1156)

* Revert "refactored"

This reverts commit 2f8dacc42d.

* refactor: `dispatch()` arguments can no longer be omitted

* denoifiy

---------

Co-authored-by: Taku Amano <taku@taaas.jp>
2023-06-03 09:07:33 +09:00
Yusuke Wada
9ef8f8528d
perf: use indexOf() intead of includes() (#1150) 2023-06-01 22:04:54 +09:00
Yusuke Wada
4263d373a6
ci: don't specify Bun version in CI (#1149) 2023-06-01 21:18:00 +09:00
Taku Amano
2ff0605382
fix(reg-exp-router): Register static paths first for duplicate checking. (#1146)
* fix(reg-exp-router): Register static paths first for duplicate checking.

* chore: denoify
2023-06-01 17:37:19 +09:00
Yudai Nakata
c09dbc060b
feat: define JSX.ElementChildrenAttribute interface (#1139)
* feat: define JSX.ElementChildrenAttribute interface

* chore: denoify
2023-05-29 22:00:27 +09:00
Yusuke Wada
ba49192f6e v3.2.3 2023-05-28 08:46:49 +09:00
Yusuke Wada
f251706e6e
fix(deno): export types for the client (#1137) 2023-05-28 08:44:50 +09:00
Dmitry Poklonskiy
2a2f73a1c4
fix: Add missing client types and TypedResponse type (#1135) 2023-05-28 08:39:36 +09:00
Yusuke Wada
b06b4d97bc v3.2.2 2023-05-24 18:06:14 +09:00
Yusuke Wada
8f5ba57d0c
fix(middleware): don't use headers.append(), use headers.set() (#1129)
* fix(middleware): don't use `c.res.headers.append()`, use `set()`

* denoify
2023-05-24 18:01:19 +09:00
Yusuke Wada
ded33157bc
fix: export PatternRouter and LinearRouter (#1128) 2023-05-24 16:05:50 +09:00
Yusuke Wada
4f8ed4201e
chore: denoify (#1124) 2023-05-22 11:40:51 +09:00
Shunsuke Suzuki
64b3e323ed
fix typo (#1123) 2023-05-22 11:19:04 +09:00
Yusuke Wada
2cfafe9642
fix(basic-auth): handle passing invalid value to atob() (#1122)
* fix(basic-auth): handle passing invalid value to `atob()`

* chore: denoify
2023-05-21 20:48:35 +09:00
Yusuke Wada
1c44c6ec46 Revert "feat(deno): export cookie middleware (#1103)"
This reverts commit 9a4af5ea00.

Fix #1120
2023-05-21 01:47:34 +09:00
Yusuke Wada
7484175c0a v3.2.1 2023-05-20 15:31:30 +09:00
Yusuke Wada
127fa30dce
fix(app): app.mount() supports / (#1119)
* fix(app): `app.mount()` supports `/`

* chore: denoify
2023-05-20 15:29:58 +09:00
Yusuke Wada
0ffd795ec6 v3.2.0 2023-05-19 14:44:11 +09:00
Yusuke Wada
ec6fa09d89
Merge pull request #1117 from honojs/next
v3.2
2023-05-19 12:13:06 +09:00
Yusuke Wada
2e6064703b
docs(readme): update (#1115)
* docs(readme): update

* denoify
2023-05-19 12:07:18 +09:00
Yusuke Wada
84f8bc6fc8
fix(router): PatternRouter supports a hostname, added tests (#1114)
* fix(router): `PatternRouter` supports a hostname, added tests

* denoify
2023-05-18 15:03:35 +09:00