- api-auth.ts was al aanwezig; demo-check toegevoegd per endpoint (ST-401) - Token aanmaken (SHA-256 hash, eenmalig tonen), intrekken, max 10 (ST-402) - GET /api/products actieve productenlijst (ST-403) - GET /api/products/:id/next-story hoogst geprioriteerde open story (ST-404) - GET /api/sprints/:id/tasks met limit parameter (ST-405) - PATCH /api/stories/:id/tasks/reorder met ID-validatie (ST-406) - POST /api/stories/:id/log met discriminatedUnion per type (ST-407) - PATCH /api/tasks/:id status bijwerken met cross-user bescherming (ST-408) - POST /api/todos via API aanmaken (ST-409) - StoryLog component met kleurcodering per type in story slide-over (ST-410) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { authenticateApiRequest } from '@/lib/api-auth'
|
|
import { prisma } from '@/lib/prisma'
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const auth = await authenticateApiRequest(request)
|
|
if ('error' in auth) {
|
|
return Response.json({ error: auth.error }, { status: auth.status })
|
|
}
|
|
|
|
const { id } = await params
|
|
const url = new URL(request.url)
|
|
const limitParam = parseInt(url.searchParams.get('limit') ?? '10')
|
|
const limit = Math.min(Math.max(1, limitParam), 50)
|
|
|
|
const sprint = await prisma.sprint.findFirst({
|
|
where: { id, product: { user_id: auth.userId } },
|
|
})
|
|
if (!sprint) {
|
|
return Response.json({ error: 'Sprint niet gevonden' }, { status: 404 })
|
|
}
|
|
|
|
const tasks = await prisma.task.findMany({
|
|
where: { sprint_id: id },
|
|
orderBy: [
|
|
{ story: { sort_order: 'asc' } },
|
|
{ priority: 'asc' },
|
|
{ sort_order: 'asc' },
|
|
],
|
|
take: limit,
|
|
select: { id: true, title: true, story_id: true, priority: true, sort_order: true, status: true },
|
|
})
|
|
|
|
return Response.json(tasks)
|
|
}
|