spb/cancerindex
Public
TypeScript 97.2%
SQL 1.5%
CSS 0.6%
JavaScript 0.5%
1import { NextResponse } from 'next/server';2import { childrenOf } from '@/lib/queries/taxonomy';34export const dynamic = 'force-dynamic';56/** Lazily fetch children of a node for the tree browser. GET /api/taxonomy/children?id=CI-CAN-…&type=oncotree */7export async function GET(req: Request) {8 const url = new URL(req.url);9 const id = url.searchParams.get('id') ?? '';10 const type = url.searchParams.get('type') ?? 'ncit';11 if (!/^CI-CAN-\d{8,}$/.test(id)) return NextResponse.json({ error: 'invalid id' }, { status: 400 });12 if (!/^[a-z_]{2,24}$/.test(type)) return NextResponse.json({ error: 'invalid type' }, { status: 400 });13 const data = await childrenOf(id, type);14 return NextResponse.json({ data }, { headers: { 'Cache-Control': 'public, max-age=300, s-maxage=3600' } });15}16