Spaces:
Runtime error
Runtime error
Download src/app/api/docs/tree/route.ts from Powerman9x/HuggingClaw-MissionControl: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/app/api/docs/tree/route.ts
- Command line
-
hf download hf://spaces/Powerman9x/HuggingClaw-MissionControl@123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/app/api/docs/tree/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/app/api/docs/tree/route.ts
798 Bytes
| import { NextRequest, NextResponse } from 'next/server' | |
| import { requireRole } from '@/lib/auth' | |
| import { readLimiter } from '@/lib/rate-limit' | |
| import { logger } from '@/lib/logger' | |
| import { getDocsTree, listDocsRoots } from '@/lib/docs-knowledge' | |
| export async function GET(request: NextRequest) { | |
| const auth = requireRole(request, 'viewer') | |
| if ('error' in auth) return NextResponse.json({ error: auth.error }, { status: auth.status }) | |
| const rateCheck = readLimiter(request) | |
| if (rateCheck) return rateCheck | |
| try { | |
| const tree = await getDocsTree() | |
| return NextResponse.json({ roots: listDocsRoots(), tree }) | |
| } catch (error) { | |
| logger.error({ err: error }, 'GET /api/docs/tree error') | |
| return NextResponse.json({ error: 'Failed to load docs tree' }, { status: 500 }) | |
| } | |
| } | |