Skip to content

Releases: middleapi/orpc

v1.13.4

13 Jan 09:10

Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

v1.13.2

29 Dec 09:26

Choose a tag to compare

   🐞 Bug Fixes

  • zod: Enhance schema conversion logic for zod4 preprocess  -  by @unnoq in #1318 (fc2dc)
    View changes on GitHub

Tip

If you find oRPC valuable and would like to support its development, you can do so here.

v1.13.1

26 Dec 01:27

Choose a tag to compare

   🚀 Features

  • nest, contract: Prefer import populateContractRouterPaths from @orpc/contract  -  by @unnoq in #1312 (544b9)
    View changes on GitHub

v1.13.0

18 Dec 08:31

Choose a tag to compare

Smart Coercion now stable docs

Automatically converts input values to match schema types without manually defining coercion logic.

import { OpenAPIHandler } from '@orpc/openapi/fetch'
import { SmartCoercionPlugin } from '@orpc/json-schema'

const handler = new OpenAPIHandler(router, {
  plugins: [
    new SmartCoercionPlugin({
      schemaConverters: [
        new ZodToJsonSchemaConverter(),
        // Add other schema converters as needed
      ],
    })
  ]
})

Rethrow handler plugin docs

The RethrowHandlerPlugin allows you to catch and rethrow specific errors that occur during request handling. This is particularly useful when your framework has its own error handling mechanism (e.g., global exception filters in NestJS, error middleware in Express) and you want certain errors to be processed by that mechanism instead of being handled by the oRPC error handling flow.

import {
  experimental_RethrowHandlerPlugin as RethrowHandlerPlugin,
} from '@orpc/server/plugins'

const handler = new RPCHandler(router, {
  plugins: [
    new RethrowHandlerPlugin({
      // Decide which errors should be rethrown.
      filter: (error) => {
        // Example: Rethrow all non-ORPCError errors
        // This allows unhandled exceptions to bubble up to your framework
        return !(error instanceof ORPCError)
      },
    }),
  ],
})

.$input now available in contract builder docs

Unlike .input, the .$input method lets you redefine the input schema after its initial configuration. This is useful when you need to enforce a void input when no .input is specified.

const base = os.$input(z.void())
const base = os.$input<Schema<void, unknown>>()

   🚀 Features

   🐞 Bug Fixes

    View changes on GitHub

v1.12.3

12 Dec 15:09

Choose a tag to compare

   🐞 Bug Fixes

  • standard-server: Change SHORTABLE_ORIGIN from orpc:// to http:// for Android WebView compatibility  -  by @Copilot in #1295 (d1259)
    View changes on GitHub

v1.12.2

02 Dec 07:55

Choose a tag to compare

   🐞 Bug Fixes

  • standard-server: Filter out undefined headers for node:http adapters compatibility  -  by @unnoq in #1269 (c994d)
    View changes on GitHub

v1.12.1

01 Dec 07:56

Choose a tag to compare

   🚀 Features

    View changes on GitHub

v1.12.0

30 Nov 03:56

Choose a tag to compare

Tanstack Query Default Options docs

You can configure default options for all query/mutation utilities using experimental_defaults. These options are spread merged with user-provided options, allowing you to set defaults while still enabling customization on a per-call basis.

const orpc = createTanstackQueryUtils(client, {
  experimental_defaults: {
    planet: {
      find: {
        queryOptions: {
          staleTime: 60 * 1000, // 1 minute
          retry: 3,
        },
      },
      list: {
        infiniteOptions: {
          staleTime: 30 * 1000,
        },
      },
      create: {
        mutationOptions: {
          onSuccess: (output, input, _, ctx) => {
            ctx.client.invalidateQueries({ queryKey: orpc.planet.key() })
          },
        },
      },
    },
  },
})

// These will automatically use the default options
const query = useQuery(orpc.planet.find.queryOptions({ input: { id: 123 } }))
const mutation = useMutation(orpc.planet.create.mutationOptions())

// User-provided options override defaults
const customQuery = useQuery(orpc.planet.find.queryOptions({
  input: { id: 123 },
  staleTime: 0, // overrides the default
}))

Cloudflare Durable Object Publisher Adapter docs

Building real-time features on Cloudflare Workers has never been easier, thanks to our publisher helpers:

import { DurablePublisher, PublisherDurableObject } from '@orpc/experimental-publisher-durable-object'

export class PublisherDO extends PublisherDurableObject {
  constructor(ctx: DurableObjectState, env: Env) {
    super(ctx, env, {
      resume: {
        retentionSeconds: 60 * 2, // Retain events for 2 minutes to support resume
      },
    })
  }
}

export default {
  async fetch(request, env) {
    const publisher = new DurablePublisher<{
      'something-updated': {
        id: string
      }
    }>(env.PUBLISHER_DO, {
      prefix: 'publisher1', // avoid conflict with other keys
      customJsonSerializers: [] // optional custom serializers
    })
  },
}

Note

Full example at Cloudflare Worker Playground

NestJS Integration Upgraded docs

NestJS Integration now supports oRPC plugins, custom error responses, custom send-response behavior, and global context type-safe.

declare module '@orpc/nest' {
  /**
   * Extend oRPC global context to make it type-safe inside your handlers/middlewares
   */
  interface ORPCGlobalContext {
    request: Request
  }
}

@Module({
  imports: [
    ORPCModule.forRootAsync({ // or use .forRoot for static config
      useFactory: (request: Request) => ({
        interceptors: [
          onError((error) => {
            console.error(error)
          }),
        ],
        context: { request }, // oRPC context, accessible from middlewares, etc.
        eventIteratorKeepAliveInterval: 5000, // 5 seconds
        customJsonSerializers: [],
        plugins: [
          new SmartCoercionPlugin({
            schemaConverters: [
              new ZodToJsonSchemaConverter(),
            ],
          }),
        ], // almost oRPC plugins are compatible
      }),
      inject: [REQUEST],
    }),
  ],
  controllers: [AuthController, PlanetController, ReferenceController, OtherController],
  providers: [PlanetService, ReferenceService],
})

   🚀 Features

   🐞 Bug Fixes

  • Clone util should clone symbol properties of object  -  by @Copilot in #1258 (b4897)

Tip

If you find oRPC valuable and would like to support its development, you can do so here.

    View changes on GitHub

v1.11.3

17 Nov 08:46

Choose a tag to compare

Cloudflare Worker Ratelimit Adapter docs

Adapter for Cloudflare Workers Ratelimit.

import { CloudflareRatelimiter } from '@orpc/experimental-ratelimit/cloudflare-ratelimit'

export default {
  async fetch(request, env) {
    const limiter = new CloudflareRatelimiter(env.MY_RATE_LIMITER)

    return new Response(`Hello World!`)
  }
}

   🚀 Features

    View changes on GitHub

v1.11.2

12 Nov 07:33

Choose a tag to compare

   🚀 Features

  • standard-server: Send initial comment in event stream to flush response headers immediately  -  by @unnoq in #1204 (91ac3)

   🐞 Bug Fixes

  • tanstack-query: Set stream query to success immediately after stream resolves  -  by @unnoq in #1202 (bbe55)
    View changes on GitHub

Tip

If you find oRPC valuable and would like to support its development, you can do so here.