@restatedev/restate-sdk-zod
v1.10.4
Published
Typescript SDK for Restate
Downloads
74,001
Maintainers
Keywords
Readme
Restate Typescript SDK Zod integration
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.
Community
- 🤗️ Join our online community for help, sharing feedback and talking to the community.
- 📖 Check out our documentation to get quickly started!
- 📣 Follow us on Twitter for staying up to date.
- 🙋 Create a GitHub issue for requesting a new feature or reporting a problem.
- 🏠 Visit our GitHub org for exploring other repositories.
Using the library
To use this library, add the dependency to your project together with zod:
npm install --save zod @restatedev/restate-sdk-zodFor Zod v3 users
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.
Versions
This library follows Semantic Versioning.
