honojs/hono
### [`v2.2.1`](https://togithub.com/honojs/hono/releases/tag/v2.2.1)
[Compare Source](https://togithub.com/honojs/hono/compare/v2.2.0...v2.2.1)
This release includes the bug fix for running it on Bun.
#### What's Changed
- fix: don't use `defaultNotFoundMessage` variable by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/549](https://togithub.com/honojs/hono/pull/549)
**Full Changelog**: https://github.com/honojs/hono/compare/v2.2.0...v2.2.1
### [`v2.2.0`](https://togithub.com/honojs/hono/releases/tag/v2.2.0)
[Compare Source](https://togithub.com/honojs/hono/compare/v2.1.4...v2.2.0)
This release includes ES Module support, innovative new features, and some bug fixes. You will like it.
#### Summary
##### Support ES Module
We have distributed only CommonJS, but now we will distribute ES Module. ES Module is used when the library is imported using the `import` keyword. ESModule may improve performance and reduces bundle size.
##### StaticRouter and SmartRouter
Now we have a really smart router.
Added a simple router named "StaticRouter" that does not support dynamic routes. Now, we have there router: "TrieRouter", "RegExpRouter", and "StaticRouter".
And we introduce "SmartRouter".
SmartRouter picks the optimal router from three routers the first time it is accessed. Users can use the fastest router without explicitly specifying a router.
```ts
// Before this release.
// If we wanted to use optimal router, we have to specify it.
const app = new Hono({ router: new RegExpRouter() })
```
```ts
// This release.
// SmartRouter selects the fastest router automatically.
const app = new Hono()
```
StaticRouter is used for having only static routes. Otherwise, RegExpRouter will be used, but it has routing that RegExpRouter does not support, TrieRouter will be used.
##### Validator Middleware
New Validator Middleware as builtin middleware. This validator is magic.
```ts
app.post(
'/posts',
validator((v) => ({
post: {
id: v.json('post.id').asNumber().isRequired(),
title: v.json('post.title').isRequired().isLength({ max: 100 }),
published: v.json('post.published').asBoolean(),
body: v.json('post.body').isOptional(),
},
})),
(c) => {
const res = c.req.valid()
const post = res.post
return c.text(`Post: ${post.id} is ${post.title}`)
}
)
```
They will have "Types"! The value validated with `asNumber()` keyword will have "Type".
Not only that.
- Easy to understand the result data because "declaring property name first".
- Easy to writing rules. `v.isLength(400)` is better than `v.isLength, 400`.
- Getting only "declared properties". Additional properties are always ignored. It's safe.
For more information: https://honojs.dev/docs/builtin-middleware/validator/
Validator Middleware was provided as third party Middleware: , it will be deprecated.
***
All changes are below:
#### What's Changed
- fix(types): correct types for `app.notFound` / `app.onError` by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/512](https://togithub.com/honojs/hono/pull/512)
- fix(middleware): support multiple middleware on bearer/basic auth middleware by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/513](https://togithub.com/honojs/hono/pull/513)
- Introduce StaticRouter and SmartRouter by [@usualoma](https://togithub.com/usualoma) in [https://github.com/honojs/hono/pull/501](https://togithub.com/honojs/hono/pull/501)
- feat(middleware): introduce "built-in" Validator Middleware by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/505](https://togithub.com/honojs/hono/pull/505)
- Lightweight RegExpRouter reborn by [@usualoma](https://togithub.com/usualoma) in [https://github.com/honojs/hono/pull/519](https://togithub.com/honojs/hono/pull/519)
- fix(types): add types to middleware correctly by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/521](https://togithub.com/honojs/hono/pull/521)
- feat(validator): add `isFalsy` and `isNotFalsy` by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/523](https://togithub.com/honojs/hono/pull/523)
- docs(readme): update discord invite url by [@OnurGvnc](https://togithub.com/OnurGvnc) in [https://github.com/honojs/hono/pull/527](https://togithub.com/honojs/hono/pull/527)
- feat: support ES modules!! by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/526](https://togithub.com/honojs/hono/pull/526)
- feat(validator): add `isBoolean` and `isNumber` by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/530](https://togithub.com/honojs/hono/pull/530)
- feat(cors): allow multiple origins by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/531](https://togithub.com/honojs/hono/pull/531)
- Check in Origin header instead of Referer by [@usualoma](https://togithub.com/usualoma) in [https://github.com/honojs/hono/pull/532](https://togithub.com/honojs/hono/pull/532)
- feat(cors): Enable to check origin header by a function. by [@usualoma](https://togithub.com/usualoma) in [https://github.com/honojs/hono/pull/533](https://togithub.com/honojs/hono/pull/533)
- fix(deno): serve static middleware returns 404 correctly by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/537](https://togithub.com/honojs/hono/pull/537)
- fix(bun): serve static middleware returns 404 correctly by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/538](https://togithub.com/honojs/hono/pull/538)
- feat: another idea of Validator Middleware by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/535](https://togithub.com/honojs/hono/pull/535)
- fix(redirect): don't have to make relative url to absolute one by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/541](https://togithub.com/honojs/hono/pull/541)
- feat: support appending values with `c.header` by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/539](https://togithub.com/honojs/hono/pull/539)
- feat: `c.req.body` and `c.req.json` accept generics by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/529](https://togithub.com/honojs/hono/pull/529)
- fix(validator): make "Types" work well by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/545](https://togithub.com/honojs/hono/pull/545)
- feat(validator): Enable verification results to be retrieved as structured data. by [@usualoma](https://togithub.com/usualoma) in [https://github.com/honojs/hono/pull/547](https://togithub.com/honojs/hono/pull/547)
#### New Contributors
- [@OnurGvnc](https://togithub.com/OnurGvnc) made their first contribution in [https://github.com/honojs/hono/pull/527](https://togithub.com/honojs/hono/pull/527)
**Full Changelog**: https://github.com/honojs/hono/compare/v2.1.4...v2.2.0
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, click this checkbox.
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
2.1.4
->2.2.1
Release Notes
honojs/hono
### [`v2.2.1`](https://togithub.com/honojs/hono/releases/tag/v2.2.1) [Compare Source](https://togithub.com/honojs/hono/compare/v2.2.0...v2.2.1) This release includes the bug fix for running it on Bun. #### What's Changed - fix: don't use `defaultNotFoundMessage` variable by [@yusukebe](https://togithub.com/yusukebe) in [https://github.com/honojs/hono/pull/549](https://togithub.com/honojs/hono/pull/549) **Full Changelog**: https://github.com/honojs/hono/compare/v2.2.0...v2.2.1 ### [`v2.2.0`](https://togithub.com/honojs/hono/releases/tag/v2.2.0) [Compare Source](https://togithub.com/honojs/hono/compare/v2.1.4...v2.2.0) This release includes ES Module support, innovative new features, and some bug fixes. You will like it. #### Summary ##### Support ES Module We have distributed only CommonJS, but now we will distribute ES Module. ES Module is used when the library is imported using the `import` keyword. ESModule may improve performance and reduces bundle size. ##### StaticRouter and SmartRouter Now we have a really smart router. Added a simple router named "StaticRouter" that does not support dynamic routes. Now, we have there router: "TrieRouter", "RegExpRouter", and "StaticRouter". And we introduce "SmartRouter". SmartRouter picks the optimal router from three routers the first time it is accessed. Users can use the fastest router without explicitly specifying a router. ```ts // Before this release. // If we wanted to use optimal router, we have to specify it. const app = new Hono({ router: new RegExpRouter() }) ``` ```ts // This release. // SmartRouter selects the fastest router automatically. const app = new Hono() ``` StaticRouter is used for having only static routes. Otherwise, RegExpRouter will be used, but it has routing that RegExpRouter does not support, TrieRouter will be used. ##### Validator Middleware New Validator Middleware as builtin middleware. This validator is magic. ```ts app.post( '/posts', validator((v) => ({ post: { id: v.json('post.id').asNumber().isRequired(), title: v.json('post.title').isRequired().isLength({ max: 100 }), published: v.json('post.published').asBoolean(), body: v.json('post.body').isOptional(), }, })), (c) => { const res = c.req.valid() const post = res.post return c.text(`Post: ${post.id} is ${post.title}`) } ) ``` They will have "Types"! The value validated with `asNumber()` keyword will have "Type". Not only that. - Easy to understand the result data because "declaring property name first". - Easy to writing rules. `v.isLength(400)` is better than `v.isLength, 400`. - Getting only "declared properties". Additional properties are always ignored. It's safe. For more information: https://honojs.dev/docs/builtin-middleware/validator/ Validator Middleware was provided as third party Middleware:Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.