import { z } from "zod"; import { createTRPCRouter, protectedProcedure, publicProcedure, } from "@/server/api/trpc"; import { list } from "./list"; import { update } from "./update"; export const photosRouter = createTRPCRouter({ list: publicProcedure .input( z .object({ limit: z.number().nonnegative().default(2), cursor: z.number().nonnegative().default(0), }) .optional() .default({}), ) .query(async ({ input }) => { const ret = await list({ limit: input.limit + 1, cursor: input.cursor, }); let next: number | undefined; if (ret.length > input.limit) { next = input.limit; ret.pop(); } return { data: ret, next, }; }), update: publicProcedure.query(update), });