🚨 Breaking Changes 🚨
.func
is now.handler
to better convey its purpose and functionality.
🚀 New Features 🚀
1. successStatus
for Routes
You can now use the successStatus
option in .route
to override the default success status in OpenAPI specifications.
2. Enhanced ORPCLink with Custom Methods
ORPCLink now supports defining custom methods, making the Client context
more powerful and flexible.
type ClientContext = { cache?: RequestCache } | undefined;
// If `ClientContext` is not `undefinable`, it will enforce providing `context` in every call.
const orpcLink = new ORPCLink<ClientContext>({
url: 'http://localhost:3000/api',
// Optional headers for additional configurations
headers: () => ({
Authorization: 'Bearer token',
}),
fetch: (input, init, context) =>
globalThis.fetch(input, {
...init,
cache: context?.cache,
}),
method: (path, input, context) => {
// Automatically switch between GET and POST based on input and context
if (context?.cache) {
return 'GET';
}
// Example: Use GET for paths ending with 'get', 'find', 'list', or 'search'
if (['get', 'find', 'list', 'search'].includes(path.at(-1)!)) {
return 'GET';
}
return 'POST';
},
});
const client = createORPCClient<typeof router, ClientContext>(orpcLink);
// Example call with `context` specifying cache
client.getting({ name: 'unnoq' }, { context: { cache: 'force-cache' } });
These updates make it easier to build flexible and type-safe clients with more control over request handling.
🚨 Breaking Changes
- client: DynamicLink pass only context instead of full option - by @unnoq (2ba06)
- server: Rename .func() to .handler() - by @unteifu in #60 (5d3da)
🚀 Features
- client:
- openapi: