v0.23.0
π New Feature: Input/Output Structure π
Simplify or customize how your API handles data with Input/Output Structure!
π Highlights
-
inputStructure
:compact
: Merges params + query/body.detailed
: Keeps params, query, headers, and body separate.
-
outputStructure
:compact
: Returns only the body.detailed
: Separates headers and body.
Example
os.route({
inputStructure: 'detailed',
outputStructure: 'detailed',
})
.input(z.object({
params: z.object({ id: z.string() }),
query: z.object({ search: z.string() }),
body: z.object({ name: z.string() }).optional(),
}))
.handler((input) => ({
body: { message: 'Hello' },
headers: { 'x-header': 'value' },
}));