- Refactor multiple API routes to utilize a centralized configuration function for base URL and token management, improving code consistency and maintainability. - Replace direct environment variable access with a unified config function in the `lib/api.ts` file. - Remove redundant error handling and streamline response handling in various API endpoints. - Delete unused job-related API routes and settings, simplifying the overall API structure.
14 lines
453 B
TypeScript
14 lines
453 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { listFolders } from "@/lib/api";
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const path = searchParams.get("path") || undefined;
|
|
const data = await listFolders(path);
|
|
return NextResponse.json(data);
|
|
} catch (error) {
|
|
return NextResponse.json({ error: "Failed to fetch folders" }, { status: 500 });
|
|
}
|
|
}
|