feat(defects): file a defect via a board-section modal (T5)
POST /api/defects validates the body with arktype (known section, uuid project, non-empty trimmed verbatim) and resolves the reporter through a dev seam (getReporter, ADR 0002) until OAuth lands. DefectForm is a DaisyUI modal opened by a section click — pick a project, describe the problem, submit.
This commit is contained in:
15
server/api/defects.post.ts
Normal file
15
server/api/defects.post.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { type } from 'arktype'
|
||||
import { getDb } from '../db/client'
|
||||
import { createDefect } from '../db/repositories/defects'
|
||||
import { DefectInput } from '../utils/defectInput'
|
||||
import { getReporter } from '../utils/getReporter'
|
||||
|
||||
// File a defect against a board section (F2). Reporter comes from the seam,
|
||||
// not the client; the timestamp defaults in the DB.
|
||||
export default defineEventHandler(async (event) => {
|
||||
const input = DefectInput(await readBody(event))
|
||||
if (input instanceof type.errors) {
|
||||
throw createError({ statusCode: 400, statusMessage: input.summary })
|
||||
}
|
||||
return createDefect(getDb(), { ...input, reporterEmail: getReporter(event) })
|
||||
})
|
||||
Reference in New Issue
Block a user