simple event list and fix tables on settings
This commit is contained in:
@@ -6,6 +6,7 @@ import { userRouter } from "./routers/user";
|
||||
import { projectRouter } from "./routers/project";
|
||||
import { clientRouter } from "./routers/client";
|
||||
import { dashboardRouter } from "./routers/dashboard";
|
||||
import { eventRouter } from "./routers/event";
|
||||
|
||||
/**
|
||||
* This is the primary router for your server.
|
||||
@@ -20,6 +21,7 @@ export const appRouter = createTRPCRouter({
|
||||
user: userRouter,
|
||||
project: projectRouter,
|
||||
client: clientRouter,
|
||||
event: eventRouter,
|
||||
});
|
||||
|
||||
// export type definition of API
|
||||
|
||||
41
apps/web/src/server/api/routers/event.ts
Normal file
41
apps/web/src/server/api/routers/event.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { z } from "zod";
|
||||
import { createTRPCRouter, protectedProcedure } from "@/server/api/trpc";
|
||||
import { db } from "@/server/db";
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
responseLimit: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const eventRouter = createTRPCRouter({
|
||||
list: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
cursor: z.string().optional(),
|
||||
projectSlug: z.string(),
|
||||
take: z.number().default(100),
|
||||
skip: z.number().default(0),
|
||||
}),
|
||||
)
|
||||
.query(async ({ input: { take, skip, projectSlug } }) => {
|
||||
const project = await db.project.findUniqueOrThrow({
|
||||
where: {
|
||||
slug: projectSlug,
|
||||
},
|
||||
});
|
||||
return db.event.findMany({
|
||||
take,
|
||||
skip,
|
||||
where: {
|
||||
project_id: project.id,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
include: {
|
||||
profile: true,
|
||||
},
|
||||
});
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user