Skip to content

Releases: honojs/hono

v1.4.5

07 Jun 01:27
Compare
Choose a tag to compare

Summary

Includes two features!

  • Bearer Auth middleware
  • Friendly error message

What's Changed

  • feat(middleware): add bearer auth middleware by @yusukebe in #299
  • feat: throw error if context is not finalized by @yusukebe in #301

Full Changelog: v1.4.4...v1.4.5

v1.4.4

04 Jun 11:13
Compare
Choose a tag to compare

Summary

A few bug fixes.

What's Changed

  • fix(status): make the status 401 for the invalid authorization info by @metrue in #296
  • fix: Import "declare global" for the Request interface explicitly. by @usualoma in #298

Full Changelog: v1.4.3...v1.4.4

v1.4.3

02 Jun 06:29
Compare
Choose a tag to compare

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 to es2020 by @yusukebe in #285
  • minor typo fixes in readme by @nelsonjchen in #286
  • chore(benchmark): polyfill Request and Response 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

Full Changelog: v1.4.2...v1.4.3

v1.4.2

28 May 04:02
Compare
Choose a tag to compare

What's Changed

  • refactor(TypeScript): enable strict null check by @yusukebe in #280
  • perf(context): add HonoResponse for better performance by @yusukebe in #281

Full Changelog: v1.4.1...v1.4.2

v1.4.1

26 May 08:43
Compare
Choose a tag to compare

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

26 May 01:25
Compare
Choose a tag to compare

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

  • @cdrx made their first contribution in #266

Full Changelog: v1.3.6...v1.4.0

v1.3.6

21 May 23:07
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.3.5...v1.3.6

v1.3.5

20 May 08:46
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.3.4...v1.3.5

v1.3.4

19 May 05:45
Compare
Choose a tag to compare

What's Changed

  • feat: serve-static middleware supports Module Worker mode by @yusukebe in #250
  • feat: mustache middleware supports Module Worker mode by @yusukebe in #252

Full Changelog: v1.3.3...v1.3.4

v1.3.3

18 May 00:49
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.3.2...v1.3.3