File tree Expand file tree Collapse file tree 5 files changed +156
-129
lines changed Expand file tree Collapse file tree 5 files changed +156
-129
lines changed Original file line number Diff line number Diff 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
127132Defines the input validation schema using Zod. The input will be validated at runtime.
128133
Original file line number Diff line number Diff 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 > ;
Original file line number Diff line number Diff line change 4848 "devDependencies" : {
4949 "tsdown" : " ^0.12.9" ,
5050 "typescript" : " ^5.8.3" ,
51- "wrangler" : " ^4.23.0 "
51+ "wrangler" : " ^4.24.1 "
5252 }
5353}
You can’t perform that action at this time.
0 commit comments