import { getCloudflareContext } from "@opennextjs/cloudflare";

export interface AppCloudflareEnv {
  DB?: D1Database;
  EXPORT_BUCKET?: R2Bucket;
  API_ACCESS_KEY?: string;
}

export function getAppCloudflareEnv(): AppCloudflareEnv | null {
  if (process.env.APP_RUNTIME !== "cloudflare") {
    return null;
  }

  return getCloudflareContext().env as AppCloudflareEnv;
}
