npm @trpc/server 9.0.0

latest releases: 11.0.0-rc.638, 11.0.0-rc.637, 11.0.0-rc.633...
3 years ago
  • next(): method in server-side middlewares - see docs
  • responseMeta(): Better support for custom HTTP headers & status code - see caching docs
  • Server-side errors in @trpc/next are now serialized

Upgrade guide for the 99% usecase

  1. npx npm-check-updates --filter /@trpc/ -u && yarn
  2. Simply update any .middleware() and add return next() at the end. See middleware docs

Breaking changes

  • Middlewares will now have to call a next() function that you have to call.
  • Reduce TRPCErrors - METHOD_NOT_FOUND removed & PATH_NOT_FOUND renamed to NOT_FOUND (#733)
  • Align input and output serialization (#746)
  • Remove deprecated httpErrors-helper
  • Remove support for ?input to be an array - now assuming a Record<number, unknown>-style dict (changed with backward compat in #669)
  • Remove support for POST calls being { input: x } (originally from #671)
  • Refactored some internals and removed some unnecessary exports on adapters - minor breaking changes if someone relied on something they shouldn't have :)
  • Stricter ErrorFormatter - data has to be a Record<string, unknown>

Minor changes

  • Expose httpStatus as part of error object as the default error shape
  • httpStatus will be used to determine the actual HTTP Status code set
  • Expose TRPCClientError.data as a shortcut to error.shape.data as that's the only one I find myself using
  • TRPCError we infer in @trpc/react is now TRPCErrorLike and is serialized for SSR in @trpc/next
  • add new method responseMeta() that is triggered before a request ends - both as part of @trpc/next & @trpc/server
    • on @trpc/server receives type, paths, errors, and the unserialized data[] that is going out
    • on @trpc/next it client errors

Thanks to @mmkal, @peterp, @anthonyshort, & @simonedelmann for your feedback!

Don't miss a new server release

NewReleases is sending notifications on new releases.