Skip to content

Commit 0d14acd

Browse files
committed
refactor(comments): move CreateCommentBody schema to @reprojs/shared
Extracts the inline z.object validation from the comments POST endpoint into a reusable exported schema in packages/shared, matching the TriagePatchInput const+type alias pattern for MCP-side reuse.
1 parent 43c3804 commit 0d14acd

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

apps/dashboard/server/api/projects/[id]/reports/[reportId]/comments/index.post.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ import {
66
readValidatedBody,
77
setResponseStatus,
88
} from "h3"
9-
import { z } from "zod"
9+
import { CreateCommentBody } from "@reprojs/shared"
1010
import { db } from "../../../../../../db"
1111
import {
1212
addReportComment,
1313
addReportCommentSideEffects,
1414
} from "../../../../../../lib/comments-service"
1515
import { requireProjectRole } from "../../../../../../lib/permissions"
1616

17-
const CreateCommentBody = z.object({
18-
body: z.string().min(1).max(65_536),
19-
})
20-
2117
export default defineEventHandler(async (event) => {
2218
const projectId = getRouterParam(event, "id")
2319
const reportId = getRouterParam(event, "reportId")

packages/shared/src/reports.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ export const TriagePatchInput = z
186186
)
187187
export type TriagePatchInput = z.infer<typeof TriagePatchInput>
188188

189+
export const CreateCommentBody = z.object({
190+
body: z.string().min(1).max(65_536),
191+
})
192+
export type CreateCommentBody = z.infer<typeof CreateCommentBody>
193+
189194
export const BulkUpdateInput = z
190195
.object({
191196
reportIds: z.array(z.uuid()).min(1).max(100),

0 commit comments

Comments
 (0)