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

555 Commits

Author SHA1 Message Date
Yusuke Wada
b8c92e42ed Merge branch 'main' into next 2023-03-06 20:42:43 +09:00
Yusuke Wada
fea78f29bd
docs(readme): add creator name of RegExpRouter and SmartRouter (#956)
* docs(readme): add creator name of RegExpRouter and SmartRouter

* denoify
2023-03-06 20:42:05 +09:00
Yusuke Wada
c996f2d542 denoify 2023-03-05 23:40:14 +09:00
Yusuke Wada
4fb8151663
feat(context): allow passing unknown to executionCtx.waitUntil (#957)
* feat(context): allow passing `Promise<unknown>` to `executionCtx.waitUntil`

* denoify
2023-03-05 23:37:02 +09:00
Yusuke Wada
cd1d4530a3 docs(readme): denoify
[skip ci]
2023-03-02 21:52:25 +09:00
Yusuke Wada
46c233e463
fix(client): show type error if $get() needs args (#937)
* fix(client): show type error if `$get()` needs args

* denoify
2023-03-02 21:40:53 +09:00
Yusuke Wada
b1c5059708
feat(jsonT): check JSON type (#939)
* feat(`jsonT`): check JSON type

* denoify

* use `JSONValue`

* create `TrueAndFalseToBoolean` and add a comment
2023-03-02 08:56:13 +09:00
tangye
73860a1595
fix: let the app.request behave the same as fetch (#933)
* fix: let the app.request behave the same as fetch

* fix: add deno dist files

---------

Co-authored-by: 唐烨 <tangye@xinpianchang.com>
2023-02-27 20:01:04 +09:00
Yusuke Wada
7ba91208b9
fix: add missing MergePath (#936)
* fix: add missing `MergePath`

* denoify
2023-02-27 19:10:16 +09:00
Taku Amano
b0501e03cd
feat: Improve route() (#929)
* feat: return a sub app cloning itself from route()

* feat: Add extra type parameter BasePath.

* refactor: The type of hono.basePath may simply be a string.

* refactor: first argument of route is required, default value is not required

* chore: denoify
2023-02-27 18:38:27 +09:00
Yusuke Wada
e035e289ee
feat(deno): export HonoRequest type in Deno (#927) 2023-02-25 02:48:18 +09:00
Yusuke Wada
b788fe619f
fix(validator): clone Request object if json or form (#926) 2023-02-25 02:36:11 +09:00
Yusuke Wada
b9227b890c
refactor(util): remove using Buffer from encode.ts (#925) 2023-02-25 01:53:18 +09:00
Yusuke Wada
b3868d1075
fix(types): app.route with multiple endpoints returns types correctly (#919)
* fix(types): `app.route` with multiple endpoints returns types correctly

* fix `OnHandlerInterface` patterns too.

* denoify

* fix type mismatch of Env

* remove unnecessary assert
2023-02-24 09:07:25 +09:00
hagishi
14ed9f7368
feat: allow pathname argument (#921)
* feat: allow pathname argument

* fix: add control input argument

* denoify
2023-02-23 23:41:50 +09:00
Jonas Hiltl
17755d8167
feat: Custom fetch method for Hono Client options (#920)
* Allow setting custom fetch method for hono client

* Run yarn denoify
2023-02-23 16:26:25 +09:00
Yusuke Wada
4c4bf2b85e docs(readme): add "quick start" 2023-02-23 05:49:16 +09:00
Yusuke Wada
2c5b9891bd
feat(types): keep schema info with app.route() (#909) 2023-02-20 08:56:29 +09:00
hagishi
7ffb5b547e
feat(client): Inject common headers (#908)
* feat(client): Inject common headers

* feat: Accept a RequestOptions object as argument.

* refactor: Rename RequestOption to RequestOptions

* denoify
2023-02-20 08:22:01 +09:00
Yusuke Wada
02e3786016
docs(readme): update for v3 (#902)
* docs(readme): update for v3

* denoify
2023-02-18 08:27:54 +09:00
Yusuke Wada
c98f71610a
fix(jsx): declare types for JSX correctly (#901) 2023-02-18 06:50:52 +09:00
Yusuke Wada
6d8bd62d23
chore: honojs.dev to hono.dev (#900) 2023-02-16 23:18:34 +09:00
Yusuke Wada
d4e3728881 chore: denoify 2023-02-16 18:08:50 +09:00
Yusuke Wada
79759a81ed
feat(client): introduce Fetch type (#898)
* feat(client): introduce `Fetch` type

* denoify
2023-02-16 16:12:21 +09:00
Yusuke Wada
94df5fce68 feat(hc): add InferRequestType (#894)
* feat(hc): add `InferRequestType`

* denoify
2023-02-15 08:47:40 +09:00
Yusuke Wada
05ee837f78
feat: change the arg InferResponseType receives (#893)
* feat: change the arg `InferResponseType` receives

* denoify
2023-02-15 07:05:39 +09:00
Yusuke Wada
733854f6cb
docs(readme): add bundlephobia badges (#891) 2023-02-14 22:50:58 +09:00
Yusuke Wada
68cbbbcde7
refactor: rename ValidationTypes to ValidationTargets (#890)
* refactor: rename `ValidationTypes` to `ValidationTargets`

* denoify
2023-02-14 06:21:30 +09:00
Yusuke Wada
5b29d4235e
refactor: rename to TypedResponse (#889)
* refactor: rename to `TypedResponse`

* denoify
2023-02-13 21:57:12 +09:00
Yusuke Wada
60c0903a1c
fix(req): query return type as string | undefined (#888)
* fix(req): return type as `string | undefined`

* denoify
2023-02-13 21:40:51 +09:00
Yusuke Wada
0b2ac1678e Merge branch 'main' into next 2023-02-13 06:47:05 +09:00
Alex Errant
d2abad3b34
header may return undefined (#884)
* header may return undefined

* fixed broken tests

* yarn denoify

* update CONTRIBUTING
2023-02-13 06:30:57 +09:00
Yusuke Wada
e0059916e9
fix(deno): allow {} for app.fetch fo compatibility (#887) 2023-02-12 16:46:47 +09:00
Yusuke Wada
23b05425da fix(deno): export deno adapter (#886) 2023-02-12 16:35:22 +09:00
Yusuke Wada
39e855f0a4
feat: move http-exception out of utils (#883) 2023-02-11 18:05:50 +09:00
Yusuke Wada
ff7b225620
feat(app): support multiple methods with app.on() (#882)
* feat(`app`): support multiple methods with `app.on()`

* use `flat()`

* denoify
2023-02-11 16:20:11 +09:00
Yusuke Wada
17af727d49
feat(validator): moved validator outside of middleware (#879) 2023-02-11 01:18:27 +09:00
Yusuke Wada
6f729895a7 merge main into next 2023-02-09 19:49:27 +09:00
Yusuke Wada
3f1de47f8f chore(denoify): update buffer 2023-02-09 18:24:14 +09:00
Taku Amano
c169a413bd
feat: use added app's errorHandler with comose() (#874)
* refactor(compose): Swapped the order of onNotFound and onError in the compose() argument.

* feat: use added app's errorHandler

* chore: denoify
2023-02-09 18:13:27 +09:00
Yusuke Wada
9391278911
feat(router) [breaking]: StaticRouter obsolete (#873)
Co-authored-by: Taku Amano <taku@taaas.jp>
2023-02-09 16:58:28 +09:00
Taku Amano
dfd4f81e79
feat: Remove the StaticRouter from default candidates. (#869)
* feat: Remove the StaticRouter from default candidates.

* chore: denoify
2023-02-08 23:19:02 +09:00
Yusuke Wada
229228a7ba
Revert "feat: use added app's errorHandler (#871)" (#872)
This reverts commit b8a99b5367.
2023-02-08 23:08:52 +09:00
Taku Amano
b8a99b5367
feat: use added app's errorHandler (#871)
Fix #851


* feat: use added app's errorHandler

* chore: denoify

* refactor(compose): Swapped the order of onNotFound and onError in the compose() argument.

* chore: denoify
2023-02-08 22:01:30 +09:00
Yusuke Wada
c0d2e608a6
feat: hc - Hono Client (#862) 2023-02-08 07:22:32 +09:00
Taku Amano
d86728b4d1
perf(reg-exp-router): Cache Result<T> instead of T[] if there is no parameter. (#867)
* perf(reg-exp-router): Cache Result<T> instead of T[] if there is no parameter.

* chore: denoify
2023-02-08 06:47:19 +09:00
Yusuke Wada
2828e59a6c Merge branch 'main' into next 2023-02-06 07:09:03 +09:00
Yusuke Wada
1a4c2fed78
chore: denoify (#865) 2023-02-06 07:01:51 +09:00
Yusuke Wada
41ba3a2193 Revert "perf(context): improve handling response (#860)"
This reverts commit ce0a8bd16d.
2023-02-05 02:53:10 +09:00
Yusuke Wada
dd4122a5e0
refactor: obsolute CustomHandler (#861) 2023-02-03 05:56:59 +09:00
Yusuke Wada
ce0a8bd16d
perf(context): improve handling response (#860) 2023-02-02 08:08:07 +09:00
Yusuke Wada
a4800bf941
fix(req): never if c.req.valid() (#859) 2023-02-02 08:06:19 +09:00
Yusuke Wada
aefe3869d0 chore: denoify 2023-02-02 00:25:58 +09:00
Yusuke Wada
fbf8959b74
fix(breaking): obsolete no args c.req.valid() (#856)
* v3.0.0-rc.9

* fix(breaking): obsolete no args `c.req.valid()`

* more strict
2023-02-01 22:02:09 +09:00
Yusuke Wada
e2b269acb0
feat: rewnew output types (#853)
* feat: rewnew output types

* denoify

* refactor: move type definitions of middlware handler to `types.ts`

* format comment block

* add more tests
2023-02-01 06:36:48 +09:00
Jayden
53de4a4021
Rename runtime keys (#850)
* Rename runtime keys

* denoify

* Fix test
2023-01-29 14:47:35 +09:00
Taku Amano
01b9fd4537
feat(reg-exp-router): Lookup static path by using Object (#845)
* feat(reg-exp-router): Search by key of Object if `path` has no variables.

* feat(reg-exp-router): Returns an empty RegExp if node is not added.

* feat(reg-exp-router): Check ambiguous path for static.

* chore: fix typo in test case

* chore: denoify
2023-01-29 13:55:27 +09:00
Yusuke Wada
0c76049487 Merge branch 'main' into next 2023-01-24 09:00:29 +09:00
Yusuke Wada
4f9d7f2d7e
fix(context): fixed bug raw Response content-type is overwritten (#836) 2023-01-24 08:53:31 +09:00
Yusuke Wada
a53ae499d3 Merge branch 'main' into next 2023-01-23 08:40:17 +09:00
Yusuke Wada
033f23189c
fix(context): set the values of already set (#834) 2023-01-23 08:35:14 +09:00
Yusuke Wada
2afa06a5ba
feat(req): support c.req.valid('query') (#832) 2023-01-23 07:47:29 +09:00
Yusuke Wada
2de2ef3279
feat(validator): support multiple handlers w/ complex patterns. (#831) 2023-01-22 21:21:37 +09:00
Yusuke Wada
2ee0f739f5
fix(bun): fixed throwing the error in HTTPException (#830) 2023-01-22 15:06:55 +09:00
Yusuke Wada
698a783573 Merge branch 'main' into next 2023-01-22 14:28:13 +09:00
Yusuke Wada
e404319824
perf: use substring and //.test ... (#829)
* v3.0.0-rc.8

* perf: use `substring` and `//.test` ...
2023-01-22 13:59:31 +09:00
Yusuke Wada
a60e46ae53
fix(request): make optional param type correct (#826)
* fix(request): make optional param type correct

* `ts-ignore`

* `denoify`
2023-01-22 13:32:33 +09:00
Yusuke Wada
fd4f18f6cc chore: denoify 2023-01-19 22:45:25 +09:00
Yusuke Wada
49ffd51153 refactor(utils): remove minor mime types (#816) 2023-01-19 22:45:25 +09:00
Yusuke Wada
9958019d13 refactor: remove the json util not needed (#815) 2023-01-19 22:45:25 +09:00
Yusuke Wada
b6b1e5bc79 fix(context): enable destruction such json (#813)
This will fix #812
2023-01-19 22:45:25 +09:00
Yusuke Wada
eb6f1fdb0d perf: optimize parsing queries and headers / 19% faster than 2.7.2 (#811) 2023-01-19 22:45:25 +09:00
Yusuke Wada
7beb64956c feat: [BREAKING] introduce adapters (#807)
* feat: [BREAKING] introduce adapters

* added Next.js adapter

* denoify
2023-01-19 22:45:25 +09:00
Yusuke Wada
733f05c21c refactor(types): more robust and flexible (#806)
* chore: denoify

* v3.0.0-rc.5

* refactor(types): more robust and flexible

* fixed some
2023-01-19 22:45:25 +09:00
Yusuke Wada
d00a47ef70 feat: introduce HTTPException (#796)
* feat: introduce `HTTPException`

* denoify and fixed tests for Lagon
2023-01-19 22:45:25 +09:00
Yusuke Wada
e989a93d01 refactor: tweak types (#795) 2023-01-19 22:45:25 +09:00
Yusuke Wada
d2dd42b35e fix: fixed bugs handling TypeResponse (#791) 2023-01-19 22:45:25 +09:00
Taku Amano
9bc52a5ddd feat(reg-exp-router): regexp support path including slashes. (#789)
* feat(reg-exp-router): `regexp` support path including slashes.

* chore: denoify
2023-01-19 22:45:25 +09:00
Yusuke Wada
b723faa81f feat(trie-router): regexp support path including slashes (#768)
* feat(trie-router): `regexp` support path including slashes

* refactor(trie-router): Use `splitRoutingPath`. (#781)

* refactor(utils): splitRoutingPath, allow `@` to be safely used in parameter names. (#790)

Co-authored-by: Taku Amano <taku@taaas.jp>
2023-01-19 22:45:25 +09:00
Yusuke Wada
548487aa53 chore: denoify 2023-01-19 22:45:25 +09:00
Yusuke Wada
a50efe4fa9 perf(context): tune up handling headers 3% faster (#778)
* perf(context): tune up handling headers ~ 3% faster

* uppercase

* denoify
2023-01-19 22:44:38 +09:00
Yusuke Wada
b49e557e5b refactor(types): shorten name, make it safer (#774)
* refactor(types): shorten name, make it safer

* remove not used
2023-01-19 22:44:38 +09:00
Yusuke Wada
6bee574ca3 refactor(validator): show type error if get/head with form/json (#772) 2023-01-19 22:44:38 +09:00
Yusuke Wada
b567a574d6 refactor: form body should be Record<string, string | File> (#771)
* refactor: form body should be `Record<string, string | File>`

* refactored
2023-01-19 22:44:38 +09:00
Yusuke Wada
4422a0929c fix(validator): return message when Malformed JSON request body (#770) 2023-01-19 22:44:37 +09:00
Yusuke Wada
34514bc560 refactor(types): fix exporting and refactor (#767) 2023-01-19 22:44:37 +09:00
Yusuke Wada
e52e9ab463 fix(types): specify values of ValidationTypes (#766)
* fix(types): specify values of `ValidationTypes`

* export `ValidationTypes`
2023-01-19 22:44:37 +09:00
Yusuke Wada
6c55b629ec fix(types): fixed type structure (#764) 2023-01-19 22:44:37 +09:00
Yusuke Wada
d8abec9291 fix(jsonT): undefined if it is not object (#758)
* v3.0.0-0

* fix(jsonT): `undefined` if it is not object
2023-01-19 22:44:37 +09:00
Yusuke Wada
397c12e181 refactor: refactor and fix Types (#748)
* wip

* refactor: refactor and fix Types
2023-01-19 22:44:34 +09:00
Yusuke Wada
85e3c6a275 feat: new validator middleware using 3rd-party & current middleware obsolete (#745)
* feat: introduce HonoRequest with "wrapper pattern" (#733)

* feat: HonoRequest

* avoid `awaits`

* use `raw` instead of `original`

* feat: types for "RPC" support & build-in validator obsolete

* feat: introduce HonoRequest with "wrapper pattern" (#733)

* feat: HonoRequest

* avoid `awaits`

* use `raw` instead of `original`

* create generic middleare for 3rd-party validator

* indent

* support multiple validators and refactor

* remove unsed lines

* denoify
2023-01-19 22:40:13 +09:00
Yusuke Wada
a6d54dbff3 feat: introduce HonoRequest with "wrapper pattern" (#733)
* feat: HonoRequest

* avoid `awaits`

* use `raw` instead of `original`
2023-01-19 22:40:13 +09:00
Yusuke Wada
3e0f5dae31
fix: fixed type error for optional parameters (#814) 2023-01-18 09:25:37 +09:00
Yusuke Wada
da0a7ce55c
fix(context): enable destruction such json (#813)
This will fix #812
2023-01-18 08:23:58 +09:00
Yusuke Wada
4298f8266a
fix(cors): fix bugs handling pre-flight (#792) 2023-01-09 00:30:53 +09:00
Yusuke Wada
c6969533a7
chore: update license, contributors as the copyright holders (#769) 2023-01-02 19:18:59 +09:00
Yusuke Wada
90de083e1d chore: denoify 2022-12-30 10:01:46 +09:00
Tom Lienard
884b287f3d
feat: Lagon support with runtime detection & tests (#742)
* feat: Lagon support with runtime detection & tests

* ci: build before running test:lagon

* refactor: remove mentions of Lagon since it's still in dev

* test: enable ETag test
2022-12-25 01:42:59 +09:00
Yusuke Wada
4f772ddb44 docs(readme): fixed shields.io badage image url 2022-12-21 06:42:27 +09:00
Yusuke Wada
9a6e4c1802
perf(context): c.text() returns a response immediately if headers is empty (#722) 2022-12-14 22:03:02 +09:00
Yusuke Wada
d755ed50b5
fix(request): req.param() should return undefined not "undefined" (#721) 2022-12-14 01:07:07 +09:00
Yusuke Wada
c6b434addd refactor: shorten 2022-12-13 20:36:30 +09:00
Yusuke Wada
b1973d0c7f
fix(type): make SchemaToProp work correctly (#720) 2022-12-13 17:22:33 +09:00
Yusuke Wada
e6635e9997 chore: denoify 2022-12-12 22:10:14 +09:00
Yusuke Wada
fdea3b1cc6
fix(type): infer types correctly (#715) 2022-12-11 11:05:30 +09:00
Yusuke Wada
3def9b12c0
fix(type): fix the type mismatch if using Handler as middleware (#714)
* fix(type): fix the type mismatch if using `Handler` as middleware

* remove a line
2022-12-10 23:11:27 +09:00
Yusuke Wada
023d1738f0 chore: denoify 2022-12-10 17:16:04 +09:00
Yusuke Wada
59bb0b1a40
feat(handler): "schema" allow normal types (#700)
* feat(handler): "schema" allow normal types

* check types for handler+validator+handler pattern

* denoify

* improve type definitions
2022-12-10 16:37:14 +09:00
unworthyEnzyme
34231435a6
fix: cookie should return string | undefined (#709)
* `cookie` should return `string | undefined`

* update the tests
2022-12-10 01:09:18 +09:00
Yusuke Wada
a5b8b44793
fix(validator): enable checking undefined in rules (#708) 2022-12-08 21:45:54 +09:00
Taku Amano
6d5de04743
fix(reg-exp-router): bug of "star and all" routing (#707)
* fix(reg-exp-router): Comparisons between middleware must be checked in both orientations.

* refactor(reg-exp-router): Simplify the conditions.

* chore: denoify

* fix(reg-exp-router): Copy middleware if the method of new middleware is METHOD_NAME_ALL.

* chore: denoify
2022-12-08 20:11:08 +09:00
Yusuke Wada
cf73de1344
fix(trie-router): bug for routing orders with named param (#704) 2022-12-08 00:54:55 +09:00
Jayden
760ae30251
Fix detecting node runtime (#696)
* Fix

* Denoify

* Avoid error in other runtime

* chore: remove unnecessary config testPathIgnorePatterns (#697)

* Fix vercel

Co-authored-by: Horie Issei <issei.horie@is2ei.com>
2022-12-02 11:28:49 +09:00
Arnaud Dagnelies
9af95c886e
fix: Updated CORS (#693)
* Updated CORS

Do not call `next` for OPTIONS pre-flight requests to avoid side effects and more sensible defaults.

* restoring default cors headers

* restoring cors default allowed methods to avoid breaking change

* Deno dist stuff
2022-12-01 00:11:06 +09:00
Dario Piotrowicz
1f43164da5
Fix Validation of optional empty/undefined arrays (#690)
* * fix(validator): allow empty and undefined optional arrays

fix the bug of empty and undefined array causing a validation fail
when those are anyways optional

resolves #677

* denonify changes
2022-11-30 19:48:43 +09:00
Taku Amano
86699c1868
fix(reg-exp-router): Copy from METHOD_NAME_ALL for new methods (#691)
* fix(reg-exp-router): Copy from METHOD_NAME_ALL for new methods

* chore: denoify

* fix(reg-exp-router): Initialize both middleware and routes.

* chore: denoify

* fix(reg-exp-router):Fix middleware search routine.

* chore: denoify
2022-11-30 10:08:28 +09:00
Dario Piotrowicz
07efdb5103
fix(validator): fix subsequent nested objects names (#683)
* fix(validator): fix subsequent nested objects names

fix the bug of having subsequent objects inside a nested structure
causing the validator to forget the previous keys in the scheme's path

fixes point 1 of #677

* deonify changes
2022-11-29 22:02:20 +09:00
Taku Amano
e9a54bb8fc
fix(reg-exp-router): Allows registering a star after a long prefix. (#684)
* fix(reg-exp-router): Allows registering a star after a long prefix.

* fix(reg-exp-router): It now works even if a short GET is registered after a long ALL.

* chore: denoify
2022-11-28 22:20:40 +09:00
Yusuke Wada
9f7b5de9aa chore: denoify 2022-11-28 08:45:57 +09:00
Yusuke Wada
8fcc9e6e3b chore: donoify 2022-11-26 15:59:50 +09:00
Yusuke Wada
a3e0eb2cc1
refactor(context): refactor context.ts (#674) 2022-11-23 18:42:24 +09:00
Yusuke Wada
1eb49b8d96
refactor: support new @cloudflare/worker-types (#673)
* refactor: support new `@cloudflare/worker-types`

* do not attach crypto to global

* denoify ignore serve-static for cloudlfare

* ignore the utility for cloudflare

* import types
2022-11-23 07:27:42 +09:00
Yusuke Wada
05f2f6eb10 fix(types): app.use return correct types
Fix #666
2022-11-19 15:49:22 +09:00
Yusuke Wada
1674bbba32 chore(denoify): update Buffer 2022-11-17 15:11:36 +09:00
Jayden
06cecbd1e2
fix(param): Decode context.param (#662)
* Decode url param

* Denoify
2022-11-14 09:10:03 +09:00
Jayden
e92dbe9558
fix(sanitizer) (#661)
* Add test for #660

* Implement sanitizeValue

* Mark sanitizeValue private
2022-11-12 20:33:18 +09:00
Yusuke Wada
d3a6f80d7c
fix(type): change the type definition of req in Context (#658) 2022-11-11 15:23:05 +09:00
Yusuke Wada
58ef70f0cf
fix(types): export ErrorHandler and NotFoundHandler (#656) 2022-11-08 07:02:54 +09:00
Yusuke Wada
b963d6e7cb
feat(app): introduce app.on(method, path, handler) (#653)
* feat(app): introduce `app.on(method, path, handler)`

* Refactoring of feat/on branche (#655)

* refactor(reg-exp-router): Use `includes` instead of `find` to check if an element is in an array.

* fix(static-router): Copy middleware from METHOD_NAME_ALL for new method.

* chore: denoify

Co-authored-by: Taku Amano <taku@taaas.jp>
2022-11-08 03:17:34 +09:00
Yusuke Wada
15a5119bac
feat(app): introduce app.showRoutes() (#650) 2022-11-05 19:04:01 +09:00
Yusuke Wada
edfb31ee94
fix(error): make notFound() enables to catch errors correctly (#652) 2022-11-05 19:02:19 +09:00
Yusuke Wada
888e04ded1
fix(context): check cloudflare before checking node in c.runtime (#651)
* fix(context): check cloudflare before checking node in `c.runtime`

* denoify
2022-11-04 07:14:57 +09:00
Yusuke Wada
4a9cd272f8
refactor(types): reduce type definitions (#649)
* refactor(types): reduce type definitions

* fixed tests for Deno and Bun
2022-11-03 15:53:41 +09:00
Yusuke Wada
8e9b1c8099
fix(type): make compatibility with @cloudflare/workers-types (#645) 2022-11-03 15:39:25 +09:00
Jayden
451d6fe117
feat(context): Introducing c.runtime (#644)
* Add context.platform getter

* Remove assumption on fastly

* Add Vercel support

* denoify

* Replace .platform with .runtime
2022-11-03 15:35:23 +09:00
Yusuke Wada
c3031a418c
fix(jsx): export fragment (#642) 2022-11-01 21:41:27 +09:00
Yusuke Wada
da55bf922f chore: denoify 2022-11-01 17:42:25 +09:00
Yusuke Wada
c14dd5ad43
feat(validator): support v.queries (#636) 2022-11-01 14:22:04 +09:00
Yusuke Wada
6a96ace96a
feat(types): introduce CustomHandler interface (#637) 2022-11-01 00:07:56 +09:00
Yusuke Wada
7b8a25126f
fix(validator): enable handling "Bad Request" in validator (#635) 2022-11-01 00:03:17 +09:00
Yusuke Wada
ca52dd898e
fix(build): fix ESM support in Node.js / use esbuild (#631)
* fix(build): fix ESM support in Node.js / use `esbuild`

* add tsx

* denoify ignore
2022-10-28 08:46:02 +09:00
Yusuke Wada
d7a36b34fd
feat(validator): export Validator from 'hono' (#627) 2022-10-24 23:59:46 +09:00
Yusuke Wada
5b3e7f8fd7
fix(deno): export static-router and smart-router (#626) 2022-10-24 23:22:05 +09:00
Yusuke Wada
b4d58eca64
test(validator): add test for custom rules (#620)
* test(validator): add test for custom rules

* fixed value
2022-10-23 10:11:18 +09:00
Yusuke Wada
8627010094
refactor(types): refactor and add tests for checking Types (#615)
* refactor(types): refactor and add tests for checking Types

* remove unused

* uncomment

* use `Handler` in validator middleware

* remove unused

* create `src/validator` dir and move some files into it

* add the case that the context is in `validator`

* rename `D` to `S`
2022-10-23 08:10:00 +09:00
Yusuke Wada
c19028374d
fix(validator): make "isOptional" work correctly with "value" validation (#613) 2022-10-20 16:19:13 +09:00
Yusuke Wada
7981b100de
fix(validator): show "type" error messages if does not have "value" errors (#612) 2022-10-20 15:46:04 +09:00
Yusuke Wada
944dfc2e13
refactor(jwt): refactor code and add more tests (#611) 2022-10-19 20:24:43 +09:00
Yusuke Wada
33f1cbd604 chore: denoify 2022-10-19 20:01:43 +09:00
Yusuke Wada
0da78351e9
feat(validator): has the error message per rule (#603)
* feat(validator): has the error message per rule

* add test for checking result objects

* test(validator): add array results test (#609)

* remove `console.log`

Co-authored-by: Derrick Farris <mr.dcfarris@gmail.com>
2022-10-19 19:17:04 +09:00
Yusuke Wada
2776957bba
feat(validator): introduce nested validation (#592)
* feat(validator): introduce `v.array()` and `v.object` for nested validation

* copy objects

* remove unnecessary tests

* fix(object): make merge immutable to fix issues with missing fields (#598)

Co-authored-by: Derrick Farris <mr.dcfarris@gmail.com>
2022-10-13 06:48:59 +09:00
Yusuke Wada
c5672a6161
perf(serve-static): return immediately if c.finalized (#596) 2022-10-10 00:29:40 +09:00
Yusuke Wada
90da196193
fix(deno): fixed the bug calling next() multiple time in Serve Static (#594) 2022-10-10 00:11:36 +09:00
Yusuke Wada
f5fc9103f1 chore: denoify 2022-10-09 23:33:00 +09:00
Yusuke Wada
41245122b9
fix(compose): fix it for error handling with async (#583) 2022-10-04 09:01:31 +09:00
Derrick Farris
1adc9264fc
fix(validator): return HTTP 400 on malformed JSON request (#579)
* fix(validator): return http 400 on malformed JSON request

* chore(deno): denoify malformed json changes
2022-10-04 06:16:25 +09:00
Taku Amano
e992c7b7f3
fix(reg-exp-router): Register path for all the methods if method === METHOD_NAME_ALL. (#580)
* fix(reg-exp-router): Register path for all the methods if method === METHOD_NAME_ALL.

* chore: denoify.
2022-10-03 07:50:57 +09:00
Yusuke Wada
39f896a576
fix(compose): don't throw Error; set error response into c.res (#576) 2022-10-02 15:44:54 +09:00
Derrick Farris
61e24b03a1
fix(cache): export cache middleware for Deno (#573)
* fix(cache): export cache middleware for Deno

* fix(test): update  jwt test (test will be fail in 46 years)
2022-10-01 17:23:44 +09:00
Nicholas Gates
af1de3574c
Fix Trie router multiple matching path parameters (#571)
* Failing test for prefix parameters

* Fix test by removing break

* Denoify
2022-09-30 22:25:24 +09:00
Derrick Farris
9a0389e723
feat(validator): add support for JSON array path validation (#563)
* refactor(JSONPath): improve typing of JSONPath

* chore(vscode-settings): add deno.enable=false

* fix(validator): add null to type Type def

* feat(JSON-Path): add support for array JSONPath-Plus syntax

* fix(validator): update isRequired to pass valid bool types

* test: update tests for isRequired validator

* feat(validator): add support for JSON array path validation

* chore(deno): denoify array support changes

* fix(validator): type check all vals in array

* chore(deno): denoify changes

* test(validator): add tests for array type checking

* fix(validator): change JSONPrimative to JSONPrimitive

* refactor(json): More compatible with https://jsonpath.com/.

* implementation of `asArray`

* fix(validator): update JSONPath implementation and add isArray check in validation

* fix(validator): fix typing errors on SchemaToProp

* Revert "fix(validator): fix typing errors on SchemaToProp"

This reverts commit b8ddef85d0.

* fix(validator): fix SchemaToProp error for VTypeArrays

* chore(deno): denoify

Co-authored-by: Taku Amano <taku@taaas.jp>
Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
2022-09-30 21:56:39 +09:00
Yusuke Wada
e5b0ea8d33 chore: denoify 2022-09-30 19:50:59 +09:00
Yusuke Wada
0e78a7698c
fix(handleEvent): use dispatch instead of fetch (#568) 2022-09-30 11:24:23 +09:00
Yusuke Wada
2c3db370ce chore: denoify 2022-09-27 21:43:55 +09:00
Yusuke Wada
03fc36f793
refactor(serve-static): use context/next instead of MiddlewareHandler (#559)
* fix(validator): make `isOptional` rule works correctly.

* refactor(serve-static): remove return type

* use context/next instead of MiddlewareHandler
2022-09-27 21:40:37 +09:00
Yusuke Wada
c0d88ff01c
fix(validator): make isOptional rule works correctly. (#555) 2022-09-27 18:19:50 +09:00
Yusuke Wada
84451d61e1
fix(types): enable types for c.env when using validator (#553) 2022-09-26 21:18:48 +09:00
Yusuke Wada
e4c8a6f467
perf: remove async from dispatch; will be 16% faster (#550) 2022-09-26 21:12:53 +09:00
Yusuke Wada
7bb9cc1a19
fix: don't use defaultNotFoundMessage variable (#549) 2022-09-21 23:05:26 +09:00
Taku Amano
957a5a9ac9
feat(validator): Enable verification results to be retrieved as structured data. (#547)
* feat(validator): Enable verification results to be retrieved as structured data.

* chore: denoify
2022-09-21 09:40:17 +09:00
Yusuke Wada
594f30aa35
fix(validator): make "Types" work well (#545)
* fix(validator): make "Types" work well

* fix import statement
2022-09-21 07:55:29 +09:00
Yusuke Wada
00547ea84e docs(readme): update! 2022-09-20 23:06:05 +09:00
Yusuke Wada
976b2c310e
feat: c.req.body and c.req.json accept generics (#529) 2022-09-20 22:01:03 +09:00
Yusuke Wada
5133a93925
feat: support appending values with c.header (#539) 2022-09-20 21:41:45 +09:00
Taku Amano
2a80b58161 feat(reg-exp-router): support optional parameter (#542)
* feat(reg-exp-router): support optional parameter

* chore: denoify
2022-09-20 21:26:59 +09:00
Yusuke Wada
24c17e340a feat(trie-router): support optional parameter (#540) 2022-09-20 21:26:27 +09:00
Yusuke Wada
730453aeb0
fix(redirect): don't have to make relative url to absolute one (#541)
* fix(redirect): don't have to make relative url to absolute one

* remove `isAbsoluteURL`
2022-09-20 18:56:31 +09:00
Yusuke Wada
a2cc1a01c2
feat: another idea of Validator Middleware (#535)
* feat: Another idea of validator middleware

* denoify

* set property value in constructor

* rename `option` to `options`

* add test for handling type error

* use `test` instead of `match`
2022-09-20 10:11:34 +09:00
Yusuke Wada
ac1c01df4a
fix(deno): serve static middleware returns 404 correctly (#537) 2022-09-19 12:22:55 +09:00
Taku Amano
8eb20215a5
feat(cors): Enable to check origin header by a function. (#533) 2022-09-16 20:59:27 +09:00
Taku Amano
bbb95585d4
Check in Origin header instead of Referer (#532)
* refactor(cors): Check in Origin header instead of Referer.

* refactor(utils/url): Remove unused function getDomainFromURL.

* chore: denoify
2022-09-16 07:23:31 +09:00
Yusuke Wada
df64870f54
feat(cors): allow multiple origins (#531)
* feat(validator): add `isBoolean` and `isNumber`

* feat(cors): allow multiple origins

Close #503
2022-09-16 00:19:02 +09:00
Yusuke Wada
9c9e1c2356
feat(validator): add isBoolean and isNumber (#530) 2022-09-16 00:10:37 +09:00
Yusuke Wada
b546fd6984 refactor: update buffer version on Deno 2022-09-14 08:44:42 +09:00
Yusuke Wada
62e3292460
feat(validator): add isFalsy and isNotFalsy (#523) 2022-09-14 08:30:46 +09:00
Yusuke Wada
e2d704fd4f
fix(types): add types to middleware correctly (#521) 2022-09-14 08:17:20 +09:00
Taku Amano
d12a11937b
feat: Lightweight RegExpRouter reborn (#519)
* Introduce RegExpLiteRouter.

* Replace RegExpRouter with RegExpLiteRouter.

* chore: denoify

* Remove old RegExpRouter and rename RegExpLiteRouter to RegExpRouter.

* chore: Update benchmarks/handle-event.
2022-09-14 08:01:14 +09:00
Yusuke Wada
46c6a8de5e
feat(middleware): introduce "built-in" Validator Middleware (#505)
* feat(middleware): introduce built-in Validator Middleware

* fixed type of `req.json()`

* Feat/builtin validator middleware another idea (#508)

* Enable overwriting of query/header data.

* Returns only verified data.

* rename `index.test.ts` to `middleware.test.ts`

* add `removeAdditional` option

* handling error that the JSON body is null

* tidy

* check is it string or not

* implement `isIn`

* enable validation the valies are duplicate

Co-authored-by: Taku Amano <taku@taaas.jp>
2022-09-13 07:54:06 +09:00
Taku Amano
a149dddfdc
Introduce StaticRouter and SmartRouter (#501)
* refactor(router): Export supported HTTP methods.

* refactor(router): Introduce UnsupportedPathError.

* feat(static-router): Introduce StaticRouter.

* feat(reg-exp-router): Add "allowAmbiguous" option to RegExpRouter.

* feat(smart-router):  Introduce SmartRouter.

* feat(hono): Make SmartRouter the default router.

* chore: denoify

* refactor(smart-router): routers is never undefined.

* chore: denoify

* refactor: Fix test for SmartRouter.
2022-09-12 20:49:18 +09:00
Yusuke Wada
3697e156ed
fix(middleware): support multiple middleware on bearer/basic auth middleware (#513)
Fix #509
2022-09-10 18:02:36 +09:00
Yusuke Wada
058e3113b3
fix(types): correct types for app.notFound / app.onError (#512)
Fix #511
2022-09-10 18:00:00 +09:00
Taku Amano
ab14da6af7
fix: regexp ambigous route (#499)
* refactor(reg-exp-router): Add existence check instead of "ts-ignore".

* fix(reg-exp-router): Rebuild all matchers as "hasAmbiguous" if some methods are ambiguous.

* Run `yarn denoify`.
2022-09-05 19:17:11 +09:00
Yusuke Wada
b6954815cb
perf(req): improve c.req.query performance (#498)
* perf(req): improve `c.req.query` performance

* allow fragments as query strings
2022-09-05 19:08:10 +09:00
Taku Amano
e174b70858
perf(compose): Always return a Promise without async. (#496) 2022-09-04 17:53:39 +09:00
Taku Amano
f3087c94e1
perf(compose): Remove await composed() from hono.ts. (#495) 2022-09-02 22:55:01 +09:00
Yusuke Wada
24a28942de
fix: fixed the issue logger called twice (#494)
* fix: fixed the issue logger called twice

* add handling the error and shorten code
2022-09-02 21:13:47 +09:00
Yusuke Wada
9793e6b8b7 docs(readme): update benchmark scores 2022-09-01 22:59:23 +09:00
Yusuke Wada
bb9a95471e
perf: do not compose if it has only one handler (#493) 2022-09-01 22:39:50 +09:00
Yusuke Wada
dec5651c2f chore: denoify 2022-08-31 18:01:33 +09:00
Yusuke Wada
d3ff952599
fix(compose): do not handle the error in compose (#491)
* fix(compose): do not handle the error in `compose`

* tweak
2022-08-31 17:49:01 +09:00
Yusuke Wada
c091517947
fix(context): fix type error (#489) 2022-08-28 18:16:51 +09:00
Yusuke Wada
1c3c9f1200
fix(type): fix type errors for Bindings and Variables (#488) 2022-08-27 23:57:33 +09:00
Yusuke Wada
128a59aec2
fix: make that c.req.parseBody parses only FormData (#487) 2022-08-27 11:38:48 +09:00
Yusuke Wada
20e8bacec8 chore: denoify 2022-08-27 11:01:09 +09:00
Yusuke Wada
c7ee2e7603
fix: enable passing Generics to c.req.parseBody, default is any (#481) 2022-08-25 09:25:11 +09:00
Yusuke Wada
ddfe07ecec
feat(types): enable adding Types for variables used in c.set/c.get (#478)
* feat(types): enable adding Types for variables used in `c.set`/`c.get`

* fix typo
2022-08-23 20:53:25 +09:00
Yusuke Wada
54a04c6a6f
fix(context): export ContextVariableMap correctly (#476) 2022-08-23 11:51:18 +09:00
Yusuke Wada
83a95ba895
perf(trie-router): fine tuning, 9~10% faster (#473)
* perf(trie-router): fine tuning, 9~10% faster!

* update readme
2022-08-21 10:11:53 +09:00
Yusuke Wada
d259b7a04d docs(readme): update readme for Deno 2022-08-19 07:30:48 +09:00
Taku Amano
db8619695e
fix(compose): Support a handler that non-async and returning a promise. (#469)
* fix(compose): Support a handler that non-async and returning a promise.

* Update deno_dist via `yarn denoify`.
2022-08-15 12:24:23 +09:00
Yusuke Wada
578833ea85
perf(compose): optimize await (#466)
Do not `await` if the handler is not promise.
2022-08-15 08:35:57 +09:00
Yusuke Wada
9edf43c63b
fix(context): fixed ContextVariableMap is not enabled in built code (#465) 2022-08-12 11:22:30 +09:00
Yusuke Wada
e07147a8ec
fix(context): fix header values shifting (#463) 2022-08-10 21:34:33 +09:00
Yusuke Wada
8879f241e8
refactor(mime): made .ico file's extension to image/x-icon (#462)
* refactor(mime): made `.ico` file's extension to `image/x-icon`

* fixed deno and bun tests
2022-08-09 10:51:08 +09:00
Yusuke Wada
7345b8105d
fix(ETag): fixed an error when the file size is too large. (#461)
Made `utils/crypto` supports `ReadbleStream`.

Fix #458
2022-08-09 10:35:30 +09:00
Yusuke Wada
8a9ebc1470
fix(utils/crypto): make Binary and JSON object crypto correct (#454) 2022-08-06 00:31:11 +09:00
Yusuke Wada
5838f9dccc Revert "refactor: add Json type for JSON object (#453)"
It's difficult to handle `Json`. So, it's ok to go with `object`.

This reverts commit bc736da6a5.
2022-08-05 08:10:41 +09:00
Yusuke Wada
bbe079134e Revert "fix(utils/crypto): stringify the parameter which is object in createHash (#452)"
It was necessary to support not only json but also other.

This reverts commit db17530b36.
2022-08-05 08:09:17 +09:00
Yusuke Wada
bc736da6a5
refactor: add Json type for JSON object (#453) 2022-08-05 06:41:28 +09:00
Yusuke Wada
db17530b36
fix(utils/crypto): stringify the parameter which is object in createHash (#452)
Fix #451
2022-08-04 08:51:09 +09:00
Yusuke Wada
a7ad89ccef refactor(utils/html): remove escape function (#450)
Close #445
2022-08-03 11:39:36 +09:00
Yusuke Wada
9f2a270c28
refactor(utils/html): rename Buffer to StringBuffer (#449) 2022-08-03 11:24:51 +09:00
Yusuke Wada
3c371d0d07 chore: denoify 2022-07-31 22:19:28 +09:00
Yusuke Wada
115395766e
fix(jsx/bun): do not escape children (#422)
For JSX middleware on Bun.
Fix bug that JSX `children` will force escaped.
2022-07-24 20:39:41 +09:00
Yusuke Wada
5f60a18227
feat(jsx): support jsxImportSource (#420)
* feat(jsx): support `jsxImportSource`

Support `jsxImportSource`.
You can use this option on Bun and Deno (Wrangler does not support it).
if you write tsconfig as below, JSX middleware will be enabled without `import { jsx } from 'hono/jsx'`.

```json
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxFragmentFactory": "Fragment",
    "jsxImportSource": "hono/jsx"
  }
}
```

* fix export path
2022-07-24 17:36:37 +09:00
Yusuke Wada
f6f454ed42
fix(trie-router): fix the rule for capturing named parameter (#419)
Close #418
2022-07-24 11:03:04 +09:00
Yusuke Wada
c450c56460
feat(middleware): implement Cache Middleware (#417)
* feat(middleware): implement Cache Middleware

* denoify

* do not export Cache middleware for Deno.
2022-07-23 15:02:42 +09:00
Yusuke Wada
b4a660c605 chore(deno): denoify 2022-07-18 11:56:07 +09:00
Yusuke Wada
da4d9a5491
fix(logger): specify console.log for default print fn (#401) 2022-07-18 08:17:42 +09:00
Yusuke Wada
007e145eec refactor(deno): fix a definition of FetchEvent 2022-07-17 18:36:42 +09:00
Yusuke Wada
1ee08cc5ce chore(deno): denoify 2022-07-17 18:11:09 +09:00
Yusuke Wada
2a24b98e55
refactor: remove useless async for a better performance on Bun (#397)
* fix(compress): add type for enconding name

* refactor: remove useless `async` for a better performance on Bun
2022-07-17 09:13:44 +09:00
Yusuke Wada
be548c97ed
fix(compress): add type for enconding name (#396) 2022-07-17 08:59:40 +09:00
Roman Hotsiy
c63d7ed77f
chore: fix typo in error class name (#393)
* chore: fix type in error class name

* chore: update usages in other places
2022-07-17 08:54:43 +09:00
Yusuke Wada
ecfc81ff1f chore(deno): denoify 2022-07-16 21:49:59 +09:00
Yusuke Wada
87db4fc07e docs(deno): update README 2022-07-16 17:56:06 +09:00
Yusuke Wada
230d265429 chore(deno): denoify 2022-07-16 10:26:14 +09:00
Yusuke Wada
af9f6a73d9 [BREAKING] feat: remove "graphql-server" middleware, will be obsolete (#366)
It might be *third-party middleware*.

Close #357
2022-07-15 08:40:15 +09:00
Yusuke Wada
dea9484a22 test: add tests for Deno (#365)
Close #351
2022-07-15 08:40:15 +09:00
Yusuke Wada
16adde746b refactor: denoify 2022-07-15 08:40:15 +09:00
Yusuke Wada
9a41cde632 chore: denoify 2022-07-15 08:40:15 +09:00
Yusuke Wada
0d48c9f338 feat: [WIP] new structure for support Deno and third-party middleware
[skip ci]
2022-07-15 08:40:15 +09:00
Yusuke Wada
b07486b965 chore(deno): denoify 2022-07-15 08:38:09 +09:00
Yusuke Wada
503317309b chore(deno): do not export Env 2022-07-10 18:54:37 +09:00
Yusuke Wada
3f5c725435 chore: denoify 2022-07-10 18:52:04 +09:00
Yusuke Wada
a430a1fcc8 docs: i forgot return 2022-07-08 09:23:33 +09:00
Yusuke Wada
c17742e104 docs: update readme 2022-07-08 09:22:10 +09:00
Yusuke Wada
c5b90a46df
feat(deno): export everythings from middlewares (#349) 2022-07-08 08:55:44 +09:00
Yusuke Wada
9bb662922b
refactor: use arrow func for app.fetch (#348) 2022-07-08 08:44:34 +09:00
Yusuke Wada
49025e0aad
refactor(deno): [BREAKING] obsolete app.fire() (#343) 2022-07-06 10:57:55 +09:00
Yusuke Wada
dbb3ec213b chore: update deno_dist files 2022-07-02 23:22:51 +09:00
Yusuke Wada
1cdd71f676
feat: add serve-static middlware for deno (#339)
* feat: add `serve-static` middlware for deno

* make `getFilePath` into utils

* ignore deno ts files
2022-07-02 23:20:09 +09:00
Yusuke Wada
6030c051db
chore: rm *.ts.test from deno_dist (#338) 2022-07-02 22:31:10 +09:00
Yusuke Wada
d589ef0a7b docs(readme): update readme in deno_dist 2022-07-02 18:32:01 +09:00
Yusuke Wada
d9e9e62e47
feat: support Deno! (#336) 2022-07-02 15:09:45 +09:00