-
Couldn't load subscription status.
- Fork 295
Open
Labels
Description
Describe the feature
In CLI and codebase scanning architectures, type inference and code merging often create inconsistencies with methods like .get, .post, etc., leading to a different set of challenges in every project. To prevent this and achieve a strictly consistent system, introducing a new structured approach unlocks many bottlenecks. In the modern ecosystem, support for StandardSchema significantly simplifies module development—even in specialized modules like OpenAPI and others.
import { H3, defineEventHandler, defineRoute, readBody, readValidatedBody } from "h3";
import { z } from "zod";
export const book = defineRoute({
method: "GET",
route: "/api/books",
routerParams: z.object({
id: z.string(),
}),
queryParams: z.object({
page: z.string().optional(),
limit: z.string().optional(),
}),
input: z.object({
title: z.string(),
}),
output: z.object({
message: z.string(),
name: z.string(),
}),
handler: async (event)=> {
const data = await readBody(event);
const data2 = await readValidatedBody(event)
return {
message: "Book list",
name: ''
}
}
});
const app = new H3();
app.addRoute(book);Additional information
- Would you be willing to help implement this feature?
KarlitosD and typed-sigtermpi0, zsilbi, OskarLebuda, unitythemaker, KarlitosD and 2 more