Burn it all to the ground and start with bun and a reorg
This commit is contained in:
40
src/server/api/routers/photos/photos.ts
Normal file
40
src/server/api/routers/photos/photos.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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(1),
|
||||
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: protectedProcedure.query(update),
|
||||
});
|
||||
Reference in New Issue
Block a user