import { initTRPC } from '@trpc/server';
import { z } from 'zod';
const t = initTRPC.create();
const publicProcedure = t.procedure;
const randomSchema = z.object({
name: z.string(),
});
type RandomType = z.infer<typeof randomSchema>;
const appRouter = t.router({
UserRouter: {
hello: publicProcedure.input<RandomType>().query((opts) => {
const name = opts.input.name;
return {
greeting: `Hello ${opts.input.name}`,
};
}),
},
});
export type AppRouter = typeof appRouter;
import { initTRPC } from '@trpc/server';
import { z } from 'zod';
const t = initTRPC.create();
const publicProcedure = t.procedure;
const randomSchema = z.object({
name: z.string(),
});
type RandomType = z.infer<typeof randomSchema>;
const appRouter = t.router({
UserRouter: {
hello: publicProcedure.input<RandomType>().query((opts) => {
const name = opts.input.name;
return {
greeting: `Hello ${opts.input.name}`,
};
}),
},
});
export type AppRouter = typeof appRouter;