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>
This commit is contained in:
2026-03-04 21:28:16 +08:00
parent 149e3a5924
commit aeb29d0428
2 changed files with 47 additions and 1 deletions

View File

@@ -1,11 +1,16 @@
// 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();
return NextResponse.json(projects);
const projectsWithAliases = projects.map(project => ({
name: project,
displayName: getProjectDisplayName(project),
}));
return NextResponse.json(projectsWithAliases);
} catch (error) {
return NextResponse.json(
{ error: 'Failed to fetch projects' },