Skip to content

v3.0.0

Choose a tag to compare

@aleclarson aleclarson released this 22 May 20:31
· 46 commits to main since this release

Update every route map to rouzer/http.

-import { route } from 'rouzer'
+import * as http from 'rouzer/http'

-export const profileRoute = route('profiles/:id', {
-  GET: { response: $type<Profile>() },
-  PATCH: { body: updateProfileSchema, response: $type<Profile>() },
+export const profiles = http.resource('profiles/:id', {
+  get: http.get({ response: $type<Profile>() }),
+  update: http.patch({ body: updateProfileSchema, response: $type<Profile>() }),
 })
 createRouter().use(routes, {
-  profileRoute: {
-    GET(ctx) { ... },
-    PATCH(ctx) { ... },
+  profiles: {
+    get(ctx) { ... },
+    update(ctx) { ... },
   },
 })
-await client.profileRoute.GET({ path: { id: '42' } })
+await client.profiles.get({ path: { id: '42' } })

Also:

  • createClient({ routes }) and createRouter().use(...) now take HTTP action/resource trees.
  • Keep route(...) only for low-level client.request(...) / client.json(...) calls.
  • ALL fallback routes and route-level OPTIONS handlers are removed.
  • @remix-run/route-pattern is upgraded to v0.21.

Docs: https://github.com/alloc/rouzer/blob/v3.0.0/docs/context.md

Compare: v2.0.1...v3.0.0