Example: Added a basic example with a product call

This commit is contained in:
Ryan Gannon
2023-06-13 15:00:38 +01:00
parent ad85a78350
commit 3fc261d5e7
15 changed files with 343 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { z } from 'zod'
import { publicProcedure, router } from '../trpc'
export const appRouter = router({
hello: publicProcedure
.input(
z.object({
text: z.string().nullish(),
})
)
.query(({ input }) => {
console.log(input)
return {
greeting: `hello ${input?.text ?? 'world'}`,
}
}),
products: publicProcedure.query(async () => {
return {
title: 'TRPC Nuxt',
price: 12.0,
description: 'Check out the trpc-nuxt repo',
}
}),
})
// export type definition of API
export type AppRouter = typeof appRouter