trpc.ts
For the full content of this gist, refer to https://gist.github.com/CodingAbdullah/32fd2e179d2096ed0b840d109a70cf81
Abdullah Muhammad@CodingAbdullah
McMaster. Software Engineer with a keen interest in blockchain and web3.
For the full content of this gist, refer to https://gist.github.com/CodingAbdullah/32fd2e179d2096ed0b840d109a70cf81
McMaster. Software Engineer with a keen interest in blockchain and web3.
import { initTRPC } from '@trpc/server';
import { ZodError } from 'zod';
// Initialize the TRPC server
const t = initTRPC.create({
errorFormatter({ shape, error }) {
return {
...shape,
data: {
...shape.data,
zodError:
error.cause instanceof ZodError ? error.cause.flatten() : null,
},
};
},
});
export const createTRPCRouter = t.router;
export const publicProcedure = t.procedure;