UNPKG

@proofkit/cli

Version:

Create web application with the ProofKit stack

38 lines (31 loc) 772 B
import { z } from "zod/v4"; import { createTRPCRouter, protectedProcedure, publicProcedure, } from "~/server/api/trpc"; let post = { id: 1, name: "Hello World", }; export const postRouter = createTRPCRouter({ hello: publicProcedure .input(z.object({ text: z.string() })) .query(({ input }) => { return { greeting: `Hello ${input.text}`, }; }), create: protectedProcedure .input(z.object({ name: z.string().min(1) })) .mutation(async ({ input }) => { post = { id: post.id + 1, name: input.name }; return post; }), getLatest: protectedProcedure.query(() => { return post; }), getSecretMessage: protectedProcedure.query(() => { return "you can now see this secret message!"; }), });