import type { APIRoute } from 'astro';
import {
  resolveAllPaths,
  buildPools,
  buildPaletteIndex,
} from '@lib/utils/paths';

export const GET: APIRoute = async () => {
  const [resolved, pools] = await Promise.all([
    resolveAllPaths(),
    buildPools(),
  ]);
  const index = buildPaletteIndex(resolved, pools);

  return new Response(JSON.stringify(index), {
    headers: { 'Content-Type': 'application/json' },
  });
};
