- fix(studio): stop markBatchDone infinite recursion so batches complete - refactor(api): merge api-response into api and drop the duplicate module - refactor(media): extract shared media loader and URL validator - refactor(ui): extract shared LoadingSpinner for site and admin groups - refactor(dates): consolidate raw date formatting into formatDate util - refactor(logs): share a single generic log-list loader across tables - refactor(theme): merge both ColorField components and reuse contrast helpers - refactor(import): extract shared ImportErrorBanner and SearchInput - chore(): remove dead theme-editor-tabs after inlining tab components
23 lines
732 B
TypeScript
23 lines
732 B
TypeScript
import { apiError, apiOk } from "@/lib/api";
|
|
import { withAdmin } from "@/lib/api-handler";
|
|
import { PERMS } from "@/lib/permissions";
|
|
import { loadCatalogItemsData } from "@/lib/services/catalog-items-loader";
|
|
|
|
function jsonSafe<T>(data: T): T {
|
|
return JSON.parse(
|
|
JSON.stringify(data, (_k, v) => (typeof v === "bigint" ? Number(v) : v)),
|
|
) as T;
|
|
}
|
|
|
|
export const GET = withAdmin(
|
|
{ permission: PERMS.CATALOG_VIEW },
|
|
async (request) => {
|
|
const pageId = Number(request.nextUrl.searchParams.get("pageId"));
|
|
if (!Number.isFinite(pageId) || pageId <= 0) {
|
|
return apiError("Invalid pageId");
|
|
}
|
|
const data = await loadCatalogItemsData(pageId);
|
|
return apiOk(jsonSafe(data) as unknown as Record<string, unknown>);
|
|
},
|
|
);
|