Skip to content

Commit 3c80f70

Browse files
committed
feat: make input optional
1 parent 4db7928 commit 3c80f70

File tree

5 files changed

+156
-129
lines changed

5 files changed

+156
-129
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ export class MyDurableObject extends SafeDurableObjectBuilder(
8585
id: ctx.id.toString(),
8686
};
8787
}),
88+
ping: fn.output(z.object({ message: z.string() })).implement(function () {
89+
return {
90+
message: "pong",
91+
};
92+
}),
8893
})
8994
) {}
9095

@@ -122,7 +127,7 @@ fn.input(inputSchema).implement(handler); // output schema is optional
122127

123128
**Note: Only `zod/v4` schemas are supported**
124129

125-
##### `.input(schema)`
130+
##### `.input(schema)` (optional)
126131

127132
Defines the input validation schema using Zod. The input will be validated at runtime.
128133

example/worker.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export class MyDurableObject extends SafeDurableObjectBuilder(
4141
id: ctx.id.toString(),
4242
};
4343
}),
44+
ping: fn.output(z.object({ message: z.string() })).implement(function ({}) {
45+
return {
46+
message: "pong",
47+
};
48+
}),
4449
})
4550
) {}
4651

@@ -49,7 +54,8 @@ export default {
4954
const stub = env.MY_DURABLE_OBJECT.get(
5055
env.MY_DURABLE_OBJECT.idFromName("test")
5156
);
52-
const res = await stub.hello("world");
53-
return Response.json(res);
57+
const hello = await stub.hello("world");
58+
const ping = await stub.ping();
59+
return Response.json({ hello, ping });
5460
},
5561
} as ExportedHandler<Env>;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
"devDependencies": {
4949
"tsdown": "^0.12.9",
5050
"typescript": "^5.8.3",
51-
"wrangler": "^4.23.0"
51+
"wrangler": "^4.24.1"
5252
}
5353
}

0 commit comments

Comments
 (0)