import {
  PRODUCTION_RESOURCES,
  buildProductionConfig,
} from "./cloudflare-production-config.mjs";

export const PAGES_PROJECT = "hearbooks-reader-pages";

export function buildPagesConfig({ databaseId }) {
  buildProductionConfig({ databaseId });
  return {
    $schema: "../node_modules/wrangler/config-schema.json",
    name: PAGES_PROJECT,
    pages_build_output_dir: "../dist/pages",
    compatibility_date: "2026-08-28",
    compatibility_flags: ["nodejs_compat"],
    d1_databases: [{
      binding: "DB",
      database_name: PRODUCTION_RESOURCES.database,
      database_id: databaseId,
      migrations_dir: "../drizzle",
    }],
    r2_buckets: [{
      binding: "STORAGE",
      bucket_name: PRODUCTION_RESOURCES.bucket,
    }],
  };
}
