Files
ftdl/app/api/projects/route.ts
tech aeb29d0428 feat: update projects API to include display names
- Modified projects API route to return objects with name and displayName fields
- Added comprehensive tests for the updated API response structure
- Tests verify display name mapping and error handling
- All existing tests continue to pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:17:31 +08:00

21 lines
574 B
TypeScript

// app/api/projects/route.ts
import { NextResponse } from 'next/server';
import { getProjects } from '@/lib/fs-utils';
import { getProjectDisplayName } from '@/lib/utils';
export async function GET() {
try {
const projects = await getProjects();
const projectsWithAliases = projects.map(project => ({
name: project,
displayName: getProjectDisplayName(project),
}));
return NextResponse.json(projectsWithAliases);
} catch (error) {
return NextResponse.json(
{ error: 'Failed to fetch projects' },
{ status: 500 }
);
}
}