Skip to content

Simplify named middleware reference logic

Pre-release
Pre-release
Compare
Choose a tag to compare
@thetutlage thetutlage released this 12 Dec 03:28

Instead of informing the router about the named middleware, we add support to make named middleware self contained functions that can be applied on the routes. For example.

export const middleware = router.named({
  auth: () => import('#middleware/auth')
})

Then, import the middleware collection inside the routes file.

import { middleware } from '#start/kernel'

router
 .get('/', () => {})
 .use(middleware.auth())

Commits

  • chore: update dependencies 2206609
  • feat: add synchronous hooks to HTTP server 95d706e
  • feat: add route.use and routeGroup.use alaises 0d5f667
  • fix: benchmarks code to use new middleware syntax a8d8138
  • feat: share container resolved with the HTTP context 344add7
  • chore: add application as a peer dependency 51a3d64
  • refactor: cleanup how named middleware are created and used bbf4467
  • chore: update dependencies 16a6d65

Full Changelog: v6.0.2-0...v6.1.0-0