add tRPC router for videos
This commit is contained in:
parent
74670a0cd4
commit
de6004278d
2 changed files with 19 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
17
src/server/api/routers/video.ts
Normal file
17
src/server/api/routers/video.ts
Normal file
|
|
@ -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();
|
||||
}),
|
||||
});
|
||||
Loading…
Reference in a new issue