Files
andon/server/api/defects.get.ts
Julien Calixte 999593b426 feat(defects): read API — feed, per-section counts and history (T6)
GET /api/defects returns a newest-first feed joined to the project name,
bounded by limit; ?section=ID narrows to one section's history. GET
/api/defects/counts returns { sectionId: n } for the weak-point map. Adds a
(section_id, created_at) index and a db:seed script; ~2k rows query in ~20ms.
2026-05-28 00:18:18 +02:00

13 lines
515 B
TypeScript

import { getDb } from '../db/client'
import { listDefects } from '../db/repositories/defects'
// Defect feed (F6), newest-first. `?section=ID` narrows to one section's
// history (the lazy modal load); `?limit=N` bounds the slice.
export default defineEventHandler(async (event) => {
const { section, limit } = getQuery(event)
return listDefects(getDb(), {
sectionId: typeof section === 'string' ? section : undefined,
limit: typeof limit === 'string' ? Number(limit) || undefined : undefined,
})
})