import QRCode from "qrcode";
import { APP_DOMAIN } from "./config";

export async function generateMonumentQR(subdomain: string): Promise<string> {
  const url = `https://${subdomain}.${APP_DOMAIN}`;
  const qrBuffer = await QRCode.toBuffer(url, {
    type: "png",
    width: 400,
    margin: 2,
    color: {
      dark: "#1a1a2e",
      light: "#ffffff",
    },
  });

  return `data:image/png;base64,${qrBuffer.toString("base64")}`;
}

export async function generateMonumentQRPng(subdomain: string): Promise<Buffer> {
  const url = `https://${subdomain}.${APP_DOMAIN}`;
  return QRCode.toBuffer(url, {
    type: "png",
    width: 400,
    margin: 2,
    color: {
      dark: "#1a1a2e",
      light: "#ffffff",
    },
  });
}