Declares a route with the body and query types inferred from its schema (inside a plain routes: [...] list they would be unknown):
routes: [...]
unknown
defineRoute({ method: "POST", path: "/users", schema: { body: z.object({ name: z.string() }) }, handler: (ctx) => ({ created: ctx.body.name }), // string}); Copy
defineRoute({ method: "POST", path: "/users", schema: { body: z.object({ name: z.string() }) }, handler: (ctx) => ({ created: ctx.body.name }), // string});
Declares a route with the body and query types inferred from its schema (inside a plain
routes: [...]list they would beunknown):