import { appResources } from "@/lib/mock-data"; import { AppResource } from "@/lib/types"; import { appListSchema, appResourceSchema } from "@/dto/app.dto"; import { requestWithSchema } from "@/services/api-client"; const USE_REMOTE_API = false; export async function getApps(): Promise { if (!USE_REMOTE_API) { return appListSchema.parse(appResources) as AppResource[]; } return requestWithSchema({ endpoint: "/api/apps", schema: appListSchema, }) as Promise; } export async function getAppBySlug(slug: string): Promise { if (!USE_REMOTE_API) { const matched = appResources.find((app) => app.slug === slug); return matched ? (appResourceSchema.parse(matched) as AppResource) : null; } const all = await getApps(); return all.find((app) => app.slug === slug) ?? null; }