Releases: honojs/hono
v1.4.5
v1.4.4
v1.4.3
Summary
This release includes performance things. Hono is really really fast! And bug fixes for JWT middleware.
Thanks a lot, @usualoma and @metrue !
What's Changed
- perf(conmpose): remove
bind
by @yusukebe in #283 - perf(util): cache regex result for URL path(s) by @yusukebe in #284
- chore(tsconfig): update
es2017
toes2020
by @yusukebe in #285 - minor typo fixes in readme by @nelsonjchen in #286
- chore(benchmark): polyfill
Request
andResponse
by @yusukebe in #287 - perf: Various performance tuning by @usualoma in #292
- perf(util): use indexOf instead of RegExp.match for extracting URL. by @usualoma in #293
- fix(token): correct 'WWW-Authenticate' header in response by @metrue in #294
- fix(test): upgrade the miniflare to consume the fix on node18 by @metrue in #295
New Contributors
- @nelsonjchen made their first contribution in #286
Full Changelog: v1.4.2...v1.4.3
v1.4.2
v1.4.1
Priority of *
is changed
You can write the fallback scenario.
app.get('/page', (c) => c.text('page'))
app.all('*', (c) => c.text('fallback'))
GET /page ---> `page`
GET /foo ---> `fallback`
If /
is matched on the top, the middleware will not be dispatched.
app.get('/', (c) => {
return c.text('foo')
}) // <--- stop process
app.use('*', middleware()) // <--- not dispached!!
If you want to apply middleware in all condition, put it above.
app.use('*', middleware()) // <--- dispached!!
app.get('/', (c) => {
return c.text('foo')
})
What's Changed
- refactor(trie-router): make
*
and/*
have same priority by @yusukebe in #274 - refactor(trie-router): fixed routing priority for
*
by @yusukebe in #276 - refactor(reg-exp-router): Update scoring rules in RegExpRouter. by @usualoma in #275
- refactor: make GraphQL Server middleware as handler by @yusukebe in #277
Full Changelog: v1.4.0...v1.4.1
v1.4.0
BREAKING CHANGES!!
This release includes some breaking changes.
Only one handler will be processed
Before this release, it is possible multiple handlers will be dispatched.
app.get('/a', async c => {
console.log('a')
return c.text('a')
});
app.get('/:slug', async c => {
console.log('slug')
return c.text('slug')
})
Output is a, slug
.
But from this release, only one handler will be dispatched.
app.get('/book/a', (c) => c.text('a')) // a
app.get('/book/:slug', (c) => c.text('common')) // common
GET /book/a ---> `a` // common will not be dispatched
GET /book/b ---> `common` // a will not be dispatched
Stop proceeding when the handler is dispatched
If you write middleware like these, please rewrite routing.
app.get('/api', (c) => {
return c.text('foo')
}) // <--- stop process
app.use('/api/*', middleware()) // <--- not dispached!!
Rewrite to
app.use('/api/*', middleware()) // <--- dispached!!
app.get('/api', (c) => {
return c.text('foo')
})
Routing Priority
Routing priority is fixed. Decided by the order of registration.
app.get('/api/*', 'c') // score 1.1 <--- `/*` is special wildcard
app.get('/api/:type/:id', 'd') // score 3.2
app.get('/api/posts/:id', 'e') // score 3.3
app.get('/api/posts/123', 'f') // score 3.4
app.get('/*/*/:id', 'g') // score 3.5
app.get('/api/posts/*/comment', 'h') // score 4.6 - not match
app.get('*', 'a') // score 0.7
app.get('*', 'b') // score 0.8
GET /api/posts/123
---> will match => c, d, e, f, b, a, b
---> sort by score => a, b, c, d, e, f, g
router
option
routerClass
option is obsolete. Use router
option instead.
import { RegExpRouter } from 'hono/router/reg-exp-router'
const app = new Hono({ router: new RegExpRouter() })
What's Changed
- fix(context): initialize status and header values after
newResponse
by @yusukebe in #261 - fix(jwt): ensure the request does not continue if the jwt token is invalid or expired by @cdrx in #266
- feat: adoption of a new sort order for routing in RegExpRouter by @usualoma in #267
- feat(trie-router) : Routing with order specification by @yusukebe in #269
- fix(router): fixed trie-router bugs by @yusukebe in #271
- refactor(router): Make Router an interface, not a class by @usualoma in #268
- feat:
c.res
is available before dispatching by @yusukebe in #272
New Contributors
Full Changelog: v1.3.6...v1.4.0
v1.3.6
What's Changed
- refactor(context):
c.res
is not optional by @yusukebe in #255 - perf: do not set
statusText
by default by @yusukebe in #256 - fix(compose): fix a bug for colliding async routes by @yusukebe in #259
- feat: multiple query values
c.req.queries
by @yusukebe in #260
Full Changelog: v1.3.5...v1.3.6