From de6004278d452d9e00ae1cad2408055013cbece9 Mon Sep 17 00:00:00 2001 From: MarconLP <13001502+MarconLP@users.noreply.github.com> Date: Tue, 11 Apr 2023 09:48:34 +0200 Subject: [PATCH] add tRPC router for videos --- src/server/api/root.ts | 2 ++ src/server/api/routers/video.ts | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/server/api/routers/video.ts diff --git a/src/server/api/root.ts b/src/server/api/root.ts index 93fba92..9cc2ab5 100644 --- a/src/server/api/root.ts +++ b/src/server/api/root.ts @@ -1,5 +1,6 @@ import { createTRPCRouter } from "~/server/api/trpc"; import { exampleRouter } from "~/server/api/routers/example"; +import { videoRouter } from "~/server/api/routers/video"; /** * This is the primary router for your server. @@ -8,6 +9,7 @@ import { exampleRouter } from "~/server/api/routers/example"; */ export const appRouter = createTRPCRouter({ example: exampleRouter, + video: videoRouter, }); // export type definition of API diff --git a/src/server/api/routers/video.ts b/src/server/api/routers/video.ts new file mode 100644 index 0000000..9073707 --- /dev/null +++ b/src/server/api/routers/video.ts @@ -0,0 +1,17 @@ +import { z } from "zod"; + +import { + createTRPCRouter, + publicProcedure, + protectedProcedure, +} from "~/server/api/trpc"; + +export const videoRouter = createTRPCRouter({ + getAll: publicProcedure.query(({ ctx }) => { + return ctx.prisma.video.findMany(); + }), + + get: publicProcedure.query(({ ctx }) => { + return ctx.prisma.video.findFirst(); + }), +});