Experiments with tRPC and Nuxt Server API
This commit is contained in:
15
server/api/test/[hello].ts
Normal file
15
server/api/test/[hello].ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const pathSchema = z.object({
|
||||
hello: z.string()
|
||||
});
|
||||
|
||||
const bodySchema = z.object({
|
||||
world: z.string()
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const pathParams = await getValidatedRouterParams(event, pathSchema.parse);
|
||||
const body = await readValidatedBody(event, bodySchema.parse);
|
||||
return { risultato: `${pathParams.hello}-${body.world}` };
|
||||
});
|
||||
Reference in New Issue
Block a user