Files
next-portfolio/src/server/api/routers/photos/photos.ts
2025-08-23 17:39:54 +01:00

41 lines
759 B
TypeScript

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),
});