refactor: streamline API calls and enhance configuration management
- 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.
This commit is contained in:
11
apps/backoffice/app/api/jobs/active/route.ts
Normal file
11
apps/backoffice/app/api/jobs/active/route.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { apiFetch, IndexJobDto } from "@/lib/api";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const data = await apiFetch<IndexJobDto[]>("/index/jobs/active");
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: "Failed to fetch active jobs" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user