Split lib/utils.ts into: - lib/utils.ts: Client-safe utilities only (no Node.js imports) - lib/project-utils.ts: Server-only utilities with Node.js imports This fixes the Next.js build error where client components were importing modules that contained Node.js dependencies (fs, path). All tests pass and build succeeds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
21 lines
582 B
TypeScript
21 lines
582 B
TypeScript
// app/api/projects/route.ts
|
|
import { NextResponse } from 'next/server';
|
|
import { getProjects } from '@/lib/fs-utils';
|
|
import { getProjectDisplayName } from '@/lib/project-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 }
|
|
);
|
|
}
|
|
}
|