v0.35.0
🚨 Breaking Changes 🚨
- Handlers have been rewritten to use native APIs in both
fetch
and Node.js' HTTP server. - The options
onStart
,onSuccess
,onError
, andonFinish
have been removed—use the new interceptors (onStart
,onError
, etc.) instead. OpenAPIServerHandler
andOpenAPIServerlessHandler
has been removed nowOpenAPIHandler
optimized for both.
🌟 Plugins 🌟
We're introducing two plugins: CORSPlugin
and ResponseHeadersPlugin
.
const openAPIHandler = new OpenAPIHandler(router, {
schemaCoercers: [new ZodCoercer()],
interceptors: [
onError((error) => {
console.error(error);
}),
],
plugins: [
new CORSPlugin({ origin: 'http://localhost:3000' }),
new ResponseHeadersPlugin(),
],
});
export interface ORPCContext extends ResponseHeadersPluginContext {
// ResponseHeadersPluginContext is injected
user?: z.infer<typeof UserSchema>;
db?: any;
}
const pub = os
.$context<ORPCContext>()
.use(({ context, next }) => {
context.resHeaders?.set('x-custom-header', 'custom-value');
return next();
});