-
BREAKING CHANGE: Remove "middleware as an optional 2nd arg" from all router methods and introduced support for defining middleware inline in route handler definitions. This greatly reduces the number of overloads required in the router API and also provides a means whereby middleware may be coupled to request handler definitions
// before router.map('/', [middleware], () => { return new Response('Home') }) // after router.map('/', { use: [middleware], handler(ctx) { return new Response('Home') }, })
-
Add
routeNames
option tocreateResource
andcreateResources
for customizing the names of the resource routes. This is a map of the default route name to a custom name.let books = createResources('books', { routeNames: { index: 'list', show: 'view' }, }) books.list // Route<'GET', '/books'> books.view // Route<'GET', '/books/:id'>
-
Add
route
shorthand forcreateRoutes
to public exports -
Add support for any
BodyInit
inhtml(body)
response helper -
Add
createFormAction
(also exported asformAction
for short) for creating route maps withindex
(GET
) andaction
(POST
) routes. This is well-suited to showing a standard HTML<form>
and handling its submit action at the same URL. -
Export
RouteHandlers
andRouteHandler
types