Restate is a system for easily building resilient applications using distributed durable async/await.
This package contains a zod integration, allowing to define input/output models of your handlers.
import * as restate from "@restatedev/restate-sdk";
import { serde } from "@restatedev/restate-sdk-zod";
import { z } from "zod";
const Greeting = z.object({
name: z.string(),
});
const greeter = restate.service({
name: "greeter",
handlers: {
greet: restate.handlers.handler(
{
input: serde.zod(Greeting),
output: serde.zod(z.string()),
},
async (ctx, greeting) => {
return `Hello ${greeting.name}!`;
}
),
},
});
export type Greeter = typeof greeter;
restate.serve({ services: [greeter], port: 9080 });
For the SDK main package, checkout @restatedev/restate-sdk
.
To use this library, add the dependency to your project together with zod
:
npm install --save zod @restatedev/restate-sdk-zod
We recommend Zod v3 users, that can't upgrade yet to Zod v4 yet, to use the module version 1.8.3, which fully supports Zod v3.
This library follows Semantic Versioning.