github unnoq/orpc v0.30.0

latest releases: v1.8.7, v1.8.6, v1.8.5...
7 months ago

🌟 Improvement 🌟

  • Implement .errors in every builder, allowing you to define error handling at a global or granular level for enhanced reusability and flexibility.
  • Middleware use before .input/.output will be execute before/after validation step
const pub = os.errors({
  UNAUTHORIZED: {},
}).use(({ errors }) => {
  throw errors.UNAUTHORIZED()
})

const getting = pub
  .input(z.object({ id: z.string() }))
  .errors({
    NOT_FOUND: {
      message: 'User not found',
    },
  })
  .handler(({ errors }) => {
    throw errors.NOT_FOUND()
    throw errors.UNAUTHORIZED()
    // ...
  })

   🚨 Breaking Changes

  • server: Middleware can run both before/after validation step  -  by @unnoq in #83 (cba52)

   🚀 Features

    View changes on GitHub

Don't miss a new orpc release

NewReleases is sending notifications on new releases.